diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index daab41ff..5f0bfe73 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -69,10 +69,10 @@ spring: port: 1025 crypto: -# development-mode: True + development-mode: True # private-key-location: classpath:nope # Use the commented lines when you want to test against a remote manage. Do not add the private_key to git - development-mode: False +# development-mode: False private-key-location: classpath:/private_key_pkcs8.pem cron: @@ -192,8 +192,8 @@ email: # configure real users / passwords and test against those. See server/src/main/java/access/manage/ManageConf.java # and server/src/main/java/access/manage/LocalManage.java to see how it works. manage: - enabled: True -# enabled: False +# enabled: True + enabled: False url: "https://manage.test2.surfconext.nl" user: invite password: secret diff --git a/server/src/test/java/access/AbstractTest.java b/server/src/test/java/access/AbstractTest.java index 3b27ffcf..031e9475 100644 --- a/server/src/test/java/access/AbstractTest.java +++ b/server/src/test/java/access/AbstractTest.java @@ -60,6 +60,7 @@ import java.util.function.Consumer; import java.util.function.UnaryOperator; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static io.restassured.RestAssured.given; @@ -346,7 +347,7 @@ protected JWTClaimsSet getJwtClaimsSet(String clientId, String sub, String redir protected void stubForManageProvisioning(List identifiers) throws JsonProcessingException { List> providers = localManage.provisioning(identifiers); - String body = objectMapper.writeValueAsString(providers); + String body = writeValueAsString(providers); stubFor(post(urlPathMatching("/manage/api/internal/provisioning")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody(body) @@ -400,12 +401,31 @@ protected void stubForManageProviderByIdNotFound(EntityType entityType, String i protected void stubForManagerProvidersByIdIn(EntityType entityType, List identifiers) { String path = String.format("/manage/api/internal/rawSearch/%s", entityType.name().toLowerCase()); List> providers = localManage.providersByIdIn(entityType, identifiers); - String body = objectMapper.writeValueAsString(providers); + String body = writeValueAsString(providers); stubFor(post(urlPathMatching(path)).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody(body))); } + @SneakyThrows + protected void stubForManageAllProviders(EntityType... entityTypes) { + Stream.of(entityTypes).forEach(entityType -> { + String path = String.format("/manage/api/internal/search/%s", entityType.name().toLowerCase()); + List> providers = localManage.providers(entityType); + String s = writeValueAsString(providers); + String body = s; + stubFor(post(urlPathMatching(path)).willReturn(aResponse() + .withHeader("Content-Type", "application/json") + .withBody(body))); + + }); + } + + @SneakyThrows + private String writeValueAsString(List> providers) { + return objectMapper.writeValueAsString(providers); + } + protected void stubForManageProviderByEntityID(EntityType entityType, String entityId) throws JsonProcessingException { String path = String.format("/manage/api/internal/rawSearch/%s", entityType.name().toLowerCase()); Optional> provider = localManage.providerByEntityID(entityType, entityId); diff --git a/server/src/test/java/access/api/SystemControllerTest.java b/server/src/test/java/access/api/SystemControllerTest.java index e295f974..b70e76a8 100644 --- a/server/src/test/java/access/api/SystemControllerTest.java +++ b/server/src/test/java/access/api/SystemControllerTest.java @@ -82,6 +82,9 @@ void unknownRoles() throws Exception { @Test void performanceSeed() throws Exception { AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", SUPER_SUB); + + super.stubForManageAllProviders(EntityType.SAML20_SP, EntityType.OIDC10_RP, EntityType.SAML20_IDP); + Map results = given() .when() .filter(accessCookieFilter.cookieFilter()) @@ -90,11 +93,11 @@ void performanceSeed() throws Exception { .queryParam("numberOfRole", 1) .queryParam("numberOfUsers", 1) .contentType(ContentType.JSON) - .get("/api/v1/system/performance-seed") + .put("/api/v1/system/performance-seed") .as(new TypeRef<>() { }); assertEquals(1, results.get("users")); - assertEquals(1, results.get("users")); - assertEquals(1, results.get("users")); + assertEquals(1, results.get("roles")); + assertEquals(1, results.get("userRoles")); } } \ No newline at end of file