Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Jun 11, 2024
1 parent 30f5f48 commit 6555e1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1812,13 +1812,13 @@ private RefreshResponse refreshIdentity(RoutingContext rc, String tokenStr) {
var v2Builder = Counter
.builder("uid2_refresh_token_v2_received_count")
.description("Counter for the amount of refresh token v2 received").tags(
"site_id", String.valueOf(AuthMiddleware.getAuthClient(rc).getSiteId()));
"site_id", String.valueOf(rc.data().get(Const.RoutingContextData.SiteId)));
v2Builder.register(Metrics.globalRegistry).increment();
} else if (tokenVersion == TokenVersion.V3) {
var v3Builder = Counter
.builder("uid2_refresh_token_v3_received_count")
.description("Counter for the amount of refresh token v3 received").tags(
"site_id", String.valueOf(AuthMiddleware.getAuthClient(rc).getSiteId()));
"site_id", String.valueOf(rc.data().get(Const.RoutingContextData.SiteId)));
v3Builder.register(Metrics.globalRegistry).increment();
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/uid2/operator/UIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,10 @@ void tokenRefreshExpiredTokenAuthenticated(String apiVersion, Vertx vertx, Vertx

sendTokenRefresh(apiVersion, vertx, testContext, refreshToken, bodyJson.getString("refresh_response_key"), 400, refreshRespJson -> {
assertEquals("expired_token", refreshRespJson.getString("status"));
assertEquals(1, Metrics.globalRegistry
.get("uid2_refresh_token_v3_received_count")
.tag("site_id", String.valueOf(clientSiteId))
.counter().count());
testContext.completeNow();
});
});
Expand All @@ -1763,6 +1767,10 @@ void tokenRefreshExpiredTokenUnauthenticated(String apiVersion, Vertx vertx, Ver

sendTokenRefresh(apiVersion, vertx, testContext, refreshToken, "", 400, refreshRespJson -> {
assertEquals("error", refreshRespJson.getString("status"));
assertEquals(1, Metrics.globalRegistry
.get("uid2_refresh_token_v3_received_count")
.tag("site_id", String.valueOf(clientSiteId))
.counter().count());
testContext.completeNow();
});
});
Expand Down Expand Up @@ -3904,6 +3912,7 @@ private Tuple.Tuple2<JsonObject, SecretKey> createClientSideTokenGenerateRequest
})
void cstgUserOptsOutAfterTokenGenerate(boolean setOptoutCheckFlagInRequest, String id, IdentityType identityType, Vertx vertx, VertxTestContext testContext) throws NoSuchAlgorithmException, InvalidKeyException {
setupCstgBackend("cstg.co.uk");
fakeAuth(111, Role.GENERATOR);

final Tuple.Tuple2<JsonObject, SecretKey> data = createClientSideTokenGenerateRequest(identityType, id, Instant.now().toEpochMilli(), setOptoutCheckFlagInRequest);

Expand Down

0 comments on commit 6555e1f

Please sign in to comment.