[java-idp-oidc] 02/02: JOIDC-22 Update Core Nimbus libraries
Henri Mikkonen
henri.mikkonen at iki.fi
Tue Feb 2 14:22:55 UTC 2021
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=523cfb4a639ba68548e1635ac84aee68284cb7a6
commit 523cfb4a639ba68548e1635ac84aee68284cb7a6
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Tue Feb 2 16:21:47 2021 +0200
JOIDC-22 Update Core Nimbus libraries
https://issues.shibboleth.net/jira/browse/JOIDC-22
Refactored and re-enabled two tests that were temporarily disabled
due to the following Nimbus issue:
https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/339
---
.../impl/FormOutboundDiscoveryResponseTest.java | 56 +++++++++++++++++-----
1 file changed, 43 insertions(+), 13 deletions(-)
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundDiscoveryResponseTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundDiscoveryResponseTest.java
index 4e473f46..9094bfd3 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundDiscoveryResponseTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundDiscoveryResponseTest.java
@@ -32,7 +32,14 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import net.minidev.json.JSONObject;
+import com.nimbusds.jose.JWSAlgorithm;
+import com.nimbusds.oauth2.sdk.GrantType;
+import com.nimbusds.oauth2.sdk.ParseException;
+import com.nimbusds.oauth2.sdk.ResponseType;
+import com.nimbusds.oauth2.sdk.Scope;
+import com.nimbusds.openid.connect.sdk.SubjectType;
+import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
+
import net.shibboleth.idp.plugin.oidc.op.messaging.JSONSuccessResponse;
import net.shibboleth.idp.plugin.oidc.op.metadata.impl.DynamicFilesystemProviderMetadataResolver;
import net.shibboleth.idp.plugin.oidc.op.metadata.impl.FilesystemProviderMetadataResolver;
@@ -85,8 +92,7 @@ public class FormOutboundDiscoveryResponseTest {
return resolver;
}
- // @Test TODO: disabled now before the bug below gets resolved
- // https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/339
+ @Test
public void testStatic() throws Exception {
action.setMetadataResolver(initMetadataResolver());
action.initialize();
@@ -95,13 +101,12 @@ public class FormOutboundDiscoveryResponseTest {
final JSONSuccessResponse resp =
(JSONSuccessResponse) profileRequestCtx.getOutboundMessageContext().getMessage();
Assert.assertTrue(resp.indicatesSuccess());
- final JSONObject jsonObject = resp.toHTTPResponse().getContentAsJSONObject();
- Assert.assertEquals(jsonObject.size(), 17);
- Assert.assertNull(jsonObject.get(dynamicClaim));
+ final OIDCProviderMetadata metadata = OIDCProviderMetadata.parse(resp.toHTTPResponse().getContent());
+ assertFileContents(metadata);
+ Assert.assertNull(metadata.getCustomParameter(dynamicClaim));
}
- // @Test TODO: disabled now before the bug below gets resolved
- // https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/339
+ @Test
public void testDynamic() throws Exception {
final Map<String, MetadataValueResolver> map = new HashMap<>();
map.put(dynamicClaim, initMockResolver(dynamicClaimValue));
@@ -110,11 +115,36 @@ public class FormOutboundDiscoveryResponseTest {
ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
final JSONSuccessResponse resp =
(JSONSuccessResponse) profileRequestCtx.getOutboundMessageContext().getMessage();
- Assert.assertTrue(resp.indicatesSuccess());
- final JSONObject jsonObject = resp.toHTTPResponse().getContentAsJSONObject();
- Assert.assertEquals(jsonObject.size(), 18);
- Assert.assertNotNull(jsonObject.get(dynamicClaim));
- Assert.assertEquals(jsonObject.get(dynamicClaim), dynamicClaimValue);
+ final OIDCProviderMetadata metadata = OIDCProviderMetadata.parse(resp.toHTTPResponse().getContent());
+ assertFileContents(metadata);
+ Assert.assertNotNull(metadata.getCustomParameter(dynamicClaim));
+ Assert.assertEquals(metadata.getCustomParameter(dynamicClaim), dynamicClaimValue);
+ }
+
+ protected void assertFileContents(final OIDCProviderMetadata metadata) throws ParseException {
+ Assert.assertNotNull(metadata.getIssuer());
+ Assert.assertEquals(metadata.getIssuer().getValue(), "http://idp.example.org");
+ Assert.assertNotNull(metadata.getAuthorizationEndpointURI());
+ Assert.assertEquals(metadata.getAuthorizationEndpointURI().toString(),
+ "https://op.example.org/idp/profile/oidc/authorize");
+ Assert.assertNotNull(metadata.getRegistrationEndpointURI());
+ Assert.assertEquals(metadata.getRegistrationEndpointURI().toString(),
+ "https://op.example.org/idp/profile/oidc/register");
+ Assert.assertNotNull(metadata.getJWKSetURI());
+ Assert.assertEquals(metadata.getJWKSetURI().toString(),
+ "https://op.example.org/oidc/keyset.jwk");
+ Assert.assertEquals(metadata.getResponseTypes(), Arrays.asList(ResponseType.parse("id_token")));
+ Assert.assertEquals(metadata.getSubjectTypes(), Arrays.asList(SubjectType.PUBLIC, SubjectType.PAIRWISE));
+ Assert.assertEquals(metadata.getGrantTypes(), Arrays.asList(GrantType.IMPLICIT));
+ Assert.assertEquals(metadata.getIDTokenJWSAlgs(), Arrays.asList(JWSAlgorithm.RS256));
+ Assert.assertFalse(metadata.supportsRequestURIParam());
+ Assert.assertFalse(metadata.supportsRequestURIParam());
+ Assert.assertFalse(metadata.requiresRequestURIRegistration());
+ Assert.assertEquals(metadata.getScopes(), Arrays.asList(new Scope.Value("openid"), new Scope.Value("profile"),
+ new Scope.Value("email"), new Scope.Value("address"), new Scope.Value("phone"),
+ new Scope.Value("info")));
+ Assert.assertEquals(metadata.getClaims(), Arrays.asList("aud", "acr", "exp", "iat", "iss", "sub",
+ "eduPersonPrincipalName", "eduPersonAffiliation", "mail"));
}
protected ProviderMetadataResolver initMetadataResolver(final Map<String, MetadataValueResolver> map)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list