Skip to content

Commit 67ebccb

Browse files
committed
add password and username opensearch
1 parent 5dd0468 commit 67ebccb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

klass-api/src/main/java/no/ssb/klass/api/config/OpenSearchConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ public class OpenSearchConfig extends AbstractOpenSearchConfiguration {
1717
@Value("${opensearch.url}")
1818
private String opensearchUri;
1919

20+
@Value("${opensearch.username}")
21+
private String username;
22+
23+
@Value("${opensearch.password}")
24+
private String password;
25+
2026
@Override
2127
@Bean
2228
public RestHighLevelClient opensearchClient() {
2329
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
2430
.connectedTo(opensearchUri.replace("http://", "").replace("https://", ""))
31+
.withBasicAuth(username, password)
2532
.withConnectTimeout(20000)
2633
.withSocketTimeout(300000)
2734
.build();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
klass.env.search.elasticsearch.index=klass
22
opensearch.url=https://localhost:9200
3+
opensearch.username=admin
4+
opensearch.password=admin
35

klass-api/src/test/java/no/ssb/klass/api/applicationtest/RestApiSearchIntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ public class RestApiSearchIntegrationTest extends AbstractRestApiApplicationTest
4242
protected static final OpensearchContainer<?> opensearchContainer =
4343
new OpensearchContainer<>(DockerImageName.parse("opensearchproject/opensearch:2.11.0"))
4444
.withEnv("OPENSEARCH_JAVA_OPTS", "-Xms2g -Xmx2g")
45-
.withEnv("DISABLE_SECURITY_PLUGIN", "true")
4645
.withEnv("discovery.type", "single-node")
4746
.withReuse(true);
4847

4948
@DynamicPropertySource
5049
static void registerOpenSearchProperties(DynamicPropertyRegistry registry) {
5150
String uri = "http://" + opensearchContainer.getHost() + ":" + opensearchContainer.getMappedPort(9200);
5251
registry.add("opensearch.url", () -> uri);
52+
registry.add("opensearch.username", () -> "admin");
53+
registry.add("opensearch.password", () -> "admin");
5354
}
5455

5556
@Autowired

0 commit comments

Comments
 (0)