diff --git a/CHANGELOG.md b/CHANGELOG.md index 517b3c6d6..bbdbc8f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.3.2 + +**Feature** +* Add 'show oidc create options' feature toggle #314 + +**Bugfix** +* Ensure all OIDCng entities are shown in the entity listings #316 + ## 2.3.1 **Bugfix** diff --git a/ansible/roles/spdashboard/defaults/main.yml b/ansible/roles/spdashboard/defaults/main.yml index f1374b173..c768da4bb 100644 --- a/ansible/roles/spdashboard/defaults/main.yml +++ b/ansible/roles/spdashboard/defaults/main.yml @@ -37,3 +37,4 @@ spdashboard_playground_uri_test: https://authz-playground.dev.support.surfconext spdashboard_playground_uri_prod: https://authz-playground.dev.support.surfconext.nl/redirect spdashboard_oidcng_playground_uri_test: https://oidc-playground.dev.support.surfconext.nl/redirect spdashboard_oidcng_playground_uri_prod: https://oidc-playground.dev.support.surfconext.nl/redirect +spdashboard_oidc_create_enabled: true diff --git a/ansible/roles/spdashboard/templates/parameters.yml.j2 b/ansible/roles/spdashboard/templates/parameters.yml.j2 index 68ec573a3..217eb3444 100644 --- a/ansible/roles/spdashboard/templates/parameters.yml.j2 +++ b/ansible/roles/spdashboard/templates/parameters.yml.j2 @@ -57,3 +57,4 @@ parameters: playground_uri_prod: {{ spdashboard_playground_uri_prod }} oidcng_playground_uri_test: {{ spdashboard_oidcng_playground_uri_test }} oidcng_playground_uri_prod: {{ spdashboard_oidcng_playground_uri_prod }} + oidc_create_enabled: {{ spdashboard_oidc_create_enabled }} diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index e0c2e0334..e41d4308c 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -88,4 +88,7 @@ parameters: playground_uri_prod: https://prod.dev.playground.surfconext.nl # Playground uri's for OIDC TNG entities oidcng_playground_uri_test: 'https://test.dev.playground.surfconext.nl' - oidcng_playground_uri_prod: 'https://prod.dev.playground.surfconext.nl' \ No newline at end of file + oidcng_playground_uri_prod: 'https://prod.dev.playground.surfconext.nl' + + # Globally enable/disable OIDC entitiy creation support + oidc_create_enabled: true \ No newline at end of file diff --git a/src/Surfnet/ServiceProviderDashboard/Domain/Service/OidcCreateEntityEnabledMarshaller.php b/src/Surfnet/ServiceProviderDashboard/Domain/Service/OidcCreateEntityEnabledMarshaller.php new file mode 100644 index 000000000..b259aefad --- /dev/null +++ b/src/Surfnet/ServiceProviderDashboard/Domain/Service/OidcCreateEntityEnabledMarshaller.php @@ -0,0 +1,40 @@ +isAllowed = $isAllowed; + } + + /** + * @return bool + */ + public function allowed() + { + return $this->isAllowed; + } +} diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Controller/EntityCreateController.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Controller/EntityCreateController.php index e8f210fd7..1096a07cd 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Controller/EntityCreateController.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Controller/EntityCreateController.php @@ -145,6 +145,11 @@ public function createAction(Request $request, $serviceId, $targetEnvironment, $ $service = $this->authorizationService->changeActiveService($serviceId); + if ($type === Entity::TYPE_OPENID_CONNECT && !$this->authorizationService->isOidcCreateEntityAllowed()) { + throw $this->createAccessDeniedException( + 'You are not allowed to create oidc entities' + ); + } if ($type === Entity::TYPE_OPENID_CONNECT_TNG && !$this->authorizationService->isOidcngAllowed($service, $targetEnvironment) diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactory.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactory.php index 3f026321e..d7e435ebf 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactory.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactory.php @@ -21,6 +21,7 @@ use Surfnet\ServiceProviderDashboard\Application\ViewObject\Manage\Config; use Surfnet\ServiceProviderDashboard\Domain\Entity\Entity; use Surfnet\ServiceProviderDashboard\Domain\Entity\Service; +use Surfnet\ServiceProviderDashboard\Domain\Service\OidcCreateEntityEnabledMarshaller; use Surfnet\ServiceProviderDashboard\Domain\Service\OidcngEnabledMarshaller; class ProtocolChoiceFactory @@ -30,6 +31,11 @@ class ProtocolChoiceFactory */ private $oidcngEnabledMarshaller; + /** + * @var OidcCreateEntityEnabledMarshaller + */ + private $oidcCreateMarshaller; + /** * @var Config[] $manageConfig */ @@ -47,14 +53,18 @@ class ProtocolChoiceFactory Entity::TYPE_OPENID_CONNECT_TNG_RESOURCE_SERVER => 'entity.type.oidcng.resource_server.title', ]; - public function __construct(Config $manageConfigTest, Config $manageConfigProd) - { + public function __construct( + Config $manageConfigTest, + Config $manageConfigProd, + OidcCreateEntityEnabledMarshaller $oidcCreateMarshaller + ) { $this->manageConfig = [ Entity::ENVIRONMENT_TEST => $manageConfigTest, Entity::ENVIRONMENT_PRODUCTION => $manageConfigProd, ]; $this->oidcngEnabledMarshaller = new OidcngEnabledMarshaller(); + $this->oidcCreateMarshaller = $oidcCreateMarshaller; } public function setService(Service $service) @@ -75,6 +85,11 @@ public function buildOptions($targetEnvironment) unset($options[Entity::TYPE_OPENID_CONNECT_TNG]); unset($options[Entity::TYPE_OPENID_CONNECT_TNG_RESOURCE_SERVER]); } + + if (!$this->oidcCreateMarshaller->allowed()) { + unset($options[Entity::TYPE_OPENID_CONNECT]); + } + return array_flip($options); } } diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml index 8cabad4f4..70e140527 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml @@ -469,3 +469,6 @@ services: - '@surfnet.manage.client.query_client.prod_environment' - '%manage_test_publication_status%' - '%manage_prod_publication_status%' + + Surfnet\ServiceProviderDashboard\Domain\Service\OidcCreateEntityEnabledMarshaller: + arguments: ['%oidc_create_enabled%'] \ No newline at end of file diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Service/AuthorizationService.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Service/AuthorizationService.php index 9813bb623..0b45b18b4 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Service/AuthorizationService.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Service/AuthorizationService.php @@ -22,6 +22,7 @@ use Surfnet\ServiceProviderDashboard\Application\Service\ServiceService; use Surfnet\ServiceProviderDashboard\Application\ViewObject\Manage\Config; use Surfnet\ServiceProviderDashboard\Domain\Entity\Service; +use Surfnet\ServiceProviderDashboard\Domain\Service\OidcCreateEntityEnabledMarshaller; use Surfnet\ServiceProviderDashboard\Domain\Service\OidcngEnabledMarshaller; use Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Exception\ManageConfigNotFoundException; use Surfnet\ServiceProviderDashboard\Infrastructure\DashboardSamlBundle\Security\Identity; @@ -50,6 +51,10 @@ class AuthorizationService */ private $oidcngMarshaller; + /** + * @var OidcCreateEntityEnabledMarshaller + */ + private $oidcCreateEntityEnabledMarshaller; /** * @var Config[] */ @@ -60,7 +65,8 @@ public function __construct( Session $session, TokenStorageInterface $tokenStorage, Config $manageTestConfig, - Config $manageProdConfig + Config $manageProdConfig, + OidcCreateEntityEnabledMarshaller $oidcCreateEntityEnabledMarshaller ) { $this->serviceService = $serviceService; $this->session = $session; @@ -71,6 +77,7 @@ public function __construct( 'production' => $manageProdConfig, ]; $this->oidcngMarshaller = new OidcngEnabledMarshaller(); + $this->oidcCreateEntityEnabledMarshaller = $oidcCreateEntityEnabledMarshaller; } /** @@ -312,4 +319,12 @@ public function isOidcngAllowed(Service $service, $environment) $this->manageConfig[$environment]->getOidcngEnabled()->isEnabled() ); } + + /** + * @return bool + */ + public function isOidcCreateEntityAllowed() + { + return $this->oidcCreateEntityEnabledMarshaller->allowed(); + } } diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/QueryClient.php b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/QueryClient.php index 6a9ccc74c..9a27d364c 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/QueryClient.php +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Client/QueryClient.php @@ -235,7 +235,7 @@ private function doSearchQuery(array $params) json_encode($params), sprintf('/manage/api/internal/search/%s', $protocol) ); - $results += $response; + $results = array_merge($response, $results); } return $results; } diff --git a/tests/unit/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactoryTest.php b/tests/unit/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactoryTest.php new file mode 100644 index 000000000..c9fc0d8a1 --- /dev/null +++ b/tests/unit/Infrastructure/DashboardBundle/Form/Entity/ProtocolChoiceFactoryTest.php @@ -0,0 +1,172 @@ +manageTestConfig + ->shouldReceive('getOidcngEnabled->isEnabled') + ->once() + ->andReturn($testOidcngEnabled); + + $this->service + ->shouldReceive('isOidcngEnabled') + ->andReturn($oidcngEnabledForService); + + $this->oidcCreateEnabledMarshaller + ->shouldReceive('allowed') + ->andReturn($oidcEnabled); + + $testOptions = $this->protocolChoiceFactory->buildOptions(Entity::ENVIRONMENT_TEST); + $this->assertEquals($expectation, array_values($testOptions), $testDescription); + } + + /** + * @param string $testDescription + * @param array $expectation + * @param bool $productionOidcngEnabled + * @param bool $oidcngEnabledForService + * @param bool $oidcEnabled + * + * @dataProvider provideTestVariations Note that the test generator is used, as for now behaviour is similar + * between prod and test + */ + public function test_variations_production( + $testDescription, + $expectation, + $productionOidcngEnabled, + $oidcngEnabledForService, + $oidcEnabled + ) { + $this->manageProdConfig + ->shouldReceive('getOidcngEnabled->isEnabled') + ->once() + ->andReturn($productionOidcngEnabled); + + $this->service + ->shouldReceive('isOidcngEnabled') + ->andReturn($oidcngEnabledForService); + + $this->oidcCreateEnabledMarshaller + ->shouldReceive('allowed') + ->andReturn($oidcEnabled); + + $testOptions = $this->protocolChoiceFactory->buildOptions(Entity::ENVIRONMENT_PRODUCTION); + $this->assertEquals($expectation, array_values($testOptions), $testDescription); + } + + public function provideTestVariations() + { + return [ + [ + 'All systems go, all options are set to true, so all options are displayed', + [ + 'saml20', + 'oidc', + 'oidcng', + 'oidcng_rs', + ], + true, + true, + true, + ], + [ + 'OIDC is disabled, all other options should be present', + [ + 'saml20', + 'oidcng', + 'oidcng_rs', + ], + true, + true, + false, + ], + [ + 'OIDC & OIDCng is disabled, Only SAML should be visible', + [ + 'saml20', + ], + false, + true, + false, + ], + [ + 'OIDCng is disabled for the service, Only SAML and OIDC should be visible', + [ + 'saml20', + 'oidc', + ], + true, + false, + true, + ], + ]; + } + + protected function setUp() + { + $this->oidcCreateEnabledMarshaller = m::mock(OidcCreateEntityEnabledMarshaller::class); + $this->manageTestConfig = m::mock(Config::class); + $this->manageProdConfig = m::mock(Config::class); + + + $this->protocolChoiceFactory = new ProtocolChoiceFactory( + $this->manageTestConfig, + $this->manageProdConfig, + $this->oidcCreateEnabledMarshaller + ); + $this->service = m::mock(Service::class); + $this->protocolChoiceFactory->setService($this->service); + } +} diff --git a/tests/unit/Infrastructure/DashboardBundle/Service/AuthorizationServiceTest.php b/tests/unit/Infrastructure/DashboardBundle/Service/AuthorizationServiceTest.php index 0dcde3846..3c4433e0c 100644 --- a/tests/unit/Infrastructure/DashboardBundle/Service/AuthorizationServiceTest.php +++ b/tests/unit/Infrastructure/DashboardBundle/Service/AuthorizationServiceTest.php @@ -24,6 +24,7 @@ use Surfnet\ServiceProviderDashboard\Application\Service\ServiceService; use Surfnet\ServiceProviderDashboard\Application\ViewObject\Manage\Config; use Surfnet\ServiceProviderDashboard\Domain\Entity\Service; +use Surfnet\ServiceProviderDashboard\Domain\Service\OidcCreateEntityEnabledMarshaller; use Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Exception\ManageConfigNotFoundException; use Surfnet\ServiceProviderDashboard\Infrastructure\DashboardBundle\Service\AuthorizationService; use Surfnet\ServiceProviderDashboard\Infrastructure\DashboardSamlBundle\Security\Authentication\Token\SamlToken; @@ -51,6 +52,10 @@ class AuthorizationServiceTest extends MockeryTestCase * @var MockInterface&Config */ private $manageConfigProd; + /** + * @var MockInterface&OidcCreateEntityEnabledMarshaller + */ + private $marshaller; public function setUp() { @@ -60,12 +65,15 @@ public function setUp() $this->manageConfigTest = m::mock(Config::class); $this->manageConfigProd = m::mock(Config::class); + $this->marshaller = m::mock(OidcCreateEntityEnabledMarshaller::class); + $this->service = new AuthorizationService( $this->serviceService, $this->session, $this->tokenStorage, $this->manageConfigTest, - $this->manageConfigProd + $this->manageConfigProd, + $this->marshaller ); } @@ -182,4 +190,20 @@ public function test_oidcng_access_invalid_env() $this->expectExceptionMessage('The manage configuration for environment "mumbojumbo" can not be found.'); $this->service->isOidcngAllowed(m::mock(Service::class), 'mumbojumbo'); } + + public function test_oidc_create_entity_allowed() + { + $this->marshaller + ->shouldReceive('allowed') + ->once() + ->andReturn(false); + $this->assertFalse($this->service->isOidcCreateEntityAllowed()); + + $this->marshaller + ->shouldReceive('allowed') + ->once() + ->andReturn(true); + + $this->assertTrue($this->service->isOidcCreateEntityAllowed()); + } } diff --git a/tests/unit/Infrastructure/Manage/Client/QueryClientTest.php b/tests/unit/Infrastructure/Manage/Client/QueryClientTest.php index 7623095c2..1419b6c33 100644 --- a/tests/unit/Infrastructure/Manage/Client/QueryClientTest.php +++ b/tests/unit/Infrastructure/Manage/Client/QueryClientTest.php @@ -83,6 +83,71 @@ public function test_it_can_query_existing_data() ); } + + /** + * Test, when multiple entities are retrieved from manage search from both the SAML and the OIDC endpoints, no + * overwriting is applied to the merged search results. + * + * @see https://www.pivotaltracker.com/story/show/168834919 + */ + public function test_search_does_not_override_keys() + { + $this->mockHandler + ->append( + # The saml search endpoint is queried + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/search_saml.json') + ), + # The oidc search endpoint is queried + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/search_oidc.json') + ), + # Next the oidc entities are retrieved from manage by id, first trying the SAML endpoint, then OIDC + new Response(404, [], '[]'), + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/read_response_oidc1.json') + ), + new Response(404, [], '[]'), + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/read_response_oidc2.json') + ), + new Response(404, [], '[]'), + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/read_response_oidc3.json') + ), + # Finally the SAML entities are loaded + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/read_response_saml1.json') + ), + new Response( + 200, + [], + file_get_contents(__DIR__.'/fixture/search_result_overwrite_bug/read_response_saml2.json') + ) + ); + $response = $this->client->findByTeamName('team-UU', 'prodaccepted'); + + $this->assertEquals('oidcng', $response[0]->getProtocol()->getProtocol()); + $this->assertEquals('oidcng', $response[1]->getProtocol()->getProtocol()); + $this->assertEquals('oidcng', $response[2]->getProtocol()->getProtocol()); + $this->assertEquals('saml20', $response[3]->getProtocol()->getProtocol()); + $this->assertEquals('saml20', $response[4]->getProtocol()->getProtocol()); + + $this->assertCount(5, $response); + } + public function test_it_can_query_non_existent_data() { // When the queried entityId does not exist, an empty array is returned diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc1.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc1.json new file mode 100644 index 000000000..cd91af63c --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc1.json @@ -0,0 +1,79 @@ +{ + "id": "710c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "type": "oidc10_rp", + "revision": { + "number": 1, + "created": 1570441986.983, + "parentId": null, + "updatedBy": "urn:collab:person:example.com:admin", + "terminated": null + }, + "data": { + "entityid": "test.oidcng.example.com", + "state": "prodaccepted", + "allowedall": true, + "arp": { + "enabled": true, + "attributes": { + "urn:mace:dir:attribute-def:displayName": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ], + "urn:mace:dir:attribute-def:uid": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ] + } + }, + "metaDataFields": { + "name:en": "MijnUu app | Uu", + "secret": "$2a$10$DX5wtBQtWT3SkhJVzEeb1uBGOJyBjVNcsOFkoJtABKmd7tYxy9UQy", + "redirectUrls": [ + "http://localhost", + "https://oidc-playground.test.openconext.nl/redirect", + "http://localhost:8000/app/redirect.html" + ], + "scopes": [ + "openid" + ], + "grants": [ + "authorization_code", + "refresh_token" + ], + "NameIDFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", + "isResourceServer": false, + "contacts:2:givenName": "Test", + "contacts:1:surName": "Test", + "contacts:2:emailAddress": "test@uu.example.com", + "logo:0:width": 200, + "contacts:0:emailAddress": "test@uu.example.com", + "contacts:0:contactType": "technical", + "contacts:2:contactType": "administrative", + "contacts:1:contactType": "support", + "contacts:1:givenName": "Test", + "name:nl": "MijnUu app | Uu", + "description:en": "MijnUu app", + "coin:service_team_id": "team-UU", + "contacts:2:surName": "Test", + "description:nl": "MijnUu app", + "logo:0:url": "https://static.openconext.nl/media/sp/Uu.png", + "contacts:0:givenName": "Test", + "contacts:0:surName": "Test", + "contacts:1:emailAddress": "test@uu.example.com", + "logo:0:height": 160, + "isPublicClient": true + }, + "allowedEntities": [], + "allowedResourceServers": [], + "type": "oidc10-rp", + "revisionnote": "Some revision note", + "eid": 57 + } +} \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc2.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc2.json new file mode 100644 index 000000000..f645c2db6 --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc2.json @@ -0,0 +1,79 @@ +{ + "id": "810c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "type": "oidc10_rp", + "revision": { + "number": 1, + "created": 1570441986.983, + "parentId": null, + "updatedBy": "urn:collab:person:example.com:admin", + "terminated": null + }, + "data": { + "entityid": "test2.oidcng.example.com", + "state": "prodaccepted", + "allowedall": true, + "arp": { + "enabled": true, + "attributes": { + "urn:mace:dir:attribute-def:displayName": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ], + "urn:mace:dir:attribute-def:uid": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ] + } + }, + "metaDataFields": { + "name:en": "MijnUu app | Uu", + "secret": "$2a$10$DX5wtBQtWT3SkhJVzEeb1uBGOJyBjVNcsOFkoJtABKmd7tYxy9UQy", + "redirectUrls": [ + "http://localhost", + "https://oidc-playground.test.openconext.nl/redirect", + "http://localhost:8000/app/redirect.html" + ], + "scopes": [ + "openid" + ], + "grants": [ + "authorization_code", + "refresh_token" + ], + "NameIDFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", + "isResourceServer": false, + "contacts:2:givenName": "Test", + "contacts:1:surName": "Test", + "contacts:2:emailAddress": "test@uu.example.com", + "logo:0:width": 200, + "contacts:0:emailAddress": "test@uu.example.com", + "contacts:0:contactType": "technical", + "contacts:2:contactType": "administrative", + "contacts:1:contactType": "support", + "contacts:1:givenName": "Test", + "name:nl": "MijnUu app | Uu", + "description:en": "MijnUu app", + "coin:service_team_id": "team-UU", + "contacts:2:surName": "Test", + "description:nl": "MijnUu app", + "logo:0:url": "https://static.openconext.nl/media/sp/Uu.png", + "contacts:0:givenName": "Test", + "contacts:0:surName": "Test", + "contacts:1:emailAddress": "test@uu.example.com", + "logo:0:height": 160, + "isPublicClient": true + }, + "allowedEntities": [], + "allowedResourceServers": [], + "type": "oidc10-rp", + "revisionnote": "Some revision note", + "eid": 57 + } +} \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc3.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc3.json new file mode 100644 index 000000000..396c8c17a --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_oidc3.json @@ -0,0 +1,79 @@ +{ + "id": "910c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "type": "oidc10_rp", + "revision": { + "number": 1, + "created": 1570441986.983, + "parentId": null, + "updatedBy": "urn:collab:person:example.com:admin", + "terminated": null + }, + "data": { + "entityid": "test3.oidcng.example.com", + "state": "prodaccepted", + "allowedall": true, + "arp": { + "enabled": true, + "attributes": { + "urn:mace:dir:attribute-def:displayName": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ], + "urn:mace:dir:attribute-def:uid": [ + { + "value": "*", + "source": "idp", + "motivation": "" + } + ] + } + }, + "metaDataFields": { + "name:en": "MijnUu app | Uu", + "secret": "$2a$10$DX5wtBQtWT3SkhJVzEeb1uBGOJyBjVNcsOFkoJtABKmd7tYxy9UQy", + "redirectUrls": [ + "http://localhost", + "https://oidc-playground.test.openconext.nl/redirect", + "http://localhost:8000/app/redirect.html" + ], + "scopes": [ + "openid" + ], + "grants": [ + "authorization_code", + "refresh_token" + ], + "NameIDFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", + "isResourceServer": false, + "contacts:2:givenName": "Test", + "contacts:1:surName": "Test", + "contacts:2:emailAddress": "test@uu.example.com", + "logo:0:width": 200, + "contacts:0:emailAddress": "test@uu.example.com", + "contacts:0:contactType": "technical", + "contacts:2:contactType": "administrative", + "contacts:1:contactType": "support", + "contacts:1:givenName": "Test", + "name:nl": "MijnUu app | Uu", + "description:en": "MijnUu app", + "coin:service_team_id": "team-UU", + "contacts:2:surName": "Test", + "description:nl": "MijnUu app", + "logo:0:url": "https://static.openconext.nl/media/sp/Uu.png", + "contacts:0:givenName": "Test", + "contacts:0:surName": "Test", + "contacts:1:emailAddress": "test@uu.example.com", + "logo:0:height": 160, + "isPublicClient": true + }, + "allowedEntities": [], + "allowedResourceServers": [], + "type": "oidc10-rp", + "revisionnote": "Some revision note", + "eid": 57 + } +} \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml1.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml1.json new file mode 100644 index 000000000..e5501d5cd --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml1.json @@ -0,0 +1 @@ +{"id":"1c7b3d8b-7897-4cc1-8521-df4f65b615c5","type": "saml20_sp","version":0,"data":{"entityid":"https:\/\/engine.dev.support.surfconext.nl\/authentication\/sp\/metadata","state":"prodaccepted","metaDataFields":{"name:nl":"OpenConext Engine","name:en":"OpenConext Engine"}}} \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml2.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml2.json new file mode 100644 index 000000000..e99c249f6 --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/read_response_saml2.json @@ -0,0 +1 @@ +{"id":"2c7b3d8b-7897-4cc1-8521-df4f65b615c5","type": "saml20_sp","version":0,"data":{"entityid":"https:\/\/engine.dev.support.surfconext.nl\/authentication\/sp\/metadata","state":"prodaccepted","metaDataFields":{"name:nl":"OpenConext Engine","name:en":"OpenConext Engine"}}} \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_oidc.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_oidc.json new file mode 100644 index 000000000..94f5a8f37 --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_oidc.json @@ -0,0 +1,38 @@ +[ + { + "_id": "710c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "data": { + "entityid": "test.oidcng.example.com", + "state": "prodaccepted", + "metaDataFields": { + "name:en": "Test 1 | UU", + "name:nl": "Test 1 | UU" + } + } + }, + { + "_id": "810c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "data": { + "entityid": "test2.oidcng.example.com", + "state": "prodaccepted", + "metaDataFields": { + "name:en": "Test 2 | UU", + "name:nl": "Test 2 | UU" + } + } + }, + { + "_id": "910c61af-411d-4bfb-af16-251d9f7b8027", + "version": 1, + "data": { + "entityid": "test3.oidcng.example.com", + "state": "prodaccepted", + "metaDataFields": { + "name:en": "Test 3 | UU", + "name:nl": "Test 3 | UU" + } + } + } +] \ No newline at end of file diff --git a/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_saml.json b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_saml.json new file mode 100644 index 000000000..692c94658 --- /dev/null +++ b/tests/unit/Infrastructure/Manage/Client/fixture/search_result_overwrite_bug/search_saml.json @@ -0,0 +1,26 @@ +[ + { + "_id": "1c7b3d8b-7897-4cc1-8521-df4f65b615c5", + "version": 0, + "data": { + "entityid": "https://test1.saml.example.com", + "state": "prodaccepted", + "metaDataFields": { + "name:en": "Test SP 1 | UU", + "name:nl": "Test SP 1 | UU" + } + } + }, + { + "_id": "2c7b3d8b-7897-4cc1-8521-df4f65b615c5", + "version": 0, + "data": { + "entityid": "https://test2.saml.example.com", + "state": "prodaccepted", + "metaDataFields": { + "name:en": "Test SP 2 | UU", + "name:nl": "Test SP 2 | UU" + } + } + } +] \ No newline at end of file diff --git a/tests/webtests/EntityListTest.php b/tests/webtests/EntityListTest.php index 017a84037..2199dc0c9 100644 --- a/tests/webtests/EntityListTest.php +++ b/tests/webtests/EntityListTest.php @@ -111,7 +111,7 @@ public function test_entity_list_shows_test_entities() $this->assertContains("Entities of service 'SURFnet'", $pageTitle->text()); $data = $this->rowsToArray($crawler->filter('table')); - $this->assertCount(4, $data, 'Expecting three rows (including header)'); + $this->assertCount(5, $data, 'Expecting four rows (2 drafts, 2 published and the header)'); unset($data[0][5]); // remove buttons $this->assertEquals([ @@ -140,9 +140,18 @@ public function test_entity_list_shows_test_entities() 'published', ], $data[2]); + unset($data[3][5]); // remove buttons $this->assertEquals([ - 'There are no entities configured', + 'SP3', + 'SP3', + 'Test Test (test@example.org)', + 'saml20', + 'published', ], $data[3]); + + $this->assertEquals([ + 'There are no entities configured', + ], $data[4]); } public function test_entity_list_shows_add_to_test_link()