From 1ebee78ba45951e73891f7e3177184f839810bfc Mon Sep 17 00:00:00 2001 From: Thomas Manson Date: Thu, 12 Sep 2024 16:35:39 +1000 Subject: [PATCH 1/2] Add the operator type to the attestation request --- .../shared/attest/AttestationResponseHandler.java | 11 ++++++++--- .../shared/attest/AttestationResponseHandlerTest.java | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/uid2/shared/attest/AttestationResponseHandler.java b/src/main/java/com/uid2/shared/attest/AttestationResponseHandler.java index d657b136..ff230cd4 100644 --- a/src/main/java/com/uid2/shared/attest/AttestationResponseHandler.java +++ b/src/main/java/com/uid2/shared/attest/AttestationResponseHandler.java @@ -29,6 +29,7 @@ public class AttestationResponseHandler { private final IAttestationProvider attestationProvider; private final String clientApiToken; + private final String operatorType; private final ApplicationVersion appVersion; private final AtomicReference attestationToken; private final AtomicReference optOutJwt; @@ -52,15 +53,17 @@ public class AttestationResponseHandler { public AttestationResponseHandler(Vertx vertx, String attestationEndpoint, String clientApiToken, + String operatorType, ApplicationVersion appVersion, IAttestationProvider attestationProvider, Handler> responseWatcher, Proxy proxy) { - this(vertx, attestationEndpoint, clientApiToken, appVersion, attestationProvider, responseWatcher, proxy, new InstantClock(), null, null, 60000); + this(vertx, attestationEndpoint, clientApiToken, operatorType, appVersion, attestationProvider, responseWatcher, proxy, new InstantClock(), null, null, 60000); } public AttestationResponseHandler(Vertx vertx, String attestationEndpoint, String clientApiToken, + String operatorType, ApplicationVersion appVersion, IAttestationProvider attestationProvider, Handler> responseWatcher, @@ -73,6 +76,7 @@ public AttestationResponseHandler(Vertx vertx, this.attestationEndpoint = attestationEndpoint; this.encodedAttestationEndpoint = this.encodeStringUnicodeAttestationEndpoint(attestationEndpoint); this.clientApiToken = clientApiToken; + this.operatorType = operatorType; this.appVersion = appVersion; this.attestationProvider = attestationProvider; this.attestationToken = new AtomicReference<>(null); @@ -158,7 +162,8 @@ public void attest() throws IOException, AttestationResponseHandlerException { "attestation_request", Base64.getEncoder().encodeToString(attestationProvider.getAttestationRequest(publicKey, this.encodedAttestationEndpoint)), "public_key", Base64.getEncoder().encodeToString(publicKey), "application_name", appVersion.getAppName(), - "application_version", appVersion.getAppVersion() + "application_version", appVersion.getAppVersion(), + "operator_type", this.operatorType ); JsonObject components = new JsonObject(); for (Map.Entry kv : appVersion.getComponentVersions().entrySet()) { @@ -178,7 +183,7 @@ public void attest() throws IOException, AttestationResponseHandlerException { notifyResponseWatcher(statusCode, responseBody); if (statusCode < 200 || statusCode >= 300) { - LOGGER.warn("attestation failed with UID2 Core returning statusCode=" + statusCode); + LOGGER.warn("attestation failed with UID2 Core returning statusCode={}", statusCode); throw new AttestationResponseHandlerException(statusCode, "unexpected status code from uid core service"); } diff --git a/src/test/java/com/uid2/shared/attest/AttestationResponseHandlerTest.java b/src/test/java/com/uid2/shared/attest/AttestationResponseHandlerTest.java index 1969c27f..e9ab4be4 100644 --- a/src/test/java/com/uid2/shared/attest/AttestationResponseHandlerTest.java +++ b/src/test/java/com/uid2/shared/attest/AttestationResponseHandlerTest.java @@ -36,6 +36,7 @@ @ExtendWith(VertxExtension.class) public class AttestationResponseHandlerTest { private static final String ATTESTATION_ENDPOINT = "https://core-test.uidapi.com/attest"; + private static final String OPERATOR_TYPE = "public"; private byte[] ENCODED_ATTESTATION_ENDPOINT; private static final ApplicationVersion APP_VERSION = new ApplicationVersion("appName", "appVersion", new HashMap() {{ @@ -303,7 +304,7 @@ public void attest_succeed_jwtsNull(Vertx vertx, VertxTestContext testContext) t } @Test - public void attest_succeed_jsonRequest_includes_attestUrl_in_attestation_request(Vertx vertx, VertxTestContext testContext) throws Exception{ + public void attest_succeed_jsonRequest_includes_expected_properties(Vertx vertx, VertxTestContext testContext) throws Exception{ attestationResponseHandler = getAttestationTokenRetriever(vertx); when(attestationProvider.isReady()).thenReturn(true); @@ -331,12 +332,15 @@ public void attest_succeed_jsonRequest_includes_attestUrl_in_attestation_request String decodedUrl = new String(data, StandardCharsets.UTF_8); Assertions.assertEquals(ATTESTATION_ENDPOINT, decodedUrl); + Assertions.assertNotNull(jsonBody.getString("operator_type")); + Assertions.assertEquals(OPERATOR_TYPE, jsonBody.getString("operator_type")); + verify(attestationProvider, times(1)).getAttestationRequest(any(), eq(ENCODED_ATTESTATION_ENDPOINT)); testContext.completeNow(); } private AttestationResponseHandler getAttestationTokenRetriever(Vertx vertx) { - return new AttestationResponseHandler(vertx, ATTESTATION_ENDPOINT, "testApiKey", APP_VERSION, attestationProvider, responseWatcher, proxy, clock, mockHttpClient, mockAttestationTokenDecryptor, 250); + return new AttestationResponseHandler(vertx, ATTESTATION_ENDPOINT, "testApiKey", OPERATOR_TYPE, APP_VERSION, attestationProvider, responseWatcher, proxy, clock, mockHttpClient, mockAttestationTokenDecryptor, 250); } } \ No newline at end of file From f288c8acd1171a15b47d5e343efc84cf097f8abc Mon Sep 17 00:00:00 2001 From: Release Workflow Date: Thu, 12 Sep 2024 06:44:17 +0000 Subject: [PATCH 2/2] [CI Pipeline] Released Snapshot version: 7.18.1-alpha-149-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 897b4e67..2eca9660 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.uid2 uid2-shared - 7.18.0 + 7.18.1-alpha-149-SNAPSHOT ${project.groupId}:${project.artifactId} Library for all the shared uid2 operations https://github.com/IABTechLab/uid2docs