Skip to content

Commit

Permalink
Fix elastic credentials check: Fixes #2047
Browse files Browse the repository at this point in the history
  • Loading branch information
johnaohara authored Oct 1, 2024
1 parent 1185d9e commit 7845086
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.hyperfoil.tools.horreum.api.data.datastore;

import static java.util.Objects.requireNonNullElse;

import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

Expand Down Expand Up @@ -42,11 +44,16 @@ public String getMaskedSecrets() {

@Override
public String validateConfig() {
if ("".equals(apiKey) && ("".equals(username) || "".equals(password))) {

String _apiKey = requireNonNullElse(apiKey, "");
String _username = requireNonNullElse(username, "");
String _password = requireNonNullElse(password, "");

if ("".equals(_apiKey) && ("".equals(_username) || "".equals(_password))) {
return "Either apiKey or username and password must be set";
}

if (!"".equals(apiKey) && !("".equals(username) || "".equals(password))) {
if (!"".equals(_apiKey) && !("".equals(_username) || "".equals(_password))) {
return "Only apiKey or username and password can be set";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private TestConfig createNewTestAndDatastores(TestInfo info) {

ElasticsearchDatastoreConfig elasticConfig = new ElasticsearchDatastoreConfig();
elasticConfig.url = hosts.get().get(0);
elasticConfig.apiKey = apiKey.orElse("");
elasticConfig.apiKey = apiKey.orElse("123");

newDatastore.config = mapper.valueToTree(elasticConfig);

Expand Down

0 comments on commit 7845086

Please sign in to comment.