@@ -121,12 +121,12 @@ public void simpleOperationsWithConfigurator() throws Exception {
121
121
assertThat ("incorrect environments" , oip .getEnvironments (), is (set ("myenv" )));
122
122
assertThat ("incorrect login url" , oip .getLoginURI ("foo3" , "pkce" , false , null ),
123
123
is (new URI ("https://ologin.com/oauth/authorize?" +
124
- "scope=openid" +
124
+ "scope=openid+%2Fauthenticate " +
125
125
"&state=foo3&redirect_uri=https%3A%2F%2Fologinredir.com" +
126
126
"&response_type=code&client_id=ofoo" )));
127
127
assertThat ("incorrect link url" , oip .getLoginURI ("foo4" , "pkce" , true , null ),
128
128
is (new URI ("https://ologin.com/oauth/authorize?" +
129
- "scope=openid" +
129
+ "scope=openid+%2Fauthenticate " +
130
130
"&state=foo4&redirect_uri=https%3A%2F%2Folinkredir.com" +
131
131
"&response_type=code&client_id=ofoo" )));
132
132
@@ -150,12 +150,12 @@ public void simpleOperationsWithoutConfigurator() throws Exception {
150
150
assertThat ("incorrect environments" , oip .getEnvironments (), is (set ("myenv" )));
151
151
assertThat ("incorrect login url" , oip .getLoginURI ("foo5" , "pkce" , false , null ),
152
152
is (new URI ("https://ologin.com/oauth/authorize?" +
153
- "scope=openid" +
153
+ "scope=openid+%2Fauthenticate " +
154
154
"&state=foo5&redirect_uri=https%3A%2F%2Fologinredir.com" +
155
155
"&response_type=code&client_id=ofoo" )));
156
156
assertThat ("incorrect link url" , oip .getLoginURI ("foo6" , "pkce" , true , null ),
157
157
is (new URI ("https://ologin.com/oauth/authorize?" +
158
- "scope=openid" +
158
+ "scope=openid+%2Fauthenticate " +
159
159
"&state=foo6&redirect_uri=https%3A%2F%2Folinkredir.com" +
160
160
"&response_type=code&client_id=ofoo" )));
161
161
@@ -267,15 +267,15 @@ public void returnsIllegalAuthtokenResponse() throws Exception {
267
267
final IdentityRetrievalException e =
268
268
new IdentityRetrievalException ("No access token was returned by OrcID" );
269
269
270
- setUpCallAuthToken (acode , null , redir , cliid , clisec , "name" , "fake ID" );
270
+ setUpCallAuthTokenWithJWT (acode , null , redir , cliid , clisec , "name" , "fake ID" , createJWTWithoutAmr ( "fake ID" ) );
271
271
failGetIdentities (idp , acode , "pkce" , false , e );
272
- setUpCallAuthToken (acode , "\t " , redir , cliid , clisec , "name" , "fake ID" );
272
+ setUpCallAuthTokenWithJWT (acode , "\t " , redir , cliid , clisec , "name" , "fake ID" , createJWTWithoutAmr ( "fake ID" ) );
273
273
failGetIdentities (idp , acode , "pkce" , false , e );
274
274
275
- setUpCallAuthToken (acode , "fake token" , redir , cliid , clisec , "my name" , null );
275
+ setUpCallAuthTokenWithJWT (acode , "fake token" , redir , cliid , clisec , "my name" , null , createJWTWithoutAmr ( "fake ID" ) );
276
276
failGetIdentities (idp , acode , "pkce" , false , new IdentityRetrievalException (
277
277
"No id was returned by OrcID" ));
278
- setUpCallAuthToken (acode , "fake token" , redir , cliid , clisec , "my name" , " \t \n " );
278
+ setUpCallAuthTokenWithJWT (acode , "fake token" , redir , cliid , clisec , "my name" , " \t \n " , createJWTWithoutAmr ( "fake ID" ) );
279
279
failGetIdentities (idp , acode , "pkce" , false , new IdentityRetrievalException (
280
280
"No id was returned by OrcID" ));
281
281
}
@@ -336,12 +336,12 @@ public void returnsBadResponseIdentity() throws Exception {
336
336
final String authtoken = "bartoken" ;
337
337
final String orcID = "0000-0001-1234-5678" ;
338
338
339
- setUpCallAuthToken (authCode , authtoken , redir , cliid , clisec , "my name" , orcID );
339
+ setUpCallAuthTokenWithJWT (authCode , authtoken , redir , cliid , clisec , "my name" , orcID , createJWTWithoutAmr ( orcID ) );
340
340
setupCallID (authtoken , orcID , APP_JSON , 200 , "bleah" );
341
341
failGetIdentities (idp , authCode , "pkce" , false , new IdentityRetrievalException (
342
342
"Unable to parse response from OrcID service." ));
343
343
344
- setUpCallAuthToken (authCode , authtoken , redir , cliid , clisec , "my name" , orcID );
344
+ setUpCallAuthTokenWithJWT (authCode , authtoken , redir , cliid , clisec , "my name" , orcID , createJWTWithoutAmr ( orcID ) );
345
345
setupCallID (authtoken , orcID , "text/html" , 200 , MAPPER .writeValueAsString (
346
346
map ("id" , "id1" , "displayName" , "dispname1" , "emails" , Arrays .asList (
347
347
map ("value" , "email1" )))));
@@ -398,8 +398,8 @@ private void getIdentityWithLoginURL(final String email, final Map<String, Objec
398
398
final IdentityProvider idp = new OrcIDIdentityProvider (idconfig );
399
399
final String orcID = "0000-0001-1234-5678" ;
400
400
401
- setUpCallAuthToken (authCode , "footoken3" , "https://ologinredir.com" ,
402
- idconfig .getClientID (), idconfig .getClientSecret (), " My name " , orcID );
401
+ setUpCallAuthTokenWithJWT (authCode , "footoken3" , "https://ologinredir.com" ,
402
+ idconfig .getClientID (), idconfig .getClientSecret (), " My name " , orcID , createJWTWithoutAmr ( orcID ) );
403
403
setupCallID ("footoken3" , orcID , APP_JSON , 200 , MAPPER .writeValueAsString (response ));
404
404
final Set <RemoteIdentity > rids = idp .getIdentities (authCode , "pkce" , false , null );
405
405
assertThat ("incorrect number of idents" , rids .size (), is (1 ));
@@ -454,9 +454,9 @@ private void getIdentityWithLinkURL(final String email, final Map<String, Object
454
454
final IdentityProvider idp = new OrcIDIdentityProvider (idconfig );
455
455
final String orcID = "0000-0001-1234-5678" ;
456
456
457
- setUpCallAuthToken (authCode , "footoken2" , "https://olinkredir2.com" ,
457
+ setUpCallAuthTokenWithJWT (authCode , "footoken2" , "https://olinkredir2.com" ,
458
458
idconfig .getClientID (), idconfig .getClientSecret (),
459
- null , orcID );
459
+ null , orcID , createJWTWithoutAmr ( orcID ) );
460
460
setupCallID ("footoken2" , orcID , APP_JSON , 200 , MAPPER .writeValueAsString (
461
461
response ));
462
462
final Set <RemoteIdentity > rids = idp .getIdentities (authCode , "pkce" , true , null );
@@ -547,12 +547,15 @@ public void getIdentityWithNoJWT() throws Exception {
547
547
idconfig .getClientID (), idconfig .getClientSecret (), " My name " , orcID );
548
548
setupCallID ("footoken5" , orcID , APP_JSON , 200 , MAPPER .writeValueAsString (
549
549
map (
"email" ,
Arrays .
asList (
map (
"email" ,
"[email protected] " )))));
550
- final Set <RemoteIdentity > rids = idp .getIdentities (authCode , "pkce" , false , null );
551
- assertThat ("incorrect number of idents" , rids .size (), is (1 ));
552
- final Set <RemoteIdentity > expected = new HashSet <>();
553
- expected .add (new RemoteIdentity (new RemoteIdentityID (ORCID , orcID ),
554
- new RemoteIdentityDetails (
orcID ,
"My name" ,
"[email protected] " ,
MfaStatus .
UNKNOWN )));
555
- assertThat ("incorrect ident set" , rids , is (expected ));
550
+
551
+ // Now that JWT is required, this should fail with missing JWT error
552
+ try {
553
+ idp .getIdentities (authCode , "pkce" , false , null );
554
+ fail ("Expected IdentityRetrievalException" );
555
+ } catch (IdentityRetrievalException e ) {
556
+ assertThat ("incorrect exception message" , e .getMessage (),
557
+ is ("10030 Identity retrieval failed: No JWT token provided by ORCID despite requesting OpenID scope" ));
558
+ }
556
559
}
557
560
558
561
@ Test
0 commit comments