Skip to content

Commit

Permalink
Enhanced cache invalidation test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsdelmundo committed Sep 28, 2023
1 parent 1f7f573 commit 263dc6b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/test/java/com/uid2/shared/auth/AuthorizableStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public void refresh_returnsPreviouslyInvalidClients_afterRefresh() throws Except
cacheField.setAccessible(true);
Cache<String, String> cache = (Cache<String, String>) cacheField.get(clientKeyStore);

clientKeyStore.getAuthorizableByKey(SITE_11_CLIENT_KEY);

String key = "UID2-C-L-14-abcdef.abcdefabcdefabcdefabcdefabcdefabcdefab";
ClientKey invalidClientKey = clientKeyStore.getAuthorizableByKey(key);
String invalidCacheValue = cache.getIfPresent(key);
Expand All @@ -152,15 +154,28 @@ public void refresh_returnsPreviouslyInvalidClients_afterRefresh() throws Except
ClientKey client = createClientKey(khr, "client14", 14);
clients.add(client);
clientKeyStore.refresh(clients);

String existingCacheValue = cache.getIfPresent(SITE_11_CLIENT_KEY);

ClientKey validClientKey = clientKeyStore.getAuthorizableByKey(key);
String validCacheValue = cache.getIfPresent(key);

assertAll(
"refresh returns previously invalid clients after refresh",
() -> assertEquals("", invalidCacheValue),
() -> assertNull(invalidClientKey),
() -> assertEquals(khr.getHash(), validCacheValue),
() -> assertEquals("client14", validClientKey.getName())
() -> assertAll(
"refresh returns previously invalid clients after refresh - invalid values were previously invalid",
() -> assertNull(invalidClientKey),
() -> assertEquals("", invalidCacheValue)
),
() -> assertAll(
"refresh returns previously invalid clients after refresh - invalid values are now valid",
() -> assertEquals("client14", validClientKey.getName()),
() -> assertEquals(khr.getHash(), validCacheValue)
),
() -> assertAll(
"refresh returns previously invalid clients after refresh - valid values are still valid",
() -> assertEquals(clients.get(0).getKeyHash(), existingCacheValue)
)
);
}

Expand Down

0 comments on commit 263dc6b

Please sign in to comment.