Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-auth-server): fixing client tests effected by "scope to claim" mapping which is disabled by default #1873 #1910

Merged
merged 1 commit into from
Jul 27, 2022
Merged
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 @@ -8,6 +8,7 @@

import com.google.common.collect.Maps;
import io.jans.as.client.client.AssertBuilder;
import io.jans.as.client.client.Asserter;
import io.jans.as.client.dev.HostnameVerifierType;
import io.jans.as.client.page.AbstractPage;
import io.jans.as.client.page.PageConfig;
Expand Down Expand Up @@ -815,24 +816,7 @@ public void discovery(ITestContext context) throws Exception {
OpenIdConfigurationResponse response = client.execOpenIdConfiguration();

showClient(client);
assertEquals(response.getStatus(), 200, "Unexpected response code");
assertNotNull(response.getIssuer(), "The issuer is null");
assertNotNull(response.getAuthorizationEndpoint(), "The authorizationEndpoint is null");
assertNotNull(response.getTokenEndpoint(), "The tokenEndpoint is null");
assertNotNull(response.getRevocationEndpoint(), "The revocationEndpoint is null");
assertNotNull(response.getUserInfoEndpoint(), "The userInfoEndPoint is null");
assertNotNull(response.getJwksUri(), "The jwksUri is null");
assertNotNull(response.getRegistrationEndpoint(), "The registrationEndpoint is null");

assertTrue(response.getScopesSupported().size() > 0, "The scopesSupported is empty");
assertTrue(response.getResponseTypesSupported().size() > 0, "The responseTypesSupported is empty");
assertTrue(response.getGrantTypesSupported().size() > 0, "The grantTypesSupported is empty");
assertTrue(response.getAcrValuesSupported().size() >= 0, "The acrValuesSupported is empty");
assertTrue(response.getSubjectTypesSupported().size() > 0, "The subjectTypesSupported is empty");
assertTrue(response.getIdTokenSigningAlgValuesSupported().size() > 0, "The idTokenSigningAlgValuesSupported is empty");
assertTrue(response.getRequestObjectSigningAlgValuesSupported().size() > 0, "The requestObjectSigningAlgValuesSupported is empty");
assertTrue(response.getTokenEndpointAuthMethodsSupported().size() > 0, "The tokenEndpointAuthMethodsSupported is empty");
assertTrue(response.getClaimsSupported().size() > 0, "The claimsSupported is empty");
Asserter.assertOpenIdConfigurationResponse(response);

authorizationEndpoint = response.getAuthorizationEndpoint();
tokenEndpoint = response.getTokenEndpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

package io.jans.as.client.client;

import io.jans.as.client.OpenIdConfigurationResponse;
import io.jans.as.client.RegisterResponse;
import io.jans.as.model.register.RegisterRequestParam;

import java.util.Arrays;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.*;

/**
* @author Yuriy Zabrovarnyy
Expand Down Expand Up @@ -49,4 +49,31 @@ public static void assertRegisterResponseClaimsAreContained(RegisterResponse res
assertTrue(response.getClaims().containsKey(claim.toString()), "Claim " + claim + " is not contained in response claims - code" + response.getEntity());
}
}

public static void assertOpenIdConfigurationResponse(OpenIdConfigurationResponse response) {
assertEquals(response.getStatus(), 200, "Unexpected response code");
assertNotNull(response.getIssuer(), "The issuer is null");
assertNotNull(response.getAuthorizationEndpoint(), "The authorizationEndpoint is null");
assertNotNull(response.getTokenEndpoint(), "The tokenEndpoint is null");
assertNotNull(response.getRevocationEndpoint(), "The tokenRevocationEndpoint is null");
assertNotNull(response.getUserInfoEndpoint(), "The userInfoEndPoint is null");
assertNotNull(response.getClientInfoEndpoint(), "The clientInfoEndPoint is null");
assertNotNull(response.getCheckSessionIFrame(), "The checkSessionIFrame is null");
assertNotNull(response.getEndSessionEndpoint(), "The endSessionEndpoint is null");
assertNotNull(response.getJwksUri(), "The jwksUri is null");
assertNotNull(response.getRegistrationEndpoint(), "The registrationEndpoint is null");
assertNotNull(response.getIntrospectionEndpoint(), "The introspectionEndpoint is null");
assertNotNull(response.getParEndpoint(), "The parEndpoint is null");

assertTrue(response.getScopesSupported().size() > 0, "The scopesSupported is empty");
assertTrue(response.getResponseTypesSupported().size() > 0, "The responseTypesSupported is empty");
assertTrue(response.getGrantTypesSupported().size() > 0, "The grantTypesSupported is empty");
assertTrue(response.getSubjectTypesSupported().size() > 0, "The subjectTypesSupported is empty");
assertTrue(response.getIdTokenSigningAlgValuesSupported().size() > 0, "The idTokenSigningAlgValuesSupported is empty");
assertTrue(response.getRequestObjectSigningAlgValuesSupported().size() > 0, "The requestObjectSigningAlgValuesSupported is empty");
assertTrue(response.getTokenEndpointAuthMethodsSupported().size() > 0, "The tokenEndpointAuthMethodsSupported is empty");
assertTrue(response.getTokenEndpointAuthSigningAlgValuesSupported().size() > 0, "The tokenEndpointAuthSigningAlgValuesSupported is empty");
assertTrue(response.getClaimsSupported().size() > 0, "The claimsSupported is empty");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.jans.as.client.OpenIdConfigurationResponse;
import io.jans.as.client.OpenIdConnectDiscoveryClient;
import io.jans.as.client.OpenIdConnectDiscoveryResponse;
import io.jans.as.client.client.Asserter;
import io.jans.as.client.dev.HostnameVerifierType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;
Expand Down Expand Up @@ -62,26 +63,10 @@ public void requestOpenIdConfiguration(final String resource) throws Exception {
OpenIdConfigurationResponse response = client.execOpenIdConfiguration();

showClient(client);
assertEquals(response.getStatus(), 200, "Unexpected response code");
assertNotNull(response.getIssuer(), "The issuer is null");
assertNotNull(response.getAuthorizationEndpoint(), "The authorizationEndpoint is null");
assertNotNull(response.getTokenEndpoint(), "The tokenEndpoint is null");
assertNotNull(response.getRevocationEndpoint(), "The tokenRevocationEndpoint is null");
assertNotNull(response.getUserInfoEndpoint(), "The userInfoEndPoint is null");
assertNotNull(response.getClientInfoEndpoint(), "The clientInfoEndPoint is null");
assertNotNull(response.getCheckSessionIFrame(), "The checkSessionIFrame is null");
assertNotNull(response.getEndSessionEndpoint(), "The endSessionEndpoint is null");
assertNotNull(response.getJwksUri(), "The jwksUri is null");
assertNotNull(response.getRegistrationEndpoint(), "The registrationEndpoint is null");
assertNotNull(response.getIntrospectionEndpoint(), "The introspectionEndpoint is null");
assertNotNull(response.getParEndpoint(), "The parEndpoint is null");

assertTrue(response.getScopesSupported().size() > 0, "The scopesSupported is empty");
assertTrue(response.getScopeToClaimsMapping().size() > 0, "The scope to claims mapping is empty");
assertTrue(response.getResponseTypesSupported().size() > 0, "The responseTypesSupported is empty");
Asserter.assertOpenIdConfigurationResponse(response);

assertTrue(response.getResponseModesSupported().size() > 0, "The responseModesSupported is empty");
assertTrue(response.getGrantTypesSupported().size() > 0, "The grantTypesSupported is empty");
assertTrue(response.getAcrValuesSupported().size() >= 0, "The acrValuesSupported is empty");
assertTrue(response.getSubjectTypesSupported().size() > 0, "The subjectTypesSupported is empty");
assertTrue(response.getUserInfoSigningAlgValuesSupported().size() > 0, "The userInfoSigningAlgValuesSupported is empty");
assertTrue(response.getUserInfoEncryptionAlgValuesSupported().size() > 0, "The userInfoEncryptionAlgValuesSupported is empty");
Expand All @@ -92,21 +77,16 @@ public void requestOpenIdConfiguration(final String resource) throws Exception {
assertTrue(response.getRequestObjectSigningAlgValuesSupported().size() > 0, "The requestObjectSigningAlgValuesSupported is empty");
assertTrue(response.getRequestObjectEncryptionAlgValuesSupported().size() > 0, "The requestObjectEncryptionAlgValuesSupported is empty");
assertTrue(response.getRequestObjectEncryptionEncValuesSupported().size() > 0, "The requestObjectEncryptionEncValuesSupported is empty");
assertTrue(response.getTokenEndpointAuthMethodsSupported().size() > 0, "The tokenEndpointAuthMethodsSupported is empty");
assertTrue(response.getTokenEndpointAuthSigningAlgValuesSupported().size() > 0, "The tokenEndpointAuthSigningAlgValuesSupported is empty");

assertTrue(response.getDisplayValuesSupported().size() > 0, "The displayValuesSupported is empty");
assertTrue(response.getClaimTypesSupported().size() > 0, "The claimTypesSupported is empty");
assertTrue(response.getClaimsSupported().size() > 0, "The claimsSupported is empty");
assertNotNull(response.getServiceDocumentation(), "The serviceDocumentation is null");
assertTrue(response.getClaimsLocalesSupported().size() > 0, "The claimsLocalesSupported is empty");
assertTrue(response.getUiLocalesSupported().size() > 0, "The uiLocalesSupported is empty");
assertTrue(response.getClaimsParameterSupported(), "The claimsParameterSupported is false");
assertTrue(response.getRequestParameterSupported(), "The requestParameterSupported is false");
assertTrue(response.getRequestUriParameterSupported(), "The requestUriParameterSupported is false");
assertFalse(response.getRequireRequestUriRegistration(), "The requireRequestUriRegistration is true");
assertNotNull(response.getOpPolicyUri(), "The opPolicyUri is null");
assertNotNull(response.getOpTosUri(), "The opTosUri is null");

// Jans Auth #917: Add dynamic scopes and claims to discovery
Map<String, List<String>> scopeToClaims = response.getScopeToClaimsMapping();
Expand Down