SamlServiceProviderConfigurator { public void validateSamlServiceProvider(SamlServiceProvider provider) throws MetadataProviderException { validateSamlServiceProvider(provider, IdentityZoneHolder.get()); } SamlServiceProviderConfigurator(); List<SamlServiceProviderHolder> getSamlServiceProviders(); List<SamlServiceProviderHolder> getSamlServiceProvidersForZone(IdentityZone zone); void validateSamlServiceProvider(SamlServiceProvider provider); ExtendedMetadataDelegate getExtendedMetadataDelegate(SamlServiceProvider provider); SamlServiceProviderProvisioning getProviderProvisioning(); void setProviderProvisioning(SamlServiceProviderProvisioning providerProvisioning); BasicParserPool getParserPool(); void setParserPool(BasicParserPool parserPool); void setSupportedNameIDs(Set<String> supportedNameIDs); void setFixedHttpMetaDataProvider(FixedHttpMetaDataProvider fixedHttpMetaDataProvider);  }
@Test public void testValidateSamlServiceProviderWithNoNameIDFormats() { SamlServiceProvider sp = mockSamlServiceProvider("uaa", ""); try { conf.validateSamlServiceProvider(sp); Assert.assertTrue("Valid Saml Service Provider", true); } catch (MetadataProviderException e) { Assert.fail("Invalid Saml Service Provider"); } }
@Test public void testValidateSamlServiceProviderWithUnsupportedNameIDFormats() throws Exception { String entityId = "uaa"; expectedEx.expect(MetadataProviderException.class); expectedEx.expectMessage("UAA does not support any of the NameIDFormats specified in the metadata for entity: " + entityId); SamlServiceProvider sp = mockSamlServiceProvider(entityId, "<md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</md:NameIDFormat>"); conf.validateSamlServiceProvider(sp); }
@Test(expected = IllegalArgumentException.class) public void testAddSamlServiceProviderToWrongZone() throws Exception { SamlServiceProvider sp = mockSamlServiceProviderForZone("uaa"); sp.setIdentityZoneId(UUID.randomUUID().toString()); conf.validateSamlServiceProvider(sp); }
@Test(expected = MetadataProviderException.class) public void testValidateSamlServiceProviderWithConflictingEntityId() throws Exception { SamlServiceProvider sp = mockSamlServiceProviderForZone("uaa"); conf.validateSamlServiceProvider(sp); SamlServiceProviderDefinition duplicateDef = SamlServiceProviderDefinition.Builder.get() .setMetaDataLocation(String.format(SamlTestUtils.UNSIGNED_SAML_SP_METADATA_WITHOUT_ID, new RandomValueStringGenerator().generate())) .setNameID("sample-nameID").setSingleSignOnServiceIndex(1) .setMetadataTrustCheck(true).build(); SamlServiceProvider duplicate = new SamlServiceProvider().setEntityId(MOCK_SP_ENTITY_ID + "_2").setIdentityZoneId("uaa") .setConfig(duplicateDef); conf.validateSamlServiceProvider(duplicate); }
@Test(expected = NullPointerException.class) public void testValidateNullSamlServiceProvider() throws Exception { conf.validateSamlServiceProvider(null); }
@Test(expected = NullPointerException.class) public void testValidatorSamlServiceProviderWithNullIdentityZoneId() throws Exception { SamlServiceProvider sp = mockSamlServiceProviderForZone("uaa"); sp.setIdentityZoneId(null); conf.validateSamlServiceProvider(sp); }
@Test public void testNullSSODescriptor() throws Exception { conf.validateSamlServiceProvider(mockSamlServiceProviderForZoneWithoutSPSSOInMetadata("uaa")); }