Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Feb 4, 2025
1 parent 513cdd2 commit 62d3cf4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/test/java/org/opensearch/timeseries/ODFERestTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,7 @@ public abstract class ODFERestTestCase extends OpenSearchRestTestCase {
private static final Logger LOG = (Logger) LogManager.getLogger(ODFERestTestCase.class);

protected boolean isHttps() {
boolean isHttps = Optional.ofNullable(System.getProperty("https")).map("true"::equalsIgnoreCase).orElse(false);
if (isHttps) {
// currently only external cluster is supported for security enabled testing
if (!Optional.ofNullable(System.getProperty("tests.rest.cluster")).isPresent()) {
throw new RuntimeException("cluster url should be provided for security enabled testing");
}
}

return isHttps;
return Optional.ofNullable(System.getProperty("https")).map("true"::equalsIgnoreCase).orElse(false);
}

@Override
Expand Down Expand Up @@ -147,12 +139,12 @@ protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOE
if (Objects.nonNull(keystore)) {
URI uri = null;
try {
uri = this.getClass().getClassLoader().getResource("security/sample.pem").toURI();
uri = this.getClass().getClassLoader().getResource("sample.pem").toURI();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
Path configPath = PathUtils.get(uri).getParent().toAbsolutePath();
return new SecureRestClientBuilder(settings, configPath).build();
return new SecureRestClientBuilder(settings, configPath, hosts).build();
} else {
configureHttpsClient(builder, settings);
builder.setStrictDeprecationMode(strictDeprecationMode);
Expand Down Expand Up @@ -214,6 +206,7 @@ protected static void configureHttpsClient(RestClientBuilder builder, Settings s
.ofNullable(System.getProperty("password"))
.orElseThrow(() -> new RuntimeException("password is missing"));
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();

final AuthScope anyScope = new AuthScope(null, -1);
credentialsProvider.setCredentials(anyScope, new UsernamePasswordCredentials(userName, password.toCharArray()));
try {
Expand Down

0 comments on commit 62d3cf4

Please sign in to comment.