Problem/Motivation

It would be nice to write test coverage for this to check that a JSON:API path is inaccessible once this module is enabled.

Steps to reproduce

n/a

Proposed resolution

Create a PHPUnit test that will run and implement CI to check and ensure test is passing.

Remaining tasks

I think this can be done by

  1. Go to a known path, /jsonapi/node/article
  2. ensure the response code is 403
  3. parse the request and ensure it is checking for the correct permission string

Since we need a fully bootstrapped Drupal instance, this should be a Functional test.

User interface changes

n/a

API changes

n/a

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dan612 created an issue. See original summary.

dan612’s picture

Started the work here. Need to actually run the tests in Gitlab CI, but locally am getting the following to pass:

$ ../vendor/bin/phpunit modules/contrib/jsonapi_permission_access/tests/src/Functional/JsonApiPermissionAccessTest.php --verbose -c ./core/phpunit.xml.dist
PHPUnit 9.6.19 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.15
Configuration: ./core/phpunit.xml.dist

Testing Drupal\Tests\jsonapi_permission_access\JsonApiPermissionAccessTest\JsonApiPermissionAccessTest
.                                                                   1 / 1 (100%)

Time: 00:04.327, Memory: 4.00 MB

OK (1 test, 10 assertions)

dan612’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.