Search in sources :

Example 1 with SamlDto

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));
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) SamlDto(uk.gov.ida.hub.samlproxy.domain.SamlDto) Test(org.junit.Test)

Example 2 with SamlDto

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));
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) KeyDescriptor(org.opensaml.saml.saml2.metadata.KeyDescriptor) DateTime(org.joda.time.DateTime) SamlDto(uk.gov.ida.hub.samlproxy.domain.SamlDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)2 SamlDto (uk.gov.ida.hub.samlproxy.domain.SamlDto)2 DateTime (org.joda.time.DateTime)1 KeyDescriptor (org.opensaml.saml.saml2.metadata.KeyDescriptor)1