@Test public void applicationShouldStartUp() throws Exception { environmentHelper.setEnv(new HashMap<String, String>() {{ put("PORT", "50555"); put("LOG_LEVEL", "ERROR"); put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL"); put("MSA_METADATA_URL", "some-msa-metadata-url"); put("MSA_ENTITY_ID", "some-msa-entity-id"); put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\"]"); put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY); put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("SAML_SECONDARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("CLOCK_SKEW", "PT5s"); }}); application.getTestSupport().before(); VerifyServiceProviderConfiguration configuration = application.getConfiguration(); assertThat(application.getLocalPort()).isEqualTo(50555); assertThat(((DefaultLoggingFactory) configuration.getLoggingFactory()).getLevel().toString()).isEqualTo("ERROR"); assertThat(configuration.getHubSsoLocation().toString()).isEqualTo(HubEnvironment.COMPLIANCE_TOOL.getSsoLocation().toString()); assertThat(configuration.getVerifyHubMetadata().getUri().toString()).isEqualTo(HubEnvironment.COMPLIANCE_TOOL.getMetadataUri().toString()); assertThat(configuration.getVerifyHubMetadata().getExpectedEntityId()).isEqualTo("https://signin.service.gov.uk"); assertThat(configuration.getMsaMetadata().getExpectedEntityId()).isEqualTo("some-msa-entity-id"); assertThat(configuration.getMsaMetadata().getUri().toString()).isEqualTo("some-msa-metadata-url"); assertThat(configuration.getServiceEntityIds()).containsExactly("http://some-service-entity-id"); assertThat(configuration.getSamlSigningKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_SIGNING_KEY)); assertThat(configuration.getSamlPrimaryEncryptionKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_ENCRYPTION_KEY)); assertThat(configuration.getSamlSecondaryEncryptionKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_ENCRYPTION_KEY)); assertThat(configuration.getClockSkew()).isEqualTo(Duration.standardSeconds(5)); }
@Test public void applicationShouldStartUpWithListOfServiceEntityIds() throws Exception { environmentHelper.setEnv(new HashMap<String, String>() {{ put("PORT", "50555"); put("LOG_LEVEL", "ERROR"); put("VERIFY_ENVIRONMENT", "COMPLIANCE_TOOL"); put("MSA_METADATA_URL", "some-msa-metadata-url"); put("MSA_ENTITY_ID", "some-msa-entity-id"); put("SERVICE_ENTITY_IDS", "[\"http://some-service-entity-id\",\"http://some-other-service-entity-id\"]"); put("SAML_SIGNING_KEY", TEST_RP_PRIVATE_SIGNING_KEY); put("SAML_PRIMARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("SAML_SECONDARY_ENCRYPTION_KEY", TEST_RP_PRIVATE_ENCRYPTION_KEY); put("CLOCK_SKEW", "PT5s"); }}); application.getTestSupport().before(); VerifyServiceProviderConfiguration configuration = application.getConfiguration(); assertThat(application.getLocalPort()).isEqualTo(50555); assertThat(((DefaultLoggingFactory) configuration.getLoggingFactory()).getLevel().toString()).isEqualTo("ERROR"); assertThat(configuration.getHubSsoLocation().toString()).isEqualTo(HubEnvironment.COMPLIANCE_TOOL.getSsoLocation().toString()); assertThat(configuration.getVerifyHubMetadata().getUri().toString()).isEqualTo(HubEnvironment.COMPLIANCE_TOOL.getMetadataUri().toString()); assertThat(configuration.getVerifyHubMetadata().getExpectedEntityId()).isEqualTo("https://signin.service.gov.uk"); assertThat(configuration.getMsaMetadata().getExpectedEntityId()).isEqualTo("some-msa-entity-id"); assertThat(configuration.getMsaMetadata().getUri().toString()).isEqualTo("some-msa-metadata-url"); assertThat(configuration.getServiceEntityIds()).containsExactly("http://some-service-entity-id", "http://some-other-service-entity-id"); assertThat(configuration.getSamlSigningKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_SIGNING_KEY)); assertThat(configuration.getSamlPrimaryEncryptionKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_ENCRYPTION_KEY)); assertThat(configuration.getSamlSecondaryEncryptionKey().getEncoded()).isEqualTo(decode(TEST_RP_PRIVATE_ENCRYPTION_KEY)); assertThat(configuration.getClockSkew()).isEqualTo(Duration.standardSeconds(5)); }
private LoggingReader initLogging(Configuration configuration) throws IOException { Set<File> mainFiles = Sets.newHashSet(); Set<File> archiveDirectories = Sets.newHashSet(); LoggingFactory loggingFactory = configuration.getLoggingFactory(); if ( loggingFactory instanceof DefaultLoggingFactory ) { for ( AppenderFactory appenderFactory : ((DefaultLoggingFactory)loggingFactory).getAppenders() ) { if ( appenderFactory instanceof FileAppenderFactory ) { FileAppenderFactory fileAppenderFactory = (FileAppenderFactory)appenderFactory; if ( fileAppenderFactory.getCurrentLogFilename() != null ) { mainFiles.add(new File(fileAppenderFactory.getCurrentLogFilename()).getCanonicalFile()); } if ( fileAppenderFactory.getArchivedLogFilenamePattern() != null ) { File archive = new File(fileAppenderFactory.getArchivedLogFilenamePattern()).getParentFile().getCanonicalFile(); archiveDirectories.add(archive); } } } } if ( (mainFiles.size() == 0) && (archiveDirectories.size() == 0) ) { log.warn("No log files found in config"); } return new LoggingReader(mainFiles, archiveDirectories); }
@BeforeClass public static void setUpServer() { DefaultLoggingFactory loggingFactory = (DefaultLoggingFactory) BITSHADOW_SERVER.getTestSupport().getConfiguration().getLoggingFactory(); loggingFactory.setLevel(Level.DEBUG); }
@Override @JsonProperty("logging") @Value.Default public LoggingFactory getLoggingFactory() { return new DefaultLoggingFactory(); }