diff --git a/server/src/test/java/org/cloudfoundry/identity/uaa/provider/oauth/OauthIdentityProviderDefinitionFactoryBeanTest.java b/server/src/test/java/org/cloudfoundry/identity/uaa/provider/oauth/OauthIdentityProviderDefinitionFactoryBeanTest.java index 10bdc4534b4..2202fc7744a 100644 --- a/server/src/test/java/org/cloudfoundry/identity/uaa/provider/oauth/OauthIdentityProviderDefinitionFactoryBeanTest.java +++ b/server/src/test/java/org/cloudfoundry/identity/uaa/provider/oauth/OauthIdentityProviderDefinitionFactoryBeanTest.java @@ -165,4 +165,36 @@ public void jwtClientAuthenticationWithCustomSetting() { assertNotNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getJwtClientAuthentication()); assertEquals("issuer", (((Map)((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getJwtClientAuthentication()).get("iss"))); } -} \ No newline at end of file + + @Test + public void testNoDiscoveryUrl() { + Map definitions = new HashMap<>(); + idpDefinitionMap.remove("discoveryUrl"); + idpDefinitionMap.put("type", OriginKeys.OIDC10); + definitions.put("test", idpDefinitionMap); + factoryBean = new OauthIDPWrapperFactoryBean(definitions); + factoryBean.setCommonProperties(idpDefinitionMap, providerDefinition); + assertTrue(factoryBean.getProviders().get(0).getProvider().getConfig() instanceof OIDCIdentityProviderDefinition); + assertNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getDiscoveryUrl()); + assertEquals("http://auth.url", ((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getAuthUrl().toString()); + assertEquals("http://token-key.url", ((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getTokenKeyUrl().toString()); + assertEquals("http://token.url", ((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getTokenUrl().toString()); + assertEquals("http://logout.url", ((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getLogoutUrl().toString()); + } + + @Test + public void testDiscoveryUrl() { + Map definitions = new HashMap<>(); + idpDefinitionMap.put("discoveryUrl", "http://localhost:8080/uaa/.well-known/openid-configuration"); + idpDefinitionMap.put("type", OriginKeys.OIDC10); + definitions.put("test", idpDefinitionMap); + factoryBean = new OauthIDPWrapperFactoryBean(definitions); + factoryBean.setCommonProperties(idpDefinitionMap, providerDefinition); + assertTrue(factoryBean.getProviders().get(0).getProvider().getConfig() instanceof OIDCIdentityProviderDefinition); + assertEquals("http://localhost:8080/uaa/.well-known/openid-configuration", ((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getDiscoveryUrl().toString()); + assertNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getAuthUrl()); + assertNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getTokenKeyUrl()); + assertNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getTokenUrl()); + assertNull(((OIDCIdentityProviderDefinition) factoryBean.getProviders().get(0).getProvider().getConfig()).getLogoutUrl()); + } +}