From d1fb6c7b20fb0979c30ac2f476c08b486db6b416 Mon Sep 17 00:00:00 2001 From: Katherine Chen Date: Wed, 25 Oct 2023 16:53:39 +1100 Subject: [PATCH] Fix `ClientKeyServiceTest` --- .../uid2/admin/vertx/ClientKeyServiceTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/uid2/admin/vertx/ClientKeyServiceTest.java b/src/test/java/com/uid2/admin/vertx/ClientKeyServiceTest.java index 3a4e6c83..2ca59454 100644 --- a/src/test/java/com/uid2/admin/vertx/ClientKeyServiceTest.java +++ b/src/test/java/com/uid2/admin/vertx/ClientKeyServiceTest.java @@ -79,7 +79,7 @@ public void clientAdd(Vertx vertx, VertxTestContext testContext) { fakeAuth(Role.CLIENTKEY_ISSUER); LegacyClientKey expectedClient = new LegacyClientBuilder().withServiceId(145).build(); - post(vertx, testContext, "api/client/add?name=test_client&roles=generator&site_id=5&service_id=145", "", response -> { + post(vertx, testContext, "api/client/add?name=test_client&roles=generator&site_id=999&service_id=145", "", response -> { RevealedKey revealedClient = OBJECT_MAPPER.readValue(response.bodyAsString(), new TypeReference<>() {}); assertAll( @@ -98,7 +98,7 @@ public void clientAdd(Vertx vertx, VertxTestContext testContext) { public void clientAddCreatesSiteKeyIfNoneExists(Set roles, boolean siteKeyShouldBeCreatedIfNoneExists, Vertx vertx, VertxTestContext testContext) { fakeAuth(Role.CLIENTKEY_ISSUER); - String endpoint = String.format("api/client/add?name=test_client&site_id=5&roles=%s", RequestUtil.getRolesSpec(roles)); + String endpoint = String.format("api/client/add?name=test_client&site_id=999&roles=%s", RequestUtil.getRolesSpec(roles)); post(vertx, testContext, endpoint, "", response -> { assertAll( "clientAddCreatesSiteKeyIfNoneExists", @@ -147,7 +147,7 @@ public void clientUpdate(Vertx vertx, VertxTestContext testContext) { fakeAuth(Role.CLIENTKEY_ISSUER); setClientKeys(new LegacyClientBuilder().withServiceId(165).build()); - post(vertx, testContext, "api/client/update?name=test_client&site_id=5&service_id=200", "", response -> { + post(vertx, testContext, "api/client/update?name=test_client&site_id=999&service_id=200", "", response -> { ClientKey expected = new LegacyClientBuilder().withServiceId(200).build().toClientKey(); assertAll( "clientUpdate", @@ -171,7 +171,7 @@ public void clientUpdateCreatesSiteKeyIfNoneExists(Set roles, boolean site .build() ); - post(vertx, testContext, "api/client/update?name=test_client&site_id=5&service_id=145", "", response -> { + post(vertx, testContext, "api/client/update?name=test_client&site_id=999&service_id=145", "", response -> { assertAll( "clientUpdateCreatesSiteKeyIfNoneExists", () -> assertEquals(200, response.statusCode()), @@ -189,7 +189,7 @@ public void clientUpdateCreatesSiteKeyIfNoneExists(Set roles, boolean site @Test public void clientUpdateUnknownClientName(Vertx vertx, VertxTestContext testContext) { fakeAuth(Role.CLIENTKEY_ISSUER); - post(vertx, testContext, "api/client/update?name=test_client&site_id=5", "", expectHttpStatus(testContext, 404)); + post(vertx, testContext, "api/client/update?name=test_client&site_id=999", "", expectHttpStatus(testContext, 404)); } @Test @@ -247,6 +247,7 @@ private static class LegacyClientBuilder { private int siteId = 999; private Set roles = Set.of(Role.GENERATOR); private int serviceId = 0; + private String keyId = "UID2-C-L-999-abcde"; public LegacyClientBuilder withName(String name) { this.name = name; @@ -268,6 +269,11 @@ public LegacyClientBuilder withServiceId(int serviceId) { return this; } + public LegacyClientBuilder withKeyId(String keyId) { + this.keyId = keyId; + return this; + } + public LegacyClientKey build() { return new LegacyClientKey( "UID2-C-L-999-abcdeM.fsR3mDqAXELtWWMS+xG1s7RdgRTMqdOH2qaAo=", @@ -281,7 +287,7 @@ public LegacyClientKey build() { siteId, false, serviceId, - "UID2-C-L-999-abcde" + keyId ); } }