From e3c11b659857ae61ef89a1ad9cc7badc8a3621a9 Mon Sep 17 00:00:00 2001 From: lmccay Date: Fri, 11 Oct 2024 13:17:39 -0400 Subject: [PATCH] KNOX-3069 - Fix Flakey Test - TokenServiceResourceTest (#938) --- .../service/knoxtoken/TokenServiceResourceTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java b/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java index b3798bdd7..dc68117b6 100644 --- a/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java +++ b/gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java @@ -1136,8 +1136,13 @@ private void testLimitingTokensPerUser(int configuredLimit, int numberOfTokens, tss.addMetadata(tokenId, tokenMetadata); } + ArrayList tokenIDs = new ArrayList<>(); for (int i = 0; i < numberOfTokens; i++) { - acquireToken(tr); + final Response tokenResponse = acquireToken(tr); + final String tokenId = getTagValue(tokenResponse.getEntity().toString(), "token_id"); + assertNotNull("TokenID should not be null", tokenId); + assertFalse("TokenID must be unique", tokenIDs.contains(tokenId)); + tokenIDs.add(tokenId); } final Response getKnoxTokensResponse = getUserTokensResponse(tr); final Collection tokens = ((Map>) JsonUtils.getObjectFromJsonString(getKnoxTokensResponse.getEntity().toString()))