Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsonapi_permission_access
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
jsonapi_permission_access
Merge requests
!3
3442351: Adding initial testing.
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
3442351: Adding initial testing.
issue/jsonapi_permission_access-3442351:3442351-implement-test-coverage
into
1.0.x
Overview
3
Commits
5
Pipelines
4
Changes
3
All threads resolved!
Thread options
Show all comments
Merged
3442351: Adding initial testing.
Daniel Chadwick
requested to merge
issue/jsonapi_permission_access-3442351:3442351-implement-test-coverage
into
1.0.x
Apr 21, 2024
Overview
3
Commits
5
Pipelines
4
Changes
3
All threads resolved!
Thread options
Show all comments
Closes
#3442351
0
0
Merge request reports
Compare
1.0.x
version 4
84a53b43
Sep 28, 2024
version 3
0ea31aeb
Sep 28, 2024
version 2
071b240d
Sep 28, 2024
version 1
93d803d9
Apr 21, 2024
1.0.x (base)
and
latest version
latest version
3eb7e27c
5 commits,
Sep 28, 2024
version 4
84a53b43
4 commits,
Sep 28, 2024
version 3
0ea31aeb
3 commits,
Sep 28, 2024
version 2
071b240d
2 commits,
Sep 28, 2024
version 1
93d803d9
1 commit,
Apr 21, 2024
3 files
+
99
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
tests/src/Functional/JsonApiPermissionAccessTest.php
0 → 100644
+
69
−
0
View file @ 3eb7e27c
Edit in single-file editor
Open in Web IDE
Show comments on this file
<?php
namespace
Drupal\Tests\jsonapi_permission_access\JsonApiPermissionAccessTest
;
use
Drupal\Tests\BrowserTestBase
;
/**
* Testing JSON:API Permission Access.
*
* @group jsonapi_permission_access
*/
class
JsonApiPermissionAccessTest
extends
BrowserTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'node'
,
'jsonapi'
,
'serialization'
,
'jsonapi_permission_access'
,
];
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* Setup function.
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// Create an article content type for testing.
$this
->
drupalCreateContentType
([
'type'
=>
'article'
,
'name'
=>
'Article'
,
]);
// Create article which will have NID.
$this
->
drupalCreateNode
([
'type'
=>
'article'
,
'title'
=>
'Article for testing.'
,
]);
$this
->
container
->
get
(
'router.builder'
)
->
rebuild
();
}
/**
* Tests that a 403 is returned on JSON:API routes.
*/
public
function
testJsonApiStatusCode
()
{
$account
=
$this
->
drupalCreateUser
([
'access content'
]);
$this
->
drupalLogin
(
$account
);
$this
->
drupalGet
(
'jsonapi/node/article'
);
$this
->
assertSession
()
->
statusCodeEquals
(
403
);
}
/**
* Tests that a user with the correct permission can access.
*/
public
function
testUserAccessWithPermission
()
{
$account
=
$this
->
drupalCreateUser
([
'access jsonapi routes'
]);
$this
->
drupalLogin
(
$account
);
$this
->
drupalGet
(
'jsonapi/node/article'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
}
}
Loading