Search in sources :

Example 1 with RemoteMatchingServiceConfig

use of uk.gov.ida.hub.config.domain.remoteconfig.RemoteMatchingServiceConfig in project verify-hub by alphagov.

the class S3ConfigSourceTest method getRemoteConfigReturnsRemoteConfigCollection.

@Test
public /**
 * Tests to make sure we can process the JSON to an object
 */
void getRemoteConfigReturnsRemoteConfigCollection() throws Exception {
    SelfServiceConfig selfServiceConfig = objectMapper.readValue(selfServiceConfigEnabledJson, SelfServiceConfig.class);
    when(s3Client.getObject(new GetObjectRequest(BUCKET_NAME, OBJECT_KEY))).thenReturn(s3Object);
    when(s3Object.getObjectContent()).thenReturn(getObjectStream("/remote-test-config.json"));
    when(s3Object.getObjectMetadata()).thenReturn(objectMetadata);
    when(objectMetadata.getLastModified()).thenReturn(new Date());
    S3ConfigSource testSource = new S3ConfigSource(selfServiceConfig, s3Client, objectMapper);
    RemoteConfigCollection result = testSource.getRemoteConfig();
    Map<String, RemoteMatchingServiceConfig> msConfigs = result.getMatchingServiceAdapters();
    assertThat(msConfigs.size()).isEqualTo(3);
    assertThat(msConfigs.get("https://msa.bananaregistry.test.com").getName()).isEqualTo("Banana Registry MSA");
    assertThat(msConfigs.get("https://msa.bananaregistry.test.com").getEncryptionCertificate()).contains(CERT_MSA_BANANA_ENCRYPTION);
    assertThat(msConfigs.get("https://msa.bananaregistry.test.com").getSignatureVerificationCertificates().size()).isEqualTo(1);
    assertThat(msConfigs.get("https://msa.bananaregistry.test.com").getSignatureVerificationCertificates().get(0)).contains(CERT_MSA_BANANA_SIGNING);
    Map<String, RemoteServiceProviderConfig> spConfigs = result.getServiceProviders();
    assertThat(spConfigs.size()).isEqualTo(3);
    RemoteServiceProviderConfig spConfig2 = spConfigs.get("2");
    assertThat(spConfig2.getName()).isEqualTo("Apple Registry VSP");
    assertThat(spConfig2.getSignatureVerificationCertificates().size()).isEqualTo(1);
    assertThat(spConfig2.getSignatureVerificationCertificates().get(0)).contains(CERT_VSP_APPLE_SIGNING);
    RemoteServiceProviderConfig spConfig3 = spConfigs.get("3");
    assertThat(spConfig3.getName()).isEqualTo("Banana Registry VSP");
    assertThat(spConfig3.getSignatureVerificationCertificates().size()).isEqualTo(1);
    assertThat(spConfig3.getSignatureVerificationCertificates().get(0)).contains(CERT_VSP_BANANA_SIGNING);
}
Also used : RemoteConfigCollection(uk.gov.ida.hub.config.domain.remoteconfig.RemoteConfigCollection) SelfServiceConfig(uk.gov.ida.hub.config.configuration.SelfServiceConfig) RemoteMatchingServiceConfig(uk.gov.ida.hub.config.domain.remoteconfig.RemoteMatchingServiceConfig) RemoteServiceProviderConfig(uk.gov.ida.hub.config.domain.remoteconfig.RemoteServiceProviderConfig) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)1 Date (java.util.Date)1 Test (org.junit.jupiter.api.Test)1 SelfServiceConfig (uk.gov.ida.hub.config.configuration.SelfServiceConfig)1 RemoteConfigCollection (uk.gov.ida.hub.config.domain.remoteconfig.RemoteConfigCollection)1 RemoteMatchingServiceConfig (uk.gov.ida.hub.config.domain.remoteconfig.RemoteMatchingServiceConfig)1 RemoteServiceProviderConfig (uk.gov.ida.hub.config.domain.remoteconfig.RemoteServiceProviderConfig)1