use of uk.gov.ida.hub.samlproxy.domain.SamlDto in project verify-hub by alphagov.
the class HubMetadataIntegrationTests method getSpMetadataFromApi_shouldReturnTheHubFromNewMetadataAsAnSp.
@Test
public void getSpMetadataFromApi_shouldReturnTheHubFromNewMetadataAsAnSp() throws Exception {
SamlDto samlDto = client.target(UriBuilder.fromUri(samlProxyAppRule.getUri("/API/metadata/sp"))).request().get(SamlDto.class);
EntityDescriptor entityDescriptor = getEntityDescriptor(samlDto);
assertThat(entityDescriptor.getEntityID()).isEqualTo(HUB_ENTITY_ID);
assertThat(entityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS)).isNull();
assertThat(entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS)).isNotNull();
assertThat(entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS).getAssertionConsumerServices().get(0).getLocation()).isEqualTo("http://foo.com/bar");
assertThat(entityDescriptor.getValidUntil()).isEqualTo(DateTime.now(DateTimeZone.UTC).plusHours(1));
}
use of uk.gov.ida.hub.samlproxy.domain.SamlDto in project verify-hub by alphagov.
the class HubMetadataIntegrationTests method getIdpMetadataFromApi_shouldWork.
@Test
public void getIdpMetadataFromApi_shouldWork() throws Exception {
final DateTime time = DateTime.now(DateTimeZone.UTC).plusHours(1);
SamlDto samlDto = client.target(UriBuilder.fromUri(samlProxyAppRule.getUri("/API/metadata/idp"))).request().get(SamlDto.class);
EntityDescriptor entityDescriptor = getEntityDescriptor(samlDto);
assertThat(entityDescriptor.getEntityID()).isEqualTo(HUB_ENTITY_ID);
assertThat(entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS)).isNull();
assertThat(entityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS)).isNotNull();
List<KeyDescriptor> keyDescriptors = entityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS).getKeyDescriptors();
// this is a bit fragile and dependent on the ordering of IDPs and in federation metadata
// this endpoint should be removed soon though...
assertThat(keyDescriptors).hasSize(7);
// signing certificates
validateKeyDescriptor(keyDescriptors, 0, HUB_ENTITY_ID);
validateKeyDescriptor(keyDescriptors, 1, HUB_ENTITY_ID, TestCertificateStrings.PUBLIC_SIGNING_CERTS.get(HUB_SECONDARY_ENTITY_ID));
validateKeyDescriptor(keyDescriptors, 2, STUB_IDP_ONE);
validateKeyDescriptor(keyDescriptors, 3, STUB_IDP_TWO);
validateKeyDescriptor(keyDescriptors, 4, STUB_IDP_THREE);
validateKeyDescriptor(keyDescriptors, 5, STUB_IDP_FOUR);
// encryption certificate
assertThat(getKeyName(keyDescriptors, 6)).isEqualTo(HUB_ENTITY_ID);
assertThat(getCertificateData(keyDescriptors, 6)).isEqualTo(TestCertificateStrings.getPrimaryPublicEncryptionCert(HUB_ENTITY_ID));
assertThat(entityDescriptor.getValidUntil()).isEqualTo(DateTime.now(DateTimeZone.UTC).plusHours(1));
}
Aggregations