Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private OzoneConfiguration createNewTestPath() throws IOException {
// TODO: Once HA and non-HA code paths are merged in
// OzoneDelegationTokenSecretManager, this test should be updated to
// test both ratis enabled and disabled case.
config.setBoolean(OZONE_OM_RATIS_ENABLE_KEY, false);
config.setBoolean(OZONE_OM_RATIS_ENABLE_KEY, true);
File newFolder = folder.toFile();
if (!newFolder.exists()) {
assertTrue(newFolder.mkdirs());
Expand Down Expand Up @@ -257,13 +257,15 @@ private void testRenewTokenSuccessHelper(boolean restartSecretManager)
Token<OzoneTokenIdentifier> token = secretManager.createToken(TEST_USER,
TEST_USER,
TEST_USER);
addToTokenStore(token);
Thread.sleep(10 * 5);

if (restartSecretManager) {
restartSecretManager();
}

long renewalTime = secretManager.renewToken(token, TEST_USER.toString());
addToTokenStore(token);
assertThat(renewalTime).isGreaterThan(0);
}

Expand All @@ -287,6 +289,7 @@ public void testRenewTokenFailure() throws Exception {
secretManager.start(certificateClient);
Token<OzoneTokenIdentifier> token = secretManager.createToken(TEST_USER,
TEST_USER, TEST_USER);
addToTokenStore(token);
AccessControlException exception =
assertThrows(AccessControlException.class,
() -> secretManager.renewToken(token, "rougeUser"));
Expand Down Expand Up @@ -354,6 +357,7 @@ public void testCancelTokenSuccess() throws Exception {
secretManager.start(certificateClient);
Token<OzoneTokenIdentifier> token = secretManager.createToken(TEST_USER,
TEST_USER, TEST_USER);
addToTokenStore(token);
secretManager.cancelToken(token, TEST_USER.toString());
}

Expand Down Expand Up @@ -512,4 +516,11 @@ private void validateHash(byte[] hash, byte[] identifier) throws Exception {
.setSecretKeyClient(secretKeyClient)
.build();
}

private void addToTokenStore(Token<OzoneTokenIdentifier> token) throws IOException {
OzoneTokenIdentifier ozoneTokenIdentifier = OzoneTokenIdentifier.
readProtoBuf(token.getIdentifier());
long renewDate = secretManager.updateToken(token, ozoneTokenIdentifier, expiryTime);
om.getMetadataManager().getDelegationTokenTable().put(ozoneTokenIdentifier, renewDate);
}
}