Search in sources :

Example 6 with ClientConfiguration

use of org.springframework.data.elasticsearch.client.ClientConfiguration in project spring-boot by spring-projects.

the class ReactiveElasticsearchRestClientAutoConfigurationTests method whenUriHasUsernameOnlyThenDefaultAuthorizationHeaderHasUsernameAndEmptyPassword.

@Test
void whenUriHasUsernameOnlyThenDefaultAuthorizationHeaderHasUsernameAndEmptyPassword() {
    this.contextRunner.withPropertyValues("spring.elasticsearch.uris=http://user@localhost:9200").run((context) -> {
        ClientConfiguration clientConfiguration = context.getBean(ClientConfiguration.class);
        assertThat(clientConfiguration.getDefaultHeaders().get(HttpHeaders.AUTHORIZATION)).containsExactly("Basic " + Base64.getEncoder().encodeToString("user:".getBytes(StandardCharsets.UTF_8)));
    });
}
Also used : ClientConfiguration(org.springframework.data.elasticsearch.client.ClientConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

ClientConfiguration (org.springframework.data.elasticsearch.client.ClientConfiguration)6 Test (org.junit.jupiter.api.Test)5 InetSocketAddress (java.net.InetSocketAddress)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)1 Bean (org.springframework.context.annotation.Bean)1