.../ConfigTest/ConfigTestHalJsonAnonTest.php | 42 +++++++++++++++++ .../ConfigTest/ConfigTestHalJsonBasicAuthTest.php | 53 +++++++++++++++++++++ .../config_test_rest/config_test_rest.info.yml | 7 +++ .../config_test_rest/config_test_rest.module | 26 +++++++++++ .../config_test_rest.permissions.yml | 2 + .../ConfigTest/ConfigTestJsonAnonTest.php | 36 +++++++++++++++ .../ConfigTest/ConfigTestJsonBasicAuthTest.php | 52 +++++++++++++++++++++ .../ConfigTest/ConfigTestResourceTestBase.php | 54 ++++++++++++++++++++++ 8 files changed, 272 insertions(+) diff --git a/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonAnonTest.php new file mode 100644 index 0000000..cf687e6 --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonAnonTest.php @@ -0,0 +1,42 @@ +grantPermissionsToAnonymousRole(['view config_test']); + } + +} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonBasicAuthTest.php b/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonBasicAuthTest.php new file mode 100644 index 0000000..9c9790d --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/ConfigTest/ConfigTestHalJsonBasicAuthTest.php @@ -0,0 +1,53 @@ +account = $this->createUser(['view config_test']); + } + + // @todo Fix in https://www.drupal.org/node/2805281: remove this trait usage. + use HalJsonBasicAuthWorkaroundFor2805281Trait { + HalJsonBasicAuthWorkaroundFor2805281Trait::verifyResponseWhenMissingAuthentication insteadof BasicAuthResourceTestTrait; + } + +} diff --git a/core/modules/rest/tests/modules/config_test_rest/config_test_rest.info.yml b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.info.yml new file mode 100644 index 0000000..cf9efee --- /dev/null +++ b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.info.yml @@ -0,0 +1,7 @@ +name: 'Configuration test REST' +type: module +package: Testing +version: VERSION +core: 8.x +dependencies: + - config_test diff --git a/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module new file mode 100644 index 0000000..f7e24a2 --- /dev/null +++ b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module @@ -0,0 +1,26 @@ +hasPermission('view config_test'))->cachePerPermissions(); +} diff --git a/core/modules/rest/tests/modules/config_test_rest/config_test_rest.permissions.yml b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.permissions.yml new file mode 100644 index 0000000..b8fd229 --- /dev/null +++ b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.permissions.yml @@ -0,0 +1,2 @@ +view config_test: + title: 'View ConfigTest entities' diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonAnonTest.php new file mode 100644 index 0000000..139e17f --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonAnonTest.php @@ -0,0 +1,36 @@ +grantPermissionsToAnonymousRole(['view config_test']); + } + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonBasicAuthTest.php new file mode 100644 index 0000000..f7365a6 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestJsonBasicAuthTest.php @@ -0,0 +1,52 @@ +account = $this->createUser(['view config_test']); + } + + // @todo Fix in https://www.drupal.org/node/2805281: remove this trait usage. + use JsonBasicAuthWorkaroundFor2805281Trait { + JsonBasicAuthWorkaroundFor2805281Trait::verifyResponseWhenMissingAuthentication insteadof BasicAuthResourceTestTrait; + } + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestResourceTestBase.php new file mode 100644 index 0000000..2e93715 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ConfigTest/ConfigTestResourceTestBase.php @@ -0,0 +1,54 @@ + 'llama', + 'label' => 'Llama', + ]); + $config_test->save(); + + return $config_test; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); + $normalization = [ + 'uuid' => $this->entity->uuid(), + 'id' => 'llama', + 'weight' => 0, + 'langcode' => 'en', + 'status' => TRUE, + 'dependencies' => [], + 'label' => 'Llama', + 'style' => NULL, + 'size' => NULL, + 'size_value' => NULL, + 'protected_property' => NULL, + ]; + + return $normalization; + } + +}