Search in sources :

Example 71 with InMemoryRepository

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

the class BaseConfigurationTest method testWebEndpointUriIsRelativeURI.

@Test
public void testWebEndpointUriIsRelativeURI() throws RepositoryException, ValidationException {
    validProperties.put("web_endpoint_uri", "/foo");
    Configuration configuration = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    assertEquals(URI.create("/foo"), configuration.getWebEndpointUri());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 72 with InMemoryRepository

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

the class BaseConfigurationTest method testRestTransportUriLocalhost.

@Test
public void testRestTransportUriLocalhost() throws RepositoryException, ValidationException {
    validProperties.put("rest_listen_uri", "http://127.0.0.1:12900");
    Configuration configuration = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    Assert.assertEquals("http://127.0.0.1:12900", configuration.getDefaultRestTransportUri().toString());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 73 with InMemoryRepository

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

the class BaseConfigurationTest method testGetRestUriScheme.

@Test
public void testGetRestUriScheme() throws RepositoryException, ValidationException, IOException {
    validProperties.put("rest_enable_tls", "false");
    final Configuration configWithoutTls = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configWithoutTls).process();
    validProperties.put("rest_enable_tls", "true");
    validProperties.put("rest_tls_key_file", temporaryFolder.newFile("graylog.key").getAbsolutePath());
    validProperties.put("rest_tls_cert_file", temporaryFolder.newFile("graylog.crt").getAbsolutePath());
    final Configuration configWithTls = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configWithTls).process();
    assertEquals("http", configWithoutTls.getRestUriScheme());
    assertEquals("https", configWithTls.getRestUriScheme());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 74 with InMemoryRepository

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

the class BaseConfigurationTest method testRestListenUriAndWebListenUriWithSameScheme.

@Test
public void testRestListenUriAndWebListenUriWithSameScheme() throws Exception {
    final File privateKey = temporaryFolder.newFile("graylog.key");
    final File certificate = temporaryFolder.newFile("graylog.crt");
    validProperties.put("rest_listen_uri", "https://127.0.0.1:8000/api");
    validProperties.put("rest_transport_uri", "https://127.0.0.1:8000/api");
    validProperties.put("rest_enable_tls", "true");
    validProperties.put("rest_tls_key_file", privateKey.getAbsolutePath());
    validProperties.put("rest_tls_cert_file", certificate.getAbsolutePath());
    validProperties.put("web_listen_uri", "https://127.0.0.1:8000/");
    validProperties.put("web_enable_tls", "true");
    org.graylog2.Configuration configuration = new org.graylog2.Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    assertThat(configuration.getRestListenUri()).hasScheme("https");
    assertThat(configuration.getRestTransportUri()).hasScheme("https");
    assertThat(configuration.getWebListenUri()).hasScheme("https");
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 75 with InMemoryRepository

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

the class BaseConfigurationTest method testRestTransportUriWithHttpDefaultPort.

@Test
public void testRestTransportUriWithHttpDefaultPort() throws RepositoryException, ValidationException {
    validProperties.put("rest_transport_uri", "http://example.com/");
    org.graylog2.Configuration configuration = new org.graylog2.Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    assertThat(configuration.getRestTransportUri()).hasPort(80);
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) 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