Skip to content

Commit

Permalink
SmokeTestPlugins use certificate authorities (#67107)
Browse files Browse the repository at this point in the history
The client in the SmokeTestPluginsSslClientYamlTestSuiteIT uses
certificate_authorities in place of the keystore so it can be run when
`tests.fips.enable: true`.
  • Loading branch information
albertzaharovits committed Jan 6, 2021
1 parent 7e1da11 commit 6f19a5e
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class SmokeTestPluginsSslClientYamlTestSuiteIT extends ESClientYamlSuiteT

private static final String USER = "test_user";
private static final String PASS = "x-pack-test-password";
private static final String KEYSTORE_PASS = "testnode";

public SmokeTestPluginsSslClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
Expand All @@ -40,32 +39,31 @@ public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}

static Path keyStore;
static Path certificateAuthorities;

@BeforeClass
public static void getKeyStore() {
try {
keyStore = PathUtils.get(SmokeTestPluginsSslClientYamlTestSuiteIT.class.getResource("/testnode.jks").toURI());
certificateAuthorities = PathUtils.get(SmokeTestPluginsSslClientYamlTestSuiteIT.class.getResource("/testnode.crt").toURI());
} catch (URISyntaxException e) {
throw new ElasticsearchException("exception while reading the store", e);
}
if (!Files.exists(keyStore)) {
throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist.");
if (!Files.exists(certificateAuthorities)) {
throw new IllegalStateException("Keystore file [" + certificateAuthorities + "] does not exist.");
}
}

@AfterClass
public static void clearKeyStore() {
keyStore = null;
certificateAuthorities = null;
}

@Override
protected Settings restClientSettings() {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder()
.put(ThreadContext.PREFIX + ".Authorization", token)
.put(ESRestTestCase.TRUSTSTORE_PATH, keyStore)
.put(ESRestTestCase.TRUSTSTORE_PASSWORD, KEYSTORE_PASS)
.put(ESRestTestCase.CERTIFICATE_AUTHORITIES, certificateAuthorities)
.build();
}

Expand Down

0 comments on commit 6f19a5e

Please sign in to comment.