SamlServiceProviderConfigurator { public List<SamlServiceProviderHolder> getSamlServiceProvidersForZone(IdentityZone zone) { List<SamlServiceProviderHolder> result = new LinkedList<>(); for (SamlServiceProvider provider : providerProvisioning.retrieveActive(zone.getId())) { try { SamlServiceProviderHolder samlServiceProviderHolder = new SamlServiceProviderHolder(getExtendedMetadataDelegate(provider), provider); result.add(samlServiceProviderHolder); } catch (MetadataProviderException e) { LOG.error("Unable to configure SAML SP Metadata for ServiceProvider:" + provider.getEntityId(), e); } } return Collections.unmodifiableList(result); } 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 testGetSamlServiceProvidersForZone() throws Exception { try { String zoneId = UUID.randomUUID().toString(); SamlServiceProvider sp = mockSamlServiceProviderForZone("uaa"); sp.setIdentityZoneId(zoneId); IdentityZoneHolder.set(withId(zoneId)); conf.validateSamlServiceProvider(sp); when(providerProvisioning.retrieveActive(zoneId)).thenReturn(Collections.singletonList(sp)); String unwantedZoneId = UUID.randomUUID().toString(); SamlServiceProvider unwantedSp = mockSamlServiceProviderForZone("uaa"); unwantedSp.setIdentityZoneId(unwantedZoneId); IdentityZoneHolder.set(withId(unwantedZoneId)); conf.validateSamlServiceProvider(unwantedSp); when(providerProvisioning.retrieveActive(unwantedZoneId)).thenReturn(Collections.singletonList(unwantedSp)); IdentityZone zone = withId(zoneId); List<SamlServiceProviderHolder> spList = conf.getSamlServiceProvidersForZone(zone); assertEquals(1, spList.size()); assertEquals(sp, spList.get(0).getSamlServiceProvider()); } finally { TestUtils.resetIdentityZoneHolder(null); } }