Search in sources :

Example 96 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class HttpConfigurationTest method tlsValidationFailsIfCertificateIsUnreadable.

@Test
public void tlsValidationFailsIfCertificateIsUnreadable() throws Exception {
    final File privateKey = temporaryFolder.newFile("graylog.key");
    final File certificate = temporaryFolder.newFile("graylog.crt");
    final Map<String, String> properties = ImmutableMap.of("http_enable_tls", "true", "http_tls_key_file", privateKey.getAbsolutePath(), "http_tls_cert_file", certificate.getAbsolutePath());
    assertThat(certificate.setReadable(false, false)).isTrue();
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Unreadable or missing HTTP X.509 certificate: ");
    jadConfig.setRepository(new InMemoryRepository(properties)).addConfigurationBean(configuration).process();
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 97 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class HttpConfigurationTest method testHttpBindAddressIsIPv6Address.

@Test
public void testHttpBindAddressIsIPv6Address() throws RepositoryException, ValidationException {
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_bind_address", "[2001:db8::1]:9000"))).addConfigurationBean(configuration).process();
    assertThat(configuration.getHttpBindAddress()).isEqualTo(HostAndPort.fromParts("[2001:db8::1]", 9000));
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 98 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class HttpConfigurationTest method testHttpBindAddressWildcard.

@Test
public void testHttpBindAddressWildcard() throws RepositoryException, ValidationException {
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_bind_address", "0.0.0.0:9000"))).addConfigurationBean(configuration).process();
    assertThat(configuration.getDefaultHttpUri()).isNotNull().isNotEqualTo(URI.create("http://0.0.0.0:9000"));
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 99 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class HttpConfigurationTest method testHttpBindAddressIsInvalidHostName.

@Test
@Ignore("Disabled test due to being unreliable (see https://github.com/Graylog2/graylog2-server/issues/4459)")
public void testHttpBindAddressIsInvalidHostName() throws RepositoryException, ValidationException {
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("this-does-not-exist-42: ");
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_bind_address", "this-does-not-exist-42"))).addConfigurationBean(configuration).process();
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 100 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class HttpConfigurationTest method testHttpPublishUriWithMissingTrailingSlash.

@Test
public void testHttpPublishUriWithMissingTrailingSlash() throws RepositoryException, ValidationException {
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_publish_uri", "http://www.example.com:12900/foo"))).addConfigurationBean(configuration).process();
    assertThat(configuration.getHttpPublishUri()).isEqualTo(URI.create("http://www.example.com:12900/foo/"));
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Aggregations

InMemoryRepository (com.github.joschi.jadconfig.repositories.InMemoryRepository)117 Test (org.junit.Test)115 JadConfig (com.github.joschi.jadconfig.JadConfig)86 File (java.io.File)25 ValidationException (com.github.joschi.jadconfig.ValidationException)5 Ignore (org.junit.Ignore)4 ElasticsearchConfiguration (org.graylog2.configuration.ElasticsearchConfiguration)3 Settings (org.elasticsearch.common.settings.Settings)2 RepositoryException (com.github.joschi.jadconfig.RepositoryException)1 GuavaConverterFactory (com.github.joschi.jadconfig.guava.GuavaConverterFactory)1 HashMap (java.util.HashMap)1