File tree Expand file tree Collapse file tree 5 files changed +22
-6
lines changed
main/java/com/mastercard/developer/oauth2/core
test/java/com/mastercard/developer/oauth2/internal/json Expand file tree Collapse file tree 5 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.mastercard.developer</groupId >
88 <artifactId >oauth2-client-java-root</artifactId >
9- <version >1.1.0-SNAPSHOT </version >
9+ <version >1.0.2 </version >
1010 </parent >
1111 <artifactId >oauth2-client-java</artifactId >
1212 <packaging >jar</packaging >
Original file line number Diff line number Diff line change @@ -323,11 +323,11 @@ public static AccessTokenResponse parseAccessTokenJson(String accessTokenRespons
323323 if (null == tokenValue ) {
324324 throw new OAuth2ClientException ("Missing value in access token response: access_token" );
325325 }
326- var expiresInSeconds = (Integer ) jsonMap .get ("expires_in" );
326+ var expiresInSeconds = (Number ) jsonMap .get ("expires_in" );
327327 if (null == expiresInSeconds ) {
328328 throw new OAuth2ClientException ("Missing value in access token response: expires_in" );
329329 }
330- Instant expiry = Instant .now ().plusSeconds (expiresInSeconds );
330+ Instant expiry = Instant .now ().plusSeconds (expiresInSeconds . intValue () );
331331 String scopeNode = (String ) jsonMap .get ("scope" );
332332 Set <String > scopes = (scopeNode == null ) ? Set .of () : Set .of (scopeNode .trim ().split ("\\ s+" ));
333333 return new AccessTokenResponse (tokenValue , scopes , expiry );
Original file line number Diff line number Diff line change @@ -44,10 +44,26 @@ void parse_ShouldParseAccessTokenResponse(JsonProvider provider) throws Exceptio
4444 // THEN
4545 assertEquals ("eyJ4NXQjUzI1NiI6Ii...oPIq4PZf2WaMxLow" , map .get ("access_token" ));
4646 assertEquals ("DPoP" , map .get ("token_type" ));
47- assertEquals (900.0 , ((Number ) map .get ("expires_in" )).doubleValue ());
47+ assertEquals (900 , ((Number ) map .get ("expires_in" )).intValue ());
4848 assertEquals ("service:scope1 service:scope2" , map .get ("scope" ));
4949 }
5050
51+ @ ParameterizedTest
52+ @ MethodSource ("jsonProviders" )
53+ void parse_ShouldParseExpireInDecimalValues (JsonProvider provider ) throws Exception {
54+ // GIVEN
55+ var json = """
56+ {
57+ "expires_in": 900.0
58+ }""" ;
59+
60+ // WHEN
61+ Map <String , Object > map = provider .parse (json );
62+
63+ // THEN
64+ assertEquals (900 , ((Number ) map .get ("expires_in" )).intValue ());
65+ }
66+
5167 @ ParameterizedTest
5268 @ MethodSource ("jsonProviders" )
5369 void parse_ShouldParseJwk (JsonProvider provider ) throws Exception {
Original file line number Diff line number Diff line change 66 <modelVersion >4.0.0</modelVersion >
77 <groupId >com.mastercard.developer</groupId >
88 <artifactId >oauth2-client-java-root</artifactId >
9- <version >1.1.0-SNAPSHOT </version >
9+ <version >1.0.2 </version >
1010 <packaging >pom</packaging >
1111
1212 <properties >
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >com.mastercard.developer</groupId >
88 <artifactId >oauth2-client-java-root</artifactId >
9- <version >1.1.0-SNAPSHOT </version >
9+ <version >1.0.2 </version >
1010 </parent >
1111 <artifactId >oauth2-client-java-test-clients</artifactId >
1212 <packaging >jar</packaging >
You can’t perform that action at this time.
0 commit comments