Skip to content
Open
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 @@ -27,7 +27,7 @@ public static BearerToken of(String token) {

public static BearerToken of(OAuthServerResponse oAuthServerResponse, long currentTimeInMillis) {
return BearerToken.of(
oAuthServerResponse.getAccessToken(), oAuthServerResponse.getExpiresIn(), currentTimeInMillis);
oAuthServerResponse.getAccessToken(), currentTimeInMillis, oAuthServerResponse.getExpiresIn());
}

public static BearerToken of(String token, long currentTimeInMillis, long expiresIn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import org.junit.jupiter.api.Test;

import io.github.jpmorganchase.fusion.oauth.retriever.OAuthServerResponse;

class BearerTokenTest {

@Test
Expand Down Expand Up @@ -41,4 +43,25 @@
assertTrue(bearerToken.hasTokenExpired(expiry + 1));
assertFalse(bearerToken.hasTokenExpired(expiry - 1));
}

@Test
public void testHasTokenExpiredWhenCanExpireFromResponse() {

Check warning on line 48 in src/test/java/io/github/jpmorganchase/fusion/oauth/model/BearerTokenTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=jpmorganchase_fusion-java-sdk&issues=AZ0w8IEvOTMil6mNrzl8&open=AZ0w8IEvOTMil6mNrzl8&pullRequest=170
String token = "my-token";
long currentTimeInMillis = 1625666400000L;
int expiresIn = 3600;

OAuthServerResponse oAuthServerResponse =

OAuthServerResponse.builder()
.accessToken(token)
.expiresIn(expiresIn)
.build();

BearerToken bearerToken = BearerToken.of(oAuthServerResponse, currentTimeInMillis);

long expiry = bearerToken.getExpiry();

assertTrue(bearerToken.hasTokenExpired(expiry + 1));
assertFalse(bearerToken.hasTokenExpired(expiry - 1));
}
}