use of com.github.tomakehurst.wiremock.matching.RequestMatcherExtension in project box-java-sdk by box.
the class BoxDeveloperEditionAPIConnectionTest method getRequestMatcher.
private RequestMatcherExtension getRequestMatcher(final String tokenPath) {
return new RequestMatcherExtension() {
@Override
public MatchResult match(Request request, Parameters parameters) {
if (!request.getMethod().equals(RequestMethod.POST) || !request.getUrl().equals(tokenPath)) {
return MatchResult.noMatch();
}
Assert.assertNotNull("JTI should be saved from previous request", BoxDeveloperEditionAPIConnectionTest.this.jtiClaim);
try {
JwtClaims claims = BoxDeveloperEditionAPIConnectionTest.this.getClaimsFromRequest(request);
String jti = claims.getJwtId();
long expTimestamp = claims.getExpirationTime().getValue();
Assert.assertNotEquals("JWT should have a new timestamp", 1511003910L, expTimestamp);
Assert.assertNotEquals("JWT should have a new jti claim", BoxDeveloperEditionAPIConnectionTest.this.jtiClaim, jti);
} catch (Exception ex) {
Assert.fail("Could not parse JWT when request is retried: " + ex.getMessage());
}
return MatchResult.exactMatch();
}
};
}
Aggregations