Skip to content

Commit 0a3750f

Browse files
committed
Enable custom credentials for core REST tests
The core REST tests with security currently use a hardcoded username and password. This is not amenable to running these tests in scenarios where the user controls the creation of the cluster and owns the credentials for this cluster. This commit enables running the core REST tests with security with a custom username and password.
1 parent aa8aa0d commit 0a3750f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

x-pack/qa/core-rest-tests-with-security/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ integTestRunner {
1919
'cat.templates/10_basic/Sort templates',
2020
'cat.templates/10_basic/Multiple template',
2121
].join(',')
22+
23+
systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user')
24+
systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'x-pack-test-password')
2225
}
2326

2427
integTestCluster {
@@ -28,7 +31,10 @@ integTestCluster {
2831
setting 'xpack.ml.enabled', 'false'
2932
setting 'xpack.license.self_generated.type', 'trial'
3033
setupCommand 'setupDummyUser',
31-
'bin/elasticsearch-users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser'
34+
'bin/elasticsearch-users',
35+
'useradd', System.getProperty('tests.rest.cluster.username'),
36+
'-p', System.getProperty('tests.rest.cluster.password'),
37+
'-r', 'superuser'
3238
waitCondition = { node, ant ->
3339
File tmpFile = new File(node.cwd, 'wait.success')
3440
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow",

x-pack/qa/core-rest-tests-with-security/src/test/java/org/elasticsearch/xpack/security/CoreWithSecurityClientYamlTestSuiteIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6+
67
package org.elasticsearch.xpack.security;
78

89
import com.carrotsearch.randomizedtesting.annotations.Name;
910
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10-
1111
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
1212
import org.apache.lucene.util.TimeUnits;
1313
import org.elasticsearch.common.settings.SecureString;
@@ -16,13 +16,15 @@
1616
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1717
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
1818

19+
import java.util.Objects;
20+
1921
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
2022

2123
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs
2224
public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
2325

24-
private static final String USER = "test_user";
25-
private static final String PASS = "x-pack-test-password";
26+
private static final String USER = Objects.requireNonNull(System.getProperty("tests.rest.cluster.username"));
27+
private static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password"));
2628

2729
public CoreWithSecurityClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
2830
super(testCandidate);

0 commit comments

Comments
 (0)