Search in sources :

Example 91 with InMemoryRepository

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

the class MongoDbConfigurationTest method validateSucceedsWithIPv6Address.

@Test
public void validateSucceedsWithIPv6Address() throws Exception {
    MongoDbConfiguration configuration = new MongoDbConfiguration();
    final Map<String, String> properties = singletonMap("mongodb_uri", "mongodb://[2001:DB8::DEAD:BEEF:CAFE:BABE]:1234,127.0.0.1:5678/TEST");
    new JadConfig(new InMemoryRepository(properties), configuration).process();
    assertEquals("mongodb://[2001:DB8::DEAD:BEEF:CAFE:BABE]:1234,127.0.0.1:5678/TEST", configuration.getMongoClientURI().toString());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 92 with InMemoryRepository

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

the class HttpConfigurationTest method tlsValidationFailsIfPrivateKeyIsUnreadable.

@Test
public void tlsValidationFailsIfPrivateKeyIsUnreadable() 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(privateKey.setReadable(false, false)).isTrue();
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Unreadable or missing HTTP private key: ");
    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 93 with InMemoryRepository

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

the class HttpConfigurationTest method testHttpPublishUriIsRelativeURI.

@Test
public void testHttpPublishUriIsRelativeURI() throws RepositoryException, ValidationException {
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Parameter http_publish_uri should be an absolute URI (found /foo)");
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_publish_uri", "/foo"))).addConfigurationBean(configuration).process();
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 94 with InMemoryRepository

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

the class HttpConfigurationTest method testHttpBindAddressWithDefaultPort.

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

Example 95 with InMemoryRepository

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

the class HttpConfigurationTest method testHttpBindAddressIsInvalidIPv6Address.

@Test
@Ignore("Disabled test due to being unreliable (see https://github.com/Graylog2/graylog2-server/issues/4459)")
public void testHttpBindAddressIsInvalidIPv6Address() throws RepositoryException, ValidationException {
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Possible bracketless IPv6 literal: ff$$::1");
    jadConfig.setRepository(new InMemoryRepository(ImmutableMap.of("http_bind_address", "ff$$::1"))).addConfigurationBean(configuration).process();
}
Also used : InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Ignore(org.junit.Ignore) 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