Commit 930a35b9 authored by larowlan's avatar larowlan

Issue #2843753 by Wim Leers, amateescu: Prevent ContentModerationState from...

Issue #2843753 by Wim Leers, amateescu: Prevent ContentModerationState from being exposed by REST's EntityResource
parent ba0ac0fd
......@@ -262,3 +262,13 @@ function content_moderation_workflow_insert(WorkflowInterface $entity) {
function content_moderation_workflow_update(WorkflowInterface $entity) {
content_moderation_workflow_insert($entity);
}
/**
* Implements hook_rest_resource_alter().
*/
function content_moderation_rest_resource_alter(&$definitions) {
// ContentModerationState is an internal entity type. Therefore it should not
// be exposed via REST.
// @see \Drupal\content_moderation\ContentModerationStateAccessControlHandler
unset($definitions['entity:content_moderation_state']);
}
<?php
namespace Drupal\Tests\content_moderation\Kernel;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\KernelTests\KernelTestBase;
use Drupal\rest\Entity\RestResourceConfig;
use Drupal\rest\RestResourceConfigInterface;
/**
* @group content_moderation
*/
class ContentModerationStateResourceTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['serialization', 'rest', 'content_moderation'];
/**
* @see content_moderation_rest_resource_alter()
*/
public function testCreateContentModerationStateResource() {
$this->setExpectedException(PluginNotFoundException::class, 'The "entity:content_moderation_state" plugin does not exist.');
RestResourceConfig::create([
'id' => 'entity.content_moderation_state',
'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
'configuration' => [
'methods' => ['GET'],
'formats' => ['json'],
'authentication' => ['cookie'],
],
])
->enable()
->save();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment