Skip to content
Merged
Show file tree
Hide file tree
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 @@ -518,9 +518,9 @@ protected DelegationTokenInformation checkToken(TokenIdent identifier)
}
long now = Time.now();
if (info.getRenewDate() < now) {
err =
"Token has" + identifier.getRealUser() + "expired, current time: " + Time.formatTime(now)
+ " expected renewal time: " + Time.formatTime(info.getRenewDate());
err = "Token " + identifier.getRealUser() + " has expired, current time: "
+ Time.formatTime(now) + " expected renewal time: " + Time
.formatTime(info.getRenewDate());
LOG.info("{}, Token={}", err, formatTokenId(identifier));
throw new InvalidToken(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.hadoop.yarn.server.resourcemanager;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand All @@ -36,6 +35,7 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;

import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.net.NetUtils;
Expand Down Expand Up @@ -111,7 +111,7 @@ public void resetSecretManager() {
}

@Test
public void testDelegationToken() throws IOException, InterruptedException {
public void testDelegationToken() throws Exception {

final YarnConfiguration conf = new YarnConfiguration();
conf.set(YarnConfiguration.RM_PRINCIPAL, "testuser/localhost@apache.org");
Expand Down Expand Up @@ -198,14 +198,11 @@ public void testDelegationToken() throws IOException, InterruptedException {
}
Thread.sleep(50l);
LOG.info("At time: " + System.currentTimeMillis() + ", token should be invalid");
// Token should have expired.
try {
clientRMWithDT.getNewApplication(request);
fail("Should not have succeeded with an expired token");
} catch (Exception e) {
assertEquals(InvalidToken.class.getName(), e.getClass().getName());
assertTrue(e.getMessage().contains("is expired"));
}
// Token should have expired.
final ApplicationClientProtocol finalClientRMWithDT = clientRMWithDT;
final GetNewApplicationRequest finalRequest = request;
LambdaTestUtils.intercept(InvalidToken.class, "Token has expired",
() -> finalClientRMWithDT.getNewApplication(finalRequest));

// Test cancellation
// Stop the existing proxy, start another.
Expand Down