diff --git a/helfi_api_base.routing.yml b/helfi_api_base.routing.yml index cb51d2cb..3dc54f8f 100644 --- a/helfi_api_base.routing.yml +++ b/helfi_api_base.routing.yml @@ -20,4 +20,4 @@ helfi_api_base.debug_list: _title: 'Debug' _controller: '\Drupal\helfi_api_base\Controller\DebugController::build' requirements: - _permission: 'restful get helfi_debug_data' + _permission: 'restful get helfi_debug_package_version' diff --git a/tests/src/Functional/DebugUiTest.php b/tests/src/Functional/DebugUiTest.php index 360ce2c2..86888d1d 100644 --- a/tests/src/Functional/DebugUiTest.php +++ b/tests/src/Functional/DebugUiTest.php @@ -4,8 +4,6 @@ namespace Drupal\Tests\helfi_api_base\Functional; -use Drupal\user\Entity\Role; - /** * Tests debug data rest resource. * @@ -27,34 +25,6 @@ class DebugUiTest extends MigrationTestBase { */ protected $defaultTheme = 'stark'; - /** - * Tests /debug endpoint. - */ - public function testDebugEndpoint() : void { - $this->drupalGet('/api/v1/debug'); - $this->assertSession()->statusCodeEquals(403); - - // Allow all users to fetch resources. - Role::load('anonymous') - ->grantPermission('restful get helfi_debug_data') - ->save(); - - $this->drupalGet('/api/v1/debug'); - $this->assertSession()->statusCodeEquals(200); - $content = json_decode($this->getSession()->getPage()->getContent(), TRUE); - - $this->assertNotEmpty($content['composer']); - // Make sure we have no imported items by default. - $this->assertEquals(0, $content['migrate']['data'][0]['imported']); - // Run migration to verify that caches are cleared properly. - $this->executeMigration('dummy_migrate'); - - $this->drupalGet('/api/v1/debug'); - $this->assertSession()->statusCodeEquals(200); - $content = json_decode($this->getSession()->getPage()->getContent(), TRUE); - $this->assertEquals(4, $content['migrate']['data'][0]['imported']); - } - /** * Tests the admin UI route. */ @@ -62,7 +32,7 @@ public function testDebugAdminUi() : void { $this->drupalGet('/admin/debug'); $this->assertSession()->statusCodeEquals(403); - $account = $this->createUser(['restful get helfi_debug_data']); + $account = $this->createUser(['restful get helfi_debug_package_version']); $this->drupalLogin($account); $this->drupalGet('/admin/debug'); diff --git a/tests/src/Functional/InstallTest.php b/tests/src/Functional/InstallTest.php deleted file mode 100644 index b0fe87ce..00000000 --- a/tests/src/Functional/InstallTest.php +++ /dev/null @@ -1,86 +0,0 @@ -config('helfi_api_base.api_accounts') - ->set('accounts', [ - [ - 'username' => 'helfi-admin', - 'password' => '123', - 'roles' => ['debug_api'], - ], - ]) - ->save(); - } - catch (SchemaIncompleteException) { - } - } - - /** - * Make sure debug api role is created when accounts are defined. - */ - public function testInstall() : void { - /** @var \Drupal\Core\Extension\ModuleInstaller $moduleInstaller */ - $moduleInstaller = $this->container->get('module_installer'); - // Enable the 'helfi_api_base' module to trigger hook_install(). - $moduleInstaller->install(['helfi_api_base']); - // Make sure 'debug_api' role is not created when active project is not - // defined. - $this->assertNull(Role::load('debug_api')); - - // Re-install the module to make sure 'debug_api' role is created and - // required permissions are granted when active environment is defined. - $moduleInstaller->uninstall(['helfi_api_base']); - - try { - $this->setActiveProject(Project::ASUMINEN, EnvironmentEnum::Local); - } - catch (SchemaIncompleteException) { - } - $moduleInstaller->install(['helfi_api_base']); - - /** @var \Drupal\user\Entity\Role $role */ - $role = Role::load('debug_api'); - $this->assertTrue($role->hasPermission('restful get helfi_debug_data')); - } - -} diff --git a/tests/src/Kernel/Controller/DebugControllerTest.php b/tests/src/Kernel/Controller/DebugControllerTest.php index a24c62e2..c09cd058 100644 --- a/tests/src/Kernel/Controller/DebugControllerTest.php +++ b/tests/src/Kernel/Controller/DebugControllerTest.php @@ -37,7 +37,7 @@ public function testControllerPermission() : void { $this->assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode()); - $this->drupalSetUpCurrentUser(permissions: ['restful get helfi_debug_data']); + $this->drupalSetUpCurrentUser(permissions: ['restful get helfi_debug_package_version']); $request = $this->getMockedRequest('/admin/debug'); $response = $this->processRequest($request);