Skip to content
Merged
Changes from all 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 @@ -59,7 +59,6 @@
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.Time;

import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMTokenProto.Type.S3AUTHINFO;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -132,14 +131,6 @@ public void setUp() throws Exception {

private OzoneConfiguration createNewTestPath() throws IOException {
OzoneConfiguration config = new OzoneConfiguration();
// When ratis is enabled, tokens are not updated to the store directly by
// OzoneDelegationTokenSecretManager. Tokens are updated via Ratis
// through the DoubleBuffer. Hence, to test
// OzoneDelegationTokenSecretManager, we should disable OM Ratis.
// 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);
File newFolder = folder.toFile();
if (!newFolder.exists()) {
assertTrue(newFolder.mkdirs());
Expand Down Expand Up @@ -257,13 +248,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 +280,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 +348,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 +507,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);
}
}
Loading