Skip to content
Snippets Groups Projects
Verified Commit c3c8f13a authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3306434 by benjifisher, quietone, Berdir, kopeboy, DYdave, larowlan:...

Issue #3306434 by benjifisher, quietone, Berdir, kopeboy, DYdave, larowlan: Fix access checks for bundle permissions to avoid triggering a config validation error

(cherry picked from commit 3f03a0aa)
parent d322b132
No related branches found
No related tags found
11 merge requests!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8949Backport .gitlabci.yml changes.,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #230452 passed with warnings
Pipeline: drupal

#230473

    Pipeline: drupal

    #230465

      Pipeline: drupal

      #230462

        +1
        ......@@ -93,11 +93,10 @@ protected function permissionsByProvider(): array {
        // Get the names of all config entities that depend on $this->bundle.
        $config_name = $this->bundle->getConfigDependencyName();
        $config_entities = $this->configManager
        ->getConfigEntitiesToChangeOnDependencyRemoval('config', [$config_name]);
        ->findConfigEntityDependencies('config', [$config_name]);
        $config_names = array_map(
        function ($dependent_config) {
        return $dependent_config->getConfigDependencyName();
        }, $config_entities['delete'] ?? []
        fn($dependent_config) => $dependent_config->getConfigDependencyName(),
        $config_entities,
        );
        $config_names[] = $config_name;
        ......
        ......@@ -4,9 +4,10 @@
        namespace Drupal\Tests\user\Functional;
        use Drupal\comment\Tests\CommentTestTrait;
        use Drupal\Tests\BrowserTestBase;
        use Drupal\user\RoleInterface;
        use Drupal\user\Entity\Role;
        use Drupal\user\RoleInterface;
        /**
        * Verifies role permissions can be added and removed via the permissions page.
        ......@@ -15,6 +16,8 @@
        */
        class UserPermissionsTest extends BrowserTestBase {
        use CommentTestTrait;
        /**
        * User with admin privileges.
        *
        ......@@ -297,4 +300,35 @@ public function testAccessBundlePermission(): void {
        $this->assertSession()->statusCodeEquals(403);
        }
        /**
        * Tests that access check does not trigger warnings.
        *
        * The access check for /admin/structure/comment/manage/comment/permissions is
        * \Drupal\user\Form\EntityPermissionsForm::EntityPermissionsForm::access().
        */
        public function testBundlePermissionError(): void {
        \Drupal::service('module_installer')->install(['comment', 'dblog', 'field_ui', 'node']);
        // Set up the node and comment field. Use the 'default' view mode since
        // 'full' is not defined, so it will not be added to the config entity.
        $this->drupalCreateContentType(['type' => 'article']);
        $this->addDefaultCommentField('node', 'article', comment_view_mode: 'default');
        $this->drupalLogin($this->adminUser);
        $this->grantPermissions(Role::load($this->rid), ['access site reports', 'administer comment display']);
        // Access both the Manage display and permission page, which is not
        // accessible currently.
        $assert_session = $this->assertSession();
        $this->drupalGet('/admin/structure/comment/manage/comment/display');
        $assert_session->statusCodeEquals(200);
        $this->drupalGet('/admin/structure/comment/manage/comment/permissions');
        $assert_session->statusCodeEquals(403);
        // Ensure there are no warnings in the log.
        $this->drupalGet('/admin/reports/dblog');
        $assert_session->statusCodeEquals(200);
        $assert_session->pageTextContains('access denied');
        $assert_session->pageTextNotContains("Entity view display 'node.article.default': Component");
        }
        }
        ......@@ -60,12 +60,10 @@ public function testPermissionsByProvider(string $dependency_name, bool $found):
        $module_handler = $this->prophesize(ModuleHandlerInterface::class)->reveal();
        $module_extension_list = $this->prophesize(ModuleExtensionList::class)->reveal();
        $prophecy = $this->prophesize(ConfigManagerInterface::class);
        $prophecy->getConfigEntitiesToChangeOnDependencyRemoval('config', ['node.type.article'])
        $prophecy->findConfigEntityDependencies('config', ['node.type.article'])
        ->willReturn([
        'delete' => [
        new ConfigEntityDependency('core.entity_view_display.node.article.full'),
        new ConfigEntityDependency('field.field.node.article.body'),
        ],
        new ConfigEntityDependency('core.entity_view_display.node.article.full'),
        new ConfigEntityDependency('field.field.node.article.body'),
        ]);
        $config_manager = $prophecy->reveal();
        $prophecy = $this->prophesize(EntityTypeInterface::class);
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment