Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -61,6 +61,7 @@ public class DLFAuthProvider implements AuthProvider {
private final String tokenFilePath;

protected DLFToken token;
protected boolean refreshSuccess;
private final boolean keepRefreshed;
private Long expiresAtMillis;
private final Long tokenRefreshInMills;
Expand Down Expand Up @@ -142,10 +143,12 @@ public boolean refresh() {
long start = System.currentTimeMillis();
DLFToken newToken = readToken(tokenFilePath, 0);
if (newToken == null) {
this.refreshSuccess = false;
return false;
}
this.expiresAtMillis = start + this.tokenRefreshInMills;
this.token = newToken;
this.refreshSuccess = true;
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ public void testRefreshDLFAuthTokenFileAuthProvider() throws IOException, Interr
tokenFile2Token = generateTokenAndWriteToFile(fileName);
token = tokenFile2Token.getRight();
Thread.sleep(tokenRefreshInMills * 2);
authToken = OBJECT_MAPPER_INSTANCE.writeValueAsString(dlfAuthProvider.token);
assertEquals(authToken, token);
if (dlfAuthProvider.refreshSuccess) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can get token first, and get token to see if it is be equal to previous token.

authToken = OBJECT_MAPPER_INSTANCE.writeValueAsString(dlfAuthProvider.token);
assertEquals(authToken, token);
}
}

@Test
Expand Down
Loading