Ensure CI is run in FIPS 140 approved only mode (#66804)

We were depending on the BouncyCastle FIPS own mechanics to set
itself in approved only mode since we run with the Security
Manager enabled. The check during startup seems to happen before we
set our restrictive SecurityManager though in
org.elasticsearch.bootstrap.Elasticsearch , and this means that
BCFIPS would not be in approved only mode, unless explicitly
configured so.

This commit sets the appropriate JVM property to explicitly set
BCFIPS in approved only mode in CI and adds tests to ensure that we
will be running with BCFIPS in approved only mode when we expect to.
It also sets xpack.security.fips_mode.enabled to true for all test clusters
used in fips mode and sets the distribution to the default one. It adds a
password to the elasticsearch keystore for all test clusters that run in fips
mode.
Moreover, it changes a few unit tests where we would use bcrypt even in
FIPS 140 mode. These would still pass since we are bundling our own
bcrypt implementation, but are now changed to use FIPS 140 approved
algorithms instead for better coverage.

It also addresses a number of tests that would fail in approved only mode
Mainly:

    Tests that use PBKDF2 with a password less than 112 bits (14char). We
    elected to change the passwords used everywhere to be at least 14
    characters long instead of mandating
    the use of pbkdf2_stretch because both pbkdf2 and
    pbkdf2_stretch are supported and allowed in fips mode and it makes sense
    to test with both. We could possibly figure out the password algorithm used
    for each test and adjust password length accordingly only for pbkdf2 but
    there is little value in that. It's good practice to use strong passwords so if
    our docs and tests use longer passwords, then it's for the best. The approach
    is brittle as there is no guarantee that the next test that will be added won't
    use a short password, so we add some testing documentation too.
    This leaves us with a possible coverage gap since we do support passwords
    as short as 6 characters but we only test with > 14 chars but the
    validation itself was not tested even before. Tests can be added in a followup,
    outside of fips related context.

    Tests that use a PKCS12 keystore and were not already muted.

    Tests that depend on running test clusters with a basic license or
    using the OSS distribution as FIPS 140 support is not available in
    neither of these.

Finally, it adds some information around FIPS 140 testing in our testing
documentation reference so that developers can hopefully keep in
mind fips 140 related intricacies when writing/changing docs.
This commit is contained in:
Ioannis Kakavas 2020-12-24 15:35:28 +02:00 committed by GitHub
parent d231202eeb
commit c0b24df307
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
176 changed files with 1107 additions and 617 deletions

View file

@ -584,6 +584,81 @@ repository without fetching latest. For these use cases, you can set the system
property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip
fetching the latest from the remote. fetching the latest from the remote.
== Testing in FIPS 140-2 mode
We have a CI matrix job that periodically runs all our tests with the JVM configured
to be FIPS 140-2 compliant with the use of the BouncyCastle FIPS approved Security Provider.
FIPS 140-2 imposes certain requirements that affect how our tests should be set up or what
can be tested. This section summarizes what one needs to take into consideration so that
tests won't fail when run in fips mode.
=== Muting tests in FIPS 140-2 mode
If the following limitations cannot be observed, or there is a need to actually test some use
case that is not available/allowed in fips mode, the test can be muted. For unit tests or Java
rest tests one can use
------------------------------------------------
assumeFalse("Justification why this cannot be run in FIPS mode", inFipsJvm());
------------------------------------------------
For specific YAML rest tests one can use
------------------------------------------------
- skip:
features: fips_140
reason: "Justification why this cannot be run in FIPS mode"
------------------------------------------------
For disabling entire types of tests for subprojects, one can use for example:
------------------------------------------------
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
------------------------------------------------
in `build.gradle`.
=== Limitations
The following should be taken into consideration when writing new tests or adjusting existing ones:
==== TLS
`JKS` and `PKCS#12` keystores cannot be used in FIPS mode. If the test depends on being able to use
a keystore, it can be muted when needed ( see `ESTestCase#inFipsJvm` ). Alternatively, one can use
PEM encoded files for keys and certificates for the tests or for setting up TLS in a test cluster.
Also, when in FIPS 140 mode, hostname verification for TLS cannot be turned off so if you are using
`*.verification_mode: none` , you'd need to mute the test in fips mode.
When using TLS, ensure that private keys used are longer than 2048 bits, or mute the test in fips mode.
==== Password hashing algorithm
Test clusters are configured with `xpack.security.fips_mode.enabled` set to true. This means that
FIPS 140-2 related bootstrap checks are enabled and the test cluster will fail to form if the
password hashing algorithm is set to something else than a PBKDF2 based one. You can delegate the choice
of algorithm to i.e. `SecurityIntegTestCase#getFastStoredHashAlgoForTests` if you don't mind the
actual algorithm used, or depend on default values for the test cluster nodes.
==== Password length
While using `pbkdf2` as the password hashing algorithm, FIPS 140-2 imposes a requirement that
passwords are longer than 14 characters. You can either ensure that all test user passwords in
your test are longer than 14 characters and use i.e. `SecurityIntegTestCase#getFastStoredHashAlgoForTests`
to randomly select a hashing algorithm, or use `pbkdf2_stretch` that doesn't have the same
limitation.
==== Keystore Password
In FIPS 140-2 mode, the elasticsearch keystore needs to be password protected with a password
of appropriate length. This is handled automatically in `fips.gradle` and the keystore is unlocked
on startup by the test clusters tooling in order to have secure settings available. However, you
might need to take into consideration that the keystore is password-protected with `keystore-password`
if you need to interact with it in a test.
== How to write good tests? == How to write good tests?
=== Base classes for test cases === Base classes for test cases

View file

@ -184,7 +184,17 @@ tasks.register("verifyVersions") {
*/ */
boolean bwc_tests_enabled = true boolean bwc_tests_enabled = true
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */ String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
/*
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable
* all bwc testing in fips mode.
*/
if ( BuildParams.inFipsJvm ) {
bwc_tests_enabled = false
bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/issues/66772"
}
if (bwc_tests_enabled == false) { if (bwc_tests_enabled == false) {
if (bwc_tests_disabled_issue.isEmpty()) { if (bwc_tests_disabled_issue.isEmpty()) {
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false") throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

View file

@ -523,7 +523,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) { if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) {
logToProcessStdout("Adding " + keystoreSettings.size() + " keystore settings and " + keystoreFiles.size() + " keystore files"); logToProcessStdout("Adding " + keystoreSettings.size() + " keystore settings and " + keystoreFiles.size() + " keystore files");
keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), "add", "-x", key)); keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), "add", key));
for (Map.Entry<String, File> entry : keystoreFiles.entrySet()) { for (Map.Entry<String, File> entry : keystoreFiles.entrySet()) {
File file = entry.getValue(); File file = entry.getValue();

View file

@ -72,14 +72,14 @@ File pkiTrustCert = file("./src/test/resources/org/elasticsearch/client/security
tasks.named("integTest").configure { tasks.named("integTest").configure {
systemProperty 'tests.rest.async', 'false' systemProperty 'tests.rest.async', 'false'
systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user') systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user')
systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-password') systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-user-password')
} }
// Requires https://github.com/elastic/elasticsearch/pull/64403 to have this moved to task avoidance api. // Requires https://github.com/elastic/elasticsearch/pull/64403 to have this moved to task avoidance api.
TaskProvider<RestIntegTestTask> asyncIntegTest = tasks.register("asyncIntegTest", RestIntegTestTask) { TaskProvider<RestIntegTestTask> asyncIntegTest = tasks.register("asyncIntegTest", RestIntegTestTask) {
systemProperty 'tests.rest.async', 'true' systemProperty 'tests.rest.async', 'true'
systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user') systemProperty 'tests.rest.cluster.username', System.getProperty('tests.rest.cluster.username', 'test_user')
systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-password') systemProperty 'tests.rest.cluster.password', System.getProperty('tests.rest.cluster.password', 'test-user-password')
} }
tasks.named("check").configure { tasks.named("check").configure {
@ -110,7 +110,7 @@ testClusters.all {
keystore 'xpack.security.transport.ssl.truststore.secure_password', 'testnode' keystore 'xpack.security.transport.ssl.truststore.secure_password', 'testnode'
extraConfigFile 'roles.yml', file('roles.yml') extraConfigFile 'roles.yml', file('roles.yml')
user username: System.getProperty('tests.rest.cluster.username', 'test_user'), user username: System.getProperty('tests.rest.cluster.username', 'test_user'),
password: System.getProperty('tests.rest.cluster.password', 'test-password'), password: System.getProperty('tests.rest.cluster.password', 'test-user-password'),
role: System.getProperty('tests.rest.cluster.role', 'admin') role: System.getProperty('tests.rest.cluster.role', 'admin')
user username: 'admin_user', password: 'admin-password' user username: 'admin_user', password: 'admin-password'

View file

@ -222,7 +222,7 @@ public class SecurityIT extends ESRestHighLevelClientTestCase {
} }
private static PutUserRequest randomPutUserRequest(User user, boolean enabled) { private static PutUserRequest randomPutUserRequest(User user, boolean enabled) {
final char[] password = randomAlphaOfLengthBetween(6, 10).toCharArray(); final char[] password = randomAlphaOfLengthBetween(14, 19).toCharArray();
return new PutUserRequest(user, password, enabled, RefreshPolicy.IMMEDIATE); return new PutUserRequest(user, password, enabled, RefreshPolicy.IMMEDIATE);
} }

View file

@ -845,7 +845,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
Integer remotePort = host.getPort(); Integer remotePort = host.getPort();
String remoteHost = host.getHostName(); String remoteHost = host.getHostName();
String user = "test_user"; String user = "test_user";
String password = "test-password"; String password = "test-user-password";
// tag::reindex-request-remote // tag::reindex-request-remote
request.setRemoteInfo( request.setRemoteInfo(

View file

@ -157,9 +157,9 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
public void testGetUsers() throws Exception { public void testGetUsers() throws Exception {
final RestHighLevelClient client = highLevelClient(); final RestHighLevelClient client = highLevelClient();
String[] usernames = new String[] {"user1", "user2", "user3"}; String[] usernames = new String[] {"user1", "user2", "user3"};
addUser(client, usernames[0], randomAlphaOfLengthBetween(6, 10)); addUser(client, usernames[0], randomAlphaOfLengthBetween(14, 18));
addUser(client, usernames[1], randomAlphaOfLengthBetween(6, 10)); addUser(client, usernames[1], randomAlphaOfLengthBetween(14, 18));
addUser(client, usernames[2], randomAlphaOfLengthBetween(6, 10)); addUser(client, usernames[2], randomAlphaOfLengthBetween(14, 18));
{ {
//tag::get-users-request //tag::get-users-request
GetUsersRequest request = new GetUsersRequest(usernames[0]); GetUsersRequest request = new GetUsersRequest(usernames[0]);
@ -251,7 +251,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
{ {
//tag::put-user-password-request //tag::put-user-password-request
char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
User user = new User("example", Collections.singletonList("superuser")); User user = new User("example", Collections.singletonList("superuser"));
PutUserRequest request = PutUserRequest.withPassword(user, password, true, RefreshPolicy.NONE); PutUserRequest request = PutUserRequest.withPassword(user, password, true, RefreshPolicy.NONE);
//end::put-user-password-request //end::put-user-password-request
@ -270,7 +270,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
byte[] salt = new byte[32]; byte[] salt = new byte[32];
// no need for secure random in a test; it could block and would not be reproducible anyway // no need for secure random in a test; it could block and would not be reproducible anyway
random().nextBytes(salt); random().nextBytes(salt);
char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
User user = new User("example2", Collections.singletonList("superuser")); User user = new User("example2", Collections.singletonList("superuser"));
//tag::put-user-hash-request //tag::put-user-hash-request
@ -326,7 +326,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
public void testDeleteUser() throws Exception { public void testDeleteUser() throws Exception {
RestHighLevelClient client = highLevelClient(); RestHighLevelClient client = highLevelClient();
addUser(client, "testUser", "testPassword"); addUser(client, "testUser", "testUserPassword");
{ {
// tag::delete-user-request // tag::delete-user-request
@ -566,7 +566,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
public void testEnableUser() throws Exception { public void testEnableUser() throws Exception {
RestHighLevelClient client = highLevelClient(); RestHighLevelClient client = highLevelClient();
char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
User enable_user = new User("enable_user", Collections.singletonList("superuser")); User enable_user = new User("enable_user", Collections.singletonList("superuser"));
PutUserRequest putUserRequest = PutUserRequest.withPassword(enable_user, password, true, RefreshPolicy.IMMEDIATE); PutUserRequest putUserRequest = PutUserRequest.withPassword(enable_user, password, true, RefreshPolicy.IMMEDIATE);
PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT); PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT);
@ -611,7 +611,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
public void testDisableUser() throws Exception { public void testDisableUser() throws Exception {
RestHighLevelClient client = highLevelClient(); RestHighLevelClient client = highLevelClient();
char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
User disable_user = new User("disable_user", Collections.singletonList("superuser")); User disable_user = new User("disable_user", Collections.singletonList("superuser"));
PutUserRequest putUserRequest = PutUserRequest.withPassword(disable_user, password, true, RefreshPolicy.IMMEDIATE); PutUserRequest putUserRequest = PutUserRequest.withPassword(disable_user, password, true, RefreshPolicy.IMMEDIATE);
PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT); PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT);
@ -1183,8 +1183,9 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
public void testChangePassword() throws Exception { public void testChangePassword() throws Exception {
RestHighLevelClient client = highLevelClient(); RestHighLevelClient client = highLevelClient();
char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
char[] newPassword = new char[]{'n', 'e', 'w', 'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; char[] newPassword =
new char[]{'n', 'e', 'w', '-', 't', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
User user = new User("change_password_user", Collections.singletonList("superuser"), Collections.emptyMap(), null, null); User user = new User("change_password_user", Collections.singletonList("superuser"), Collections.emptyMap(), null, null);
PutUserRequest putUserRequest = PutUserRequest.withPassword(user, password, true, RefreshPolicy.NONE); PutUserRequest putUserRequest = PutUserRequest.withPassword(user, password, true, RefreshPolicy.NONE);
PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT); PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT);
@ -1403,14 +1404,14 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
{ {
// Setup user // Setup user
User token_user = new User("token_user", Collections.singletonList("kibana_user")); User token_user = new User("token_user", Collections.singletonList("kibana_user"));
PutUserRequest putUserRequest = PutUserRequest.withPassword(token_user, "password".toCharArray(), true, PutUserRequest putUserRequest = PutUserRequest.withPassword(token_user, "test-user-password".toCharArray(), true,
RefreshPolicy.IMMEDIATE); RefreshPolicy.IMMEDIATE);
PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT); PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT);
assertTrue(putUserResponse.isCreated()); assertTrue(putUserResponse.isCreated());
} }
{ {
// tag::create-token-password-request // tag::create-token-password-request
final char[] password = new char[]{'p', 'a', 's', 's', 'w', 'o', 'r', 'd'}; final char[] password = new char[]{'t', 'e', 's', 't', '-', 'u','s','e','r','-','p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
CreateTokenRequest createTokenRequest = CreateTokenRequest.passwordGrant("token_user", password); CreateTokenRequest createTokenRequest = CreateTokenRequest.passwordGrant("token_user", password);
// end::create-token-password-request // end::create-token-password-request
@ -1480,7 +1481,7 @@ public class SecurityDocumentationIT extends ESRestHighLevelClientTestCase {
String refreshToken; String refreshToken;
{ {
// Setup users // Setup users
final char[] password = "password".toCharArray(); final char[] password = "test-user-password".toCharArray();
User user = new User("user", Collections.singletonList("kibana_user")); User user = new User("user", Collections.singletonList("kibana_user"));
PutUserRequest putUserRequest = PutUserRequest.withPassword(user, password, true, RefreshPolicy.IMMEDIATE); PutUserRequest putUserRequest = PutUserRequest.withPassword(user, password, true, RefreshPolicy.IMMEDIATE);
PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT); PutUserResponse putUserResponse = client.security().putUser(putUserRequest, RequestOptions.DEFAULT);

View file

@ -359,7 +359,7 @@ public class RestClientDocumentation {
final CredentialsProvider credentialsProvider = final CredentialsProvider credentialsProvider =
new BasicCredentialsProvider(); new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("user", "password")); new UsernamePasswordCredentials("user", "test-user-password"));
RestClientBuilder builder = RestClient.builder( RestClientBuilder builder = RestClient.builder(
new HttpHost("localhost", 9200)) new HttpHost("localhost", 9200))
@ -378,7 +378,7 @@ public class RestClientDocumentation {
final CredentialsProvider credentialsProvider = final CredentialsProvider credentialsProvider =
new BasicCredentialsProvider(); new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("user", "password")); new UsernamePasswordCredentials("user", "test-user-password"));
RestClientBuilder builder = RestClient.builder( RestClientBuilder builder = RestClient.builder(
new HttpHost("localhost", 9200)) new HttpHost("localhost", 9200))

View file

@ -215,13 +215,17 @@ def createAndSetWritable(Object... locations) {
} }
} }
tasks.register("copyKeystore", Sync) { tasks.register("copyNodeKeyMaterial", Sync) {
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .files(
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt'
)
into "${buildDir}/certs" into "${buildDir}/certs"
doLast { doLast {
file("${buildDir}/certs").setReadable(true, false) file("${buildDir}/certs").setReadable(true, false)
file("${buildDir}/certs/testnode.jks").setReadable(true, false) file("${buildDir}/certs/testnode.pem").setReadable(true, false)
file("${buildDir}/certs/testnode.crt").setReadable(true, false)
} }
} }
@ -241,7 +245,7 @@ elasticsearch_distributions {
tasks.named("preProcessFixture").configure { tasks.named("preProcessFixture").configure {
dependsOn elasticsearch_distributions.docker_default, elasticsearch_distributions.docker_oss dependsOn elasticsearch_distributions.docker_default, elasticsearch_distributions.docker_oss
dependsOn "copyKeystore" dependsOn "copyNodeKeyMaterial"
doLast { doLast {
// tests expect to have an empty repo // tests expect to have an empty repo
project.delete( project.delete(
@ -261,7 +265,10 @@ tasks.named("preProcessFixture").configure {
tasks.named("processTestResources").configure { tasks.named("processTestResources").configure {
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .files(
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt'
)
} }
tasks.register("integTest", Test) { tasks.register("integTest", Test) {

View file

@ -23,14 +23,17 @@ services:
- xpack.security.audit.enabled=true - xpack.security.audit.enabled=true
- xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.file.file1.order=0
- xpack.security.authc.realms.native.native1.order=1 - xpack.security.authc.realms.native.native1.order=1
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.security.http.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.http.ssl.verification_mode=certificate - xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial - xpack.license.self_generated.type=trial
volumes: volumes:
- ./build/repo:/tmp/es-repo - ./build/repo:/tmp/es-repo
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
- ./build/certs/testnode.crt:/usr/share/elasticsearch/config/testnode.crt
- ./build/logs/default-1:/usr/share/elasticsearch/logs - ./build/logs/default-1:/usr/share/elasticsearch/logs
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh
ports: ports:
@ -62,14 +65,17 @@ services:
- xpack.security.audit.enabled=true - xpack.security.audit.enabled=true
- xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.file.file1.order=0
- xpack.security.authc.realms.native.native1.order=1 - xpack.security.authc.realms.native.native1.order=1
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.security.http.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.http.ssl.verification_mode=certificate - xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial - xpack.license.self_generated.type=trial
volumes: volumes:
- ./build/repo:/tmp/es-repo - ./build/repo:/tmp/es-repo
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
- ./build/certs/testnode.crt:/usr/share/elasticsearch/config/testnode.crt
- ./build/logs/default-2:/usr/share/elasticsearch/logs - ./build/logs/default-2:/usr/share/elasticsearch/logs
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh
ports: ports:

View file

@ -2,6 +2,6 @@
cd /usr/share/elasticsearch/bin/ cd /usr/share/elasticsearch/bin/
./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true ./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true
echo "testnode" > /tmp/password echo "testnode" > /tmp/password
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.keystore.secure_password' cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.secure_key_passphrase'
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.keystore.secure_password' cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.secure_key_passphrase'
/usr/local/bin/docker-entrypoint.sh | tee > /usr/share/elasticsearch/logs/console.log /usr/local/bin/docker-entrypoint.sh | tee /usr/share/elasticsearch/logs/console.log

View file

@ -45,7 +45,6 @@ public class DockerYmlTestSuiteIT extends ESClientYamlSuiteTestCase {
private static final String USER = "x_pack_rest_user"; private static final String USER = "x_pack_rest_user";
private static final String PASS = "x-pack-test-password"; private static final String PASS = "x-pack-test-password";
private static final String KEYSTORE_PASS = "testnode";
public DockerYmlTestSuiteIT(ClientYamlTestCandidate testCandidate) { public DockerYmlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
super(testCandidate); super(testCandidate);
@ -103,23 +102,24 @@ public class DockerYmlTestSuiteIT extends ESClientYamlSuiteTestCase {
client().performRequest(health); client().performRequest(health);
} }
static Path keyStore; static Path trustedCertFile;
@BeforeClass @BeforeClass
public static void getKeyStore() { public static void getTrustedCert() {
try { try {
keyStore = PathUtils.get(DockerYmlTestSuiteIT.class.getResource("/testnode.jks").toURI()); trustedCertFile = PathUtils.get(DockerYmlTestSuiteIT.class.getResource("/testnode.crt").toURI());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new ElasticsearchException("exception while reading the store", e); throw new ElasticsearchException("exception while reading the certificate", e);
} }
if (Files.exists(keyStore) == false) {
throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); if (Files.exists(trustedCertFile) == false) {
throw new IllegalStateException("Certificate file [" + trustedCertFile + "] does not exist.");
} }
} }
@AfterClass @AfterClass
public static void clearKeyStore() { public static void clearTrustedCert() {
keyStore = null; trustedCertFile = null;
} }
@Override @Override
@ -130,8 +130,7 @@ public class DockerYmlTestSuiteIT extends ESClientYamlSuiteTestCase {
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder() return Settings.builder()
.put(ThreadContext.PREFIX + ".Authorization", token) .put(ThreadContext.PREFIX + ".Authorization", token)
.put(ESRestTestCase.TRUSTSTORE_PATH, keyStore) .put(ESRestTestCase.CERTIFICATE_AUTHORITIES, trustedCertFile)
.put(ESRestTestCase.TRUSTSTORE_PASSWORD, KEYSTORE_PASS)
.build(); .build();
} }

View file

@ -55,13 +55,13 @@ public class HasPasswordKeyStoreCommandTests extends KeyStoreCommandTestCase {
} }
public void testSucceedsWhenKeystoreHasPassword() throws Exception { public void testSucceedsWhenKeystoreHasPassword() throws Exception {
createKeystore("password"); createKeystore("keystore-password");
String output = execute(); String output = execute();
assertThat(output, containsString("Keystore is password-protected")); assertThat(output, containsString("Keystore is password-protected"));
} }
public void testSilentSucceedsWhenKeystoreHasPassword() throws Exception { public void testSilentSucceedsWhenKeystoreHasPassword() throws Exception {
createKeystore("password"); createKeystore("keystre-password");
String output = execute("--silent"); String output = execute("--silent");
assertThat(output, is(emptyString())); assertThat(output, is(emptyString()));
} }

View file

@ -55,7 +55,7 @@ testClusters.integTest {
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'
setting 'indices.lifecycle.history_index_enabled', 'false' setting 'indices.lifecycle.history_index_enabled', 'false'
systemProperty 'es.rollup_v2_feature_flag_enabled', 'true' systemProperty 'es.rollup_v2_feature_flag_enabled', 'true'
keystorePassword 's3cr3t' keystorePassword 'keystore-password'
} }
// enable regexes in painless so our tests don't complain about example snippets that use them // enable regexes in painless so our tests don't complain about example snippets that use them
@ -104,7 +104,7 @@ ext.docsFileTree = fileTree(projectDir) {
exclude 'README.asciidoc' exclude 'README.asciidoc'
// Broken code snippet tests // Broken code snippet tests
exclude 'reference/graph/explore.asciidoc' exclude 'reference/graph/explore.asciidoc'
if (Boolean.parseBoolean(System.getProperty("tests.fips.enabled"))) { if (BuildParams.inFipsJvm) {
// We don't install/support this plugin in FIPS 140 // We don't install/support this plugin in FIPS 140
exclude 'plugins/ingest-attachment.asciidoc' exclude 'plugins/ingest-attachment.asciidoc'
// We can't conditionally control output, this would be missing the ingest-attachment plugin // We can't conditionally control output, this would be missing the ingest-attachment plugin

View file

@ -57,11 +57,11 @@ node of the cluster:
-------------------------------------------------- --------------------------------------------------
POST _nodes/reload_secure_settings POST _nodes/reload_secure_settings
{ {
"secure_settings_password":"s3cr3t" "secure_settings_password":"keystore-password"
} }
POST _nodes/nodeId1,nodeId2/reload_secure_settings POST _nodes/nodeId1,nodeId2/reload_secure_settings
{ {
"secure_settings_password":"s3cr3t" "secure_settings_password":"keystore-password"
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:node] // TEST[setup:node]

View file

@ -35,7 +35,7 @@ using the `bin/elasticsearch-keystore add` command, call:
---- ----
POST _nodes/reload_secure_settings POST _nodes/reload_secure_settings
{ {
"secure_settings_password": "s3cr3t" <1> "secure_settings_password": "keystore-password" <1>
} }
---- ----
// NOTCONSOLE // NOTCONSOLE

View file

@ -1,5 +1,6 @@
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.elasticsearch.gradle.info.BuildParams import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.TestDistribution
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
// Common config when running with a FIPS-140 runtime JVM // Common config when running with a FIPS-140 runtime JVM
@ -58,6 +59,7 @@ if (BuildParams.inFipsJvm) {
} }
} }
testClusters.all { testClusters.all {
setTestDistribution(TestDistribution.DEFAULT)
extraConfigFile "fips_java.security", fipsSecurity extraConfigFile "fips_java.security", fipsSecurity
extraConfigFile "fips_java.policy", fipsPolicy extraConfigFile "fips_java.policy", fipsPolicy
extraConfigFile "cacerts.bcfks", fipsTrustStore extraConfigFile "cacerts.bcfks", fipsTrustStore
@ -67,6 +69,10 @@ if (BuildParams.inFipsJvm) {
systemProperty 'javax.net.ssl.trustStorePassword', 'password' systemProperty 'javax.net.ssl.trustStorePassword', 'password'
systemProperty 'javax.net.ssl.keyStorePassword', 'password' systemProperty 'javax.net.ssl.keyStorePassword', 'password'
systemProperty 'javax.net.ssl.keyStoreType', 'BCFKS' systemProperty 'javax.net.ssl.keyStoreType', 'BCFKS'
systemProperty 'org.bouncycastle.fips.approved_only', 'true'
setting 'xpack.security.fips_mode.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
keystorePassword 'keystore-password'
} }
} }
project.tasks.withType(Test).configureEach { Test task -> project.tasks.withType(Test).configureEach { Test task ->
@ -79,6 +85,7 @@ if (BuildParams.inFipsJvm) {
task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", fipsSecurity)) task.systemProperty('java.security.properties', String.format(Locale.ROOT, "=%s", fipsSecurity))
task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", fipsPolicy)) task.systemProperty('java.security.policy', String.format(Locale.ROOT, "=%s", fipsPolicy))
task.systemProperty('javax.net.ssl.trustStore', fipsTrustStore) task.systemProperty('javax.net.ssl.trustStore', fipsTrustStore)
task.systemProperty('org.bouncycastle.fips.approved_only', 'true')
} }
} }
} }

View file

@ -100,6 +100,7 @@ public class SslConfigurationLoaderTests extends ESTestCase {
} }
public void testLoadTrustFromPkcs12() { public void testLoadTrustFromPkcs12() {
assumeFalse("Can't use JKS/PKCS12 keystores in a FIPS JVM", inFipsJvm());
final Settings.Builder builder = Settings.builder().put("test.ssl.truststore.path", "ca-all/ca.p12"); final Settings.Builder builder = Settings.builder().put("test.ssl.truststore.path", "ca-all/ca.p12");
if (randomBoolean()) { if (randomBoolean()) {
builder.put("test.ssl.truststore.password", "p12-pass"); builder.put("test.ssl.truststore.password", "p12-pass");
@ -122,6 +123,7 @@ public class SslConfigurationLoaderTests extends ESTestCase {
} }
public void testLoadTrustFromJKS() { public void testLoadTrustFromJKS() {
assumeFalse("Can't use JKS/PKCS12 keystores in a FIPS JVM", inFipsJvm());
final Settings.Builder builder = Settings.builder().put("test.ssl.truststore.path", "ca-all/ca.jks"); final Settings.Builder builder = Settings.builder().put("test.ssl.truststore.path", "ca-all/ca.jks");
if (randomBoolean()) { if (randomBoolean()) {
builder.put("test.ssl.truststore.password", "jks-pass"); builder.put("test.ssl.truststore.password", "jks-pass");
@ -167,6 +169,7 @@ public class SslConfigurationLoaderTests extends ESTestCase {
} }
public void testLoadKeysFromPKCS12() { public void testLoadKeysFromPKCS12() {
assumeFalse("Can't use JKS/PKCS12 keystores in a FIPS JVM", inFipsJvm());
final Settings.Builder builder = Settings.builder() final Settings.Builder builder = Settings.builder()
.put("test.ssl.keystore.path", "cert-all/certs.p12"); .put("test.ssl.keystore.path", "cert-all/certs.p12");
if (randomBoolean()) { if (randomBoolean()) {

View file

@ -78,6 +78,7 @@ public class StoreTrustConfigTests extends ESTestCase {
} }
public void testIncorrectPasswordFailsWithMeaningfulMessage() throws Exception { public void testIncorrectPasswordFailsWithMeaningfulMessage() throws Exception {
assumeFalse("Can't use JKS/PKCS12 keystores in a FIPS JVM", inFipsJvm());
final Path ks = getDataPath("/certs/ca1/ca.p12"); final Path ks = getDataPath("/certs/ca1/ca.p12");
final StoreTrustConfig trustConfig = new StoreTrustConfig(ks, new char[0], "PKCS12", DEFAULT_ALGORITHM); final StoreTrustConfig trustConfig = new StoreTrustConfig(ks, new char[0], "PKCS12", DEFAULT_ALGORITHM);
assertThat(trustConfig.getDependentFiles(), Matchers.containsInAnyOrder(ks)); assertThat(trustConfig.getDependentFiles(), Matchers.containsInAnyOrder(ks));

View file

@ -18,6 +18,8 @@
*/ */
apply plugin: 'elasticsearch.yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-test'
import org.elasticsearch.gradle.info.BuildParams
esplugin { esplugin {
description 'Placeholder plugin for geospatial features in ES. only registers geo_shape field mapper for now' description 'Placeholder plugin for geospatial features in ES. only registers geo_shape field mapper for now'
classname 'org.elasticsearch.geo.GeoPlugin' classname 'org.elasticsearch.geo.GeoPlugin'
@ -32,3 +34,9 @@ artifacts {
restTests(project.file('src/yamlRestTest/resources/rest-api-spec/test')) restTests(project.file('src/yamlRestTest/resources/rest-api-spec/test'))
} }
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
if (BuildParams.inFipsJvm){
// The geo module is replaced by spatial in the default distribution and in FIPS 140 mode, we set the testclusters to
// use the default distribution, so there is no need to run these tests
tasks.named("yamlRestTest").configure{enabled = false }
}

View file

@ -1,4 +1,7 @@
"Action to list contexts": "Action to list contexts":
- skip:
features: fips_140
reason: "The tests expect to be run with OSS distribution"
- do: - do:
scripts_painless_context: {} scripts_painless_context: {}
- match: { contexts.0: aggregation_selector} - match: { contexts.0: aggregation_selector}
@ -6,6 +9,9 @@
--- ---
"Action to get all API values for score context": "Action to get all API values for score context":
- skip:
features: fips_140
reason: "The tests expect to be run with OSS distribution"
- do: - do:
scripts_painless_context: scripts_painless_context:
context: score context: score

View file

@ -139,6 +139,16 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
builder.endObject(); builder.endObject();
Request request = new Request("PUT", "/_template/template"); Request request = new Request("PUT", "/_template/template");
if (inFipsJvm()) {
request.setOptions(expectWarnings(
"legacy template [template] has index patterns [*] matching patterns from existing composable templates " +
"[ilm-history,.triggered_watches,.watch-history-14,.slm-history,synthetics,metrics,.deprecation-indexing-template," +
".watches,logs] with patterns (ilm-history => [ilm-history-5*],.triggered_watches => [.triggered_watches*]," +
".watch-history-14 => [.watcher-history-14*],.slm-history => [.slm-history-5*],synthetics => [synthetics-*-*]" +
",metrics => [metrics-*-*],.deprecation-indexing-template => [.logs-deprecation-elasticsearch]," +
".watches => [.watches*],logs => [logs-*-*]); this template [template] may be ignored in favor " +
"of a composable template at index creation time"));
}
request.setJsonEntity(Strings.toString(builder)); request.setJsonEntity(Strings.toString(builder));
client().performRequest(request); client().performRequest(request);
headTestCase("/_template/template", emptyMap(), greaterThan(0)); headTestCase("/_template/template", emptyMap(), greaterThan(0));

View file

@ -124,7 +124,7 @@ public class AmazonEC2Fixture extends AbstractHttpFixture {
+ "\"AccessKeyId\": \"" + "ec2_integration_test_access_key" + "\"," + "\"AccessKeyId\": \"" + "ec2_integration_test_access_key" + "\","
+ "\"Expiration\": \"" + DateUtils.formatISO8601Date(expiration) + "\"," + "\"Expiration\": \"" + DateUtils.formatISO8601Date(expiration) + "\","
+ "\"RoleArn\": \"" + "test" + "\"," + "\"RoleArn\": \"" + "test" + "\","
+ "\"SecretAccessKey\": \"" + "test" + "\"," + "\"SecretAccessKey\": \"" + "ec2_integration_test_secret_key" + "\","
+ "\"Token\": \"" + "test" + "\"" + "\"Token\": \"" + "test" + "\""
+ "}"; + "}";

View file

@ -75,7 +75,7 @@ public abstract class AbstractEC2MockAPITestCase extends ESTestCase {
final String endpoint = "http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort(); final String endpoint = "http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort();
final MockSecureSettings mockSecure = new MockSecureSettings(); final MockSecureSettings mockSecure = new MockSecureSettings();
mockSecure.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), accessKey); mockSecure.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), accessKey);
mockSecure.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret"); mockSecure.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret_key");
return Settings.builder().put(Ec2ClientSettings.ENDPOINT_SETTING.getKey(), endpoint).setSecureSettings(mockSecure).build(); return Settings.builder().put(Ec2ClientSettings.ENDPOINT_SETTING.getKey(), endpoint).setSecureSettings(mockSecure).build();
} }

View file

@ -110,7 +110,7 @@ public class Ec2DiscoveryPluginTests extends ESTestCase {
public void testClientSettingsReInit() throws IOException { public void testClientSettingsReInit() throws IOException {
final MockSecureSettings mockSecure1 = new MockSecureSettings(); final MockSecureSettings mockSecure1 = new MockSecureSettings();
mockSecure1.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), "ec2_access_1"); mockSecure1.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), "ec2_access_1");
mockSecure1.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret_1"); mockSecure1.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret_key_1");
final boolean mockSecure1HasSessionToken = randomBoolean(); final boolean mockSecure1HasSessionToken = randomBoolean();
if (mockSecure1HasSessionToken) { if (mockSecure1HasSessionToken) {
mockSecure1.setString(Ec2ClientSettings.SESSION_TOKEN_SETTING.getKey(), "ec2_session_token_1"); mockSecure1.setString(Ec2ClientSettings.SESSION_TOKEN_SETTING.getKey(), "ec2_session_token_1");
@ -125,7 +125,7 @@ public class Ec2DiscoveryPluginTests extends ESTestCase {
.build(); .build();
final MockSecureSettings mockSecure2 = new MockSecureSettings(); final MockSecureSettings mockSecure2 = new MockSecureSettings();
mockSecure2.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), "ec2_access_2"); mockSecure2.setString(Ec2ClientSettings.ACCESS_KEY_SETTING.getKey(), "ec2_access_2");
mockSecure2.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret_2"); mockSecure2.setString(Ec2ClientSettings.SECRET_KEY_SETTING.getKey(), "ec2_secret_key_2");
final boolean mockSecure2HasSessionToken = randomBoolean(); final boolean mockSecure2HasSessionToken = randomBoolean();
if (mockSecure2HasSessionToken) { if (mockSecure2HasSessionToken) {
mockSecure2.setString(Ec2ClientSettings.SESSION_TOKEN_SETTING.getKey(), "ec2_session_token_2"); mockSecure2.setString(Ec2ClientSettings.SESSION_TOKEN_SETTING.getKey(), "ec2_session_token_2");
@ -143,7 +143,7 @@ public class Ec2DiscoveryPluginTests extends ESTestCase {
{ {
final AWSCredentials credentials = ((AmazonEC2Mock) clientReference.client()).credentials.getCredentials(); final AWSCredentials credentials = ((AmazonEC2Mock) clientReference.client()).credentials.getCredentials();
assertThat(credentials.getAWSAccessKeyId(), is("ec2_access_1")); assertThat(credentials.getAWSAccessKeyId(), is("ec2_access_1"));
assertThat(credentials.getAWSSecretKey(), is("ec2_secret_1")); assertThat(credentials.getAWSSecretKey(), is("ec2_secret_key_1"));
if (mockSecure1HasSessionToken) { if (mockSecure1HasSessionToken) {
assertThat(credentials, instanceOf(BasicSessionCredentials.class)); assertThat(credentials, instanceOf(BasicSessionCredentials.class));
assertThat(((BasicSessionCredentials)credentials).getSessionToken(), is("ec2_session_token_1")); assertThat(((BasicSessionCredentials)credentials).getSessionToken(), is("ec2_session_token_1"));
@ -177,7 +177,7 @@ public class Ec2DiscoveryPluginTests extends ESTestCase {
try (AmazonEc2Reference clientReference = plugin.ec2Service.client()) { try (AmazonEc2Reference clientReference = plugin.ec2Service.client()) {
final AWSCredentials credentials = ((AmazonEC2Mock) clientReference.client()).credentials.getCredentials(); final AWSCredentials credentials = ((AmazonEC2Mock) clientReference.client()).credentials.getCredentials();
assertThat(credentials.getAWSAccessKeyId(), is("ec2_access_2")); assertThat(credentials.getAWSAccessKeyId(), is("ec2_access_2"));
assertThat(credentials.getAWSSecretKey(), is("ec2_secret_2")); assertThat(credentials.getAWSSecretKey(), is("ec2_secret_key_2"));
if (mockSecure2HasSessionToken) { if (mockSecure2HasSessionToken) {
assertThat(credentials, instanceOf(BasicSessionCredentials.class)); assertThat(credentials, instanceOf(BasicSessionCredentials.class));
assertThat(((BasicSessionCredentials)credentials).getSessionToken(), is("ec2_session_token_2")); assertThat(((BasicSessionCredentials)credentials).getSessionToken(), is("ec2_session_token_2"));

View file

@ -6,7 +6,6 @@ gradle.projectsEvaluated {
project.tasks.matching { it.name.equals('assemble') }.configureEach { project.tasks.matching { it.name.equals('assemble') }.configureEach {
enabled = false enabled = false
} }
// Disable example project testing with FIPS JVM // Disable example project testing with FIPS JVM
tasks.withType(Test) { tasks.withType(Test) {
onlyIf { onlyIf {

View file

@ -84,7 +84,7 @@ public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryInteg
@Override @Override
protected Settings nodeSettings(int nodeOrdinal) { protected Settings nodeSettings(int nodeOrdinal) {
final String key = Base64.getEncoder().encodeToString(randomAlphaOfLength(10).getBytes(StandardCharsets.UTF_8)); final String key = Base64.getEncoder().encodeToString(randomAlphaOfLength(14).getBytes(StandardCharsets.UTF_8));
final MockSecureSettings secureSettings = new MockSecureSettings(); final MockSecureSettings secureSettings = new MockSecureSettings();
String accountName = DEFAULT_ACCOUNT_NAME; String accountName = DEFAULT_ACCOUNT_NAME;
secureSettings.setString(AzureStorageSettings.ACCOUNT_SETTING.getConcreteSettingForNamespace("test").getKey(), accountName); secureSettings.setString(AzureStorageSettings.ACCOUNT_SETTING.getConcreteSettingForNamespace("test").getKey(), accountName);

View file

@ -144,7 +144,7 @@ public class AzureBlobContainerRetriesTests extends ESTestCase {
final MockSecureSettings secureSettings = new MockSecureSettings(); final MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString(ACCOUNT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "account"); secureSettings.setString(ACCOUNT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "account");
final String key = Base64.getEncoder().encodeToString(randomAlphaOfLength(10).getBytes(UTF_8)); final String key = Base64.getEncoder().encodeToString(randomAlphaOfLength(14).getBytes(UTF_8));
secureSettings.setString(KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), key); secureSettings.setString(KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), key);
clientSettings.setSecureSettings(secureSettings); clientSettings.setSecureSettings(secureSettings);

View file

@ -236,7 +236,7 @@ def encodedCredentials = {
tasks.register("createServiceAccountFile") { tasks.register("createServiceAccountFile") {
doLast { doLast {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA") KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA")
keyPairGenerator.initialize(1024) keyPairGenerator.initialize(2048)
KeyPair keyPair = keyPairGenerator.generateKeyPair() KeyPair keyPair = keyPairGenerator.generateKeyPair()
String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded()) String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded())

View file

@ -143,7 +143,7 @@ public class GoogleCloudStorageServiceTests extends ESTestCase {
private byte[] serviceAccountFileContent(String projectId) throws Exception { private byte[] serviceAccountFileContent(String projectId) throws Exception {
final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024); keyPairGenerator.initialize(2048);
final KeyPair keyPair = keyPairGenerator.generateKeyPair(); final KeyPair keyPair = keyPairGenerator.generateKeyPair();
final String encodedKey = Base64.getEncoder().encodeToString(keyPair.getPrivate().getEncoded()); final String encodedKey = Base64.getEncoder().encodeToString(keyPair.getPrivate().getEncoded());
final XContentBuilder serviceAccountBuilder = jsonBuilder().startObject() final XContentBuilder serviceAccountBuilder = jsonBuilder().startObject()

View file

@ -37,7 +37,7 @@ final class TestUtils {
static byte[] createServiceAccount(final Random random) { static byte[] createServiceAccount(final Random random) {
try { try {
final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024); keyPairGenerator.initialize(2048);
final String privateKey = Base64.getEncoder().encodeToString(keyPairGenerator.generateKeyPair().getPrivate().getEncoded()); final String privateKey = Base64.getEncoder().encodeToString(keyPairGenerator.generateKeyPair().getPrivate().getEncoded());
final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream out = new ByteArrayOutputStream();

View file

@ -124,8 +124,8 @@ boolean s3DisableChunkedEncoding = (new Random(Long.parseUnsignedLong(BuildParam
// credentials hard-coded in. // credentials hard-coded in.
if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3PermanentBasePath) { if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3PermanentBasePath) {
s3PermanentAccessKey = 'access_key' s3PermanentAccessKey = 's3_test_access_key'
s3PermanentSecretKey = 'secret_key' s3PermanentSecretKey = 's3_test_secret_key'
s3PermanentBucket = 'bucket' s3PermanentBucket = 'bucket'
s3PermanentBasePath = 'base_path' s3PermanentBasePath = 'base_path'

View file

@ -122,8 +122,8 @@ public class S3BlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTes
@Override @Override
protected Settings nodeSettings(int nodeOrdinal) { protected Settings nodeSettings(int nodeOrdinal) {
final MockSecureSettings secureSettings = new MockSecureSettings(); final MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace("test").getKey(), "access"); secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace("test").getKey(), "test_access_key");
secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace("test").getKey(), "secret"); secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace("test").getKey(), "test_secret_key");
final Settings.Builder builder = Settings.builder() final Settings.Builder builder = Settings.builder()
.put(ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING.getKey(), 0) // We have tests that verify an exact wait time .put(ThreadPool.ESTIMATED_TIME_INTERVAL_SETTING.getKey(), 0) // We have tests that verify an exact wait time

View file

@ -122,8 +122,10 @@ public class S3BlobContainerRetriesTests extends AbstractBlobContainerRetriesTes
} }
final MockSecureSettings secureSettings = new MockSecureSettings(); final MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "access"); secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(),
secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "secret"); "test_access_key");
secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(),
"test_secret_key");
clientSettings.setSecureSettings(secureSettings); clientSettings.setSecureSettings(secureSettings);
service.refreshAndClearCache(S3ClientSettings.load(clientSettings.build())); service.refreshAndClearCache(S3ClientSettings.load(clientSettings.build()));

View file

@ -304,7 +304,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
*/ */
public void test60DockerEnvironmentVariablePassword() throws Exception { public void test60DockerEnvironmentVariablePassword() throws Exception {
assumeTrue(distribution().isDocker()); assumeTrue(distribution().isDocker());
String password = "password"; String password = "keystore-password";
Path dockerKeystore = installation.config("elasticsearch.keystore"); Path dockerKeystore = installation.config("elasticsearch.keystore");
Path localKeystoreFile = getKeystoreFileFromDockerContainer(password, dockerKeystore); Path localKeystoreFile = getKeystoreFileFromDockerContainer(password, dockerKeystore);
@ -328,7 +328,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
try { try {
tempDir = createTempDir(DockerTests.class.getSimpleName()); tempDir = createTempDir(DockerTests.class.getSimpleName());
String password = "password"; String password = "keystore-password";
String passwordFilename = "password.txt"; String passwordFilename = "password.txt";
Files.write(tempDir.resolve(passwordFilename), singletonList(password)); Files.write(tempDir.resolve(passwordFilename), singletonList(password));
Files.setPosixFilePermissions(tempDir.resolve(passwordFilename), p600); Files.setPosixFilePermissions(tempDir.resolve(passwordFilename), p600);
@ -362,7 +362,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
*/ */
public void test62DockerEnvironmentVariableBadPassword() throws Exception { public void test62DockerEnvironmentVariableBadPassword() throws Exception {
assumeTrue(distribution().isDocker()); assumeTrue(distribution().isDocker());
String password = "password"; String password = "keystore-password";
Path dockerKeystore = installation.config("elasticsearch.keystore"); Path dockerKeystore = installation.config("elasticsearch.keystore");
Path localKeystoreFile = getKeystoreFileFromDockerContainer(password, dockerKeystore); Path localKeystoreFile = getKeystoreFileFromDockerContainer(password, dockerKeystore);

View file

@ -31,13 +31,17 @@ dependencies {
testImplementation project(':client:rest-high-level') testImplementation project(':client:rest-high-level')
} }
tasks.register("copyKeystore", Sync) { tasks.register("copyNodeKeyMaterial", Sync) {
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .files(
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt'
)
into "${buildDir}/certs" into "${buildDir}/certs"
doLast { doLast {
file("${buildDir}/certs").setReadable(true, false) file("${buildDir}/certs").setReadable(true, false)
file("${buildDir}/certs/testnode.jks").setReadable(true, false) file("${buildDir}/certs/testnode.pem").setReadable(true, false)
file("${buildDir}/certs/testnode.crt").setReadable(true, false)
} }
} }
@ -52,7 +56,7 @@ elasticsearch_distributions {
} }
tasks.named("preProcessFixture").configure { tasks.named("preProcessFixture").configure {
dependsOn "copyKeystore", elasticsearch_distributions.docker dependsOn "copyNodeKeyMaterial", elasticsearch_distributions.docker
doLast { doLast {
// tests expect to have an empty repo // tests expect to have an empty repo
project.delete( project.delete(
@ -89,7 +93,10 @@ def createAndSetWritable(Object... locations) {
tasks.named("processTestResources").configure { tasks.named("processTestResources").configure {
from project(':x-pack:plugin:core') from project(':x-pack:plugin:core')
.file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') .files(
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt'
)
} }
tasks.register("integTest", Test) { tasks.register("integTest", Test) {

View file

@ -23,14 +23,17 @@ services:
- xpack.security.audit.enabled=true - xpack.security.audit.enabled=true
- xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.file.file1.order=0
- xpack.security.authc.realms.native.native1.order=1 - xpack.security.authc.realms.native.native1.order=1
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.security.http.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.http.ssl.verification_mode=certificate - xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial - xpack.license.self_generated.type=trial
volumes: volumes:
- ./build/repo:/tmp/es-repo - ./build/repo:/tmp/es-repo
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
- ./build/certs/testnode.crt:/usr/share/elasticsearch/config/testnode.crt
- ./build/logs/default-1:/usr/share/elasticsearch/logs - ./build/logs/default-1:/usr/share/elasticsearch/logs
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh
ports: ports:
@ -72,14 +75,17 @@ services:
- xpack.security.audit.enabled=true - xpack.security.audit.enabled=true
- xpack.security.authc.realms.file.file1.order=0 - xpack.security.authc.realms.file.file1.order=0
- xpack.security.authc.realms.native.native1.order=1 - xpack.security.authc.realms.native.native1.order=1
- xpack.security.transport.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.keystore.path=/usr/share/elasticsearch/config/testnode.jks - xpack.security.transport.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.security.http.ssl.key=/usr/share/elasticsearch/config/testnode.pem
- xpack.security.http.ssl.certificate=/usr/share/elasticsearch/config/testnode.crt
- xpack.http.ssl.verification_mode=certificate - xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate - xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial - xpack.license.self_generated.type=trial
volumes: volumes:
- ./build/repo:/tmp/es-repo - ./build/repo:/tmp/es-repo
- ./build/certs/testnode.jks:/usr/share/elasticsearch/config/testnode.jks - ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
- ./build/certs/testnode.crt:/usr/share/elasticsearch/config/testnode.crt
- ./build/logs/default-2:/usr/share/elasticsearch/logs - ./build/logs/default-2:/usr/share/elasticsearch/logs
- ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh - ./docker-test-entrypoint.sh:/docker-test-entrypoint.sh
ports: ports:

View file

@ -2,6 +2,6 @@
cd /usr/share/elasticsearch/bin/ cd /usr/share/elasticsearch/bin/
./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true ./elasticsearch-users useradd x_pack_rest_user -p x-pack-test-password -r superuser || true
echo "testnode" > /tmp/password echo "testnode" > /tmp/password
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.keystore.secure_password' cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.transport.ssl.secure_key_passphrase'
cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.keystore.secure_password' cat /tmp/password | ./elasticsearch-keystore add -x -f -v 'xpack.security.http.ssl.secure_key_passphrase'
/usr/local/bin/docker-entrypoint.sh | tee > /usr/share/elasticsearch/logs/console.log /usr/local/bin/docker-entrypoint.sh | tee /usr/share/elasticsearch/logs/console.log

View file

@ -48,7 +48,6 @@ public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase
private static final String USER = "x_pack_rest_user"; private static final String USER = "x_pack_rest_user";
private static final String PASS = "x-pack-test-password"; private static final String PASS = "x-pack-test-password";
private static final String KEYSTORE_PASS = "testnode";
@Override @Override
protected boolean preserveClusterUponCompletion() { protected boolean preserveClusterUponCompletion() {
@ -123,23 +122,23 @@ public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase
return getDistribution().equals("oss"); return getDistribution().equals("oss");
} }
static Path keyStore; static Path trustedCertFile;
@BeforeClass @BeforeClass
public static void getKeyStore() { public static void getTrustedCert() {
try { try {
keyStore = PathUtils.get(AbstractMultiClusterRemoteTestCase.class.getResource("/testnode.jks").toURI()); trustedCertFile = PathUtils.get(AbstractMultiClusterRemoteTestCase.class.getResource("/testnode.crt").toURI());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new ElasticsearchException("exception while reading the store", e); throw new ElasticsearchException("exception while reading the certificate file", e);
} }
if (Files.exists(keyStore) == false) { if (Files.exists(trustedCertFile) == false) {
throw new IllegalStateException("Keystore file [" + keyStore + "] does not exist."); throw new IllegalStateException("Certificate file [" + trustedCertFile + "] does not exist.");
} }
} }
@AfterClass @AfterClass
public static void clearKeyStore() { public static void clearTrustedCert() {
keyStore = null; trustedCertFile = null;
} }
@Override @Override
@ -150,8 +149,7 @@ public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase
String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray()));
return Settings.builder() return Settings.builder()
.put(ThreadContext.PREFIX + ".Authorization", token) .put(ThreadContext.PREFIX + ".Authorization", token)
.put(ESRestTestCase.TRUSTSTORE_PATH, keyStore) .put(ESRestTestCase.CERTIFICATE_AUTHORITIES, trustedCertFile)
.put(ESRestTestCase.TRUSTSTORE_PASSWORD, KEYSTORE_PASS)
.build(); .build();
} }

View file

@ -24,7 +24,9 @@ setup:
--- ---
"node_reload_secure_settings test correct(empty) password": "node_reload_secure_settings test correct(empty) password":
- skip:
features: fips_140
reason: "In FIPS 140 mode, we use a password protected elasticsearch keystore"
- do: - do:
nodes.reload_secure_settings: {} nodes.reload_secure_settings: {}

View file

@ -33,6 +33,7 @@ import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ReloadablePlugin; import org.elasticsearch.plugins.ReloadablePlugin;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.transport.RemoteTransportException; import org.elasticsearch.transport.RemoteTransportException;
import org.junit.BeforeClass;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
@ -55,6 +56,13 @@ import static org.hamcrest.Matchers.nullValue;
@ESIntegTestCase.ClusterScope(minNumDataNodes = 2) @ESIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class ReloadSecureSettingsIT extends ESIntegTestCase { public class ReloadSecureSettingsIT extends ESIntegTestCase {
@BeforeClass
public static void disableInFips() {
// Reload secure settings with a password protected keystore is tested in ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT
assumeFalse("Cannot run in FIPS mode since the keystore will be password protected and sending a password in the reload" +
"settings api call, require TLS to be configured for the transport layer", inFipsJvm());
}
public void testMissingKeystoreFile() throws Exception { public void testMissingKeystoreFile() throws Exception {
final PluginsService pluginsService = internalCluster().getInstance(PluginsService.class); final PluginsService pluginsService = internalCluster().getInstance(PluginsService.class);
final MockReloadablePlugin mockReloadablePlugin = pluginsService.filterPlugins(MockReloadablePlugin.class) final MockReloadablePlugin mockReloadablePlugin = pluginsService.filterPlugins(MockReloadablePlugin.class)

View file

@ -24,9 +24,9 @@
kadmind_port = 749 kadmind_port = 749
max_life = 12h 0m 0s max_life = 12h 0m 0s
max_renewable_life = 7d 0h 0m 0s max_renewable_life = 7d 0h 0m 0s
master_key_type = aes256-cts master_key_type = des3-cbc-sha1-kd
# remove aes256-cts:normal since unlimited strength policy needs installed for java to use it. # This is the only supported enctype for fips 140-2
supported_enctypes = aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal supported_enctypes = des3-cbc-sha1-kd:normal
} }
[logging] [logging]

View file

@ -24,12 +24,14 @@
forwardable = true forwardable = true
ignore_acceptor_hostname = true ignore_acceptor_hostname = true
rdns = false rdns = false
default_tgs_enctypes = rc4-hmac # des3-cbc-sha1-kd is the only enctype available in fips 140-2
default_tkt_enctypes = rc4-hmac default_tgs_enctypes = des3-cbc-sha1-kd
permitted_enctypes = rc4-hmac default_tkt_enctypes = des3-cbc-sha1-kd
permitted_enctypes = des3-cbc-sha1-kd
# udp_preference_limit = 1 # udp_preference_limit = 1
kdc_timeout = 3000 kdc_timeout = 3000
canonicalize = true canonicalize = true
allow_weak_enctypes = false
[realms] [realms]
${REALM_NAME} = { ${REALM_NAME} = {

View file

@ -5,8 +5,8 @@ services:
context: . context: .
args: args:
bucket: "bucket" bucket: "bucket"
accessKey: "access_key" accessKey: "s3_test_access_key"
secretKey: "secret_key" secretKey: "s3_test_secret_key"
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "9000" - "9000"
@ -16,8 +16,8 @@ services:
context: . context: .
args: args:
bucket: "bucket" bucket: "bucket"
accessKey: "access_key" accessKey: "s3_test_access_key"
secretKey: "secret_key" secretKey: "s3_test_secret_key"
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "9000" - "9000"

View file

@ -8,7 +8,7 @@ services:
port: 80 port: 80
bucket: "bucket" bucket: "bucket"
basePath: "base_path_integration_tests" basePath: "base_path_integration_tests"
accessKey: "access_key" accessKey: "s3_test_access_key"
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- ./testfixtures_shared/shared:/fixture/shared - ./testfixtures_shared/shared:/fixture/shared
@ -23,7 +23,7 @@ services:
port: 80 port: 80
bucket: "bucket" bucket: "bucket"
basePath: "base_path" basePath: "base_path"
accessKey: "access_key" accessKey: "s3_test_access_key"
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- ./testfixtures_shared/shared:/fixture/shared - ./testfixtures_shared/shared:/fixture/shared
@ -38,7 +38,7 @@ services:
port: 80 port: 80
bucket: "bucket" bucket: "bucket"
basePath: "base_path" basePath: "base_path"
accessKey: "access_key" accessKey: "s3_test_access_key"
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- ./testfixtures_shared/shared:/fixture/shared - ./testfixtures_shared/shared:/fixture/shared

View file

@ -79,7 +79,7 @@ public class S3HttpFixtureWithEC2 extends S3HttpFixtureWithSessionToken {
+ "\"AccessKeyId\": \"" + ec2AccessKey + "\"," + "\"AccessKeyId\": \"" + ec2AccessKey + "\","
+ "\"Expiration\": \"" + ZonedDateTime.now().plusDays(1L).format(DateTimeFormatter.ISO_DATE_TIME) + "\"," + "\"Expiration\": \"" + ZonedDateTime.now().plusDays(1L).format(DateTimeFormatter.ISO_DATE_TIME) + "\","
+ "\"RoleArn\": \"arn\"," + "\"RoleArn\": \"arn\","
+ "\"SecretAccessKey\": \"secret\"," + "\"SecretAccessKey\": \"secret_access_key\","
+ "\"Token\": \"" + ec2SessionToken + "\"" + "\"Token\": \"" + ec2SessionToken + "\""
+ "}"; + "}";
} }

View file

@ -706,7 +706,7 @@ tasks.named("buildRestTests").configure { buildRestTests ->
username: "jacknich" username: "jacknich"
body: > body: >
{ {
"password" : "test-password", "password" : "l0ng-r4nd0m-p@ssw0rd",
"roles" : [ "admin", "other_role1" ], "roles" : [ "admin", "other_role1" ],
"full_name" : "Jack Nicholson", "full_name" : "Jack Nicholson",
"email" : "jacknich@example.com", "email" : "jacknich@example.com",

View file

@ -55,7 +55,7 @@ The following example updates the password for the `jacknich` user:
-------------------------------------------------- --------------------------------------------------
POST /_security/user/jacknich/_password POST /_security/user/jacknich/_password
{ {
"password" : "s3cr3t" "password" : "new-test-password"
} }
-------------------------------------------------- --------------------------------------------------
// TEST[setup:jacknich_user] // TEST[setup:jacknich_user]

View file

@ -112,7 +112,7 @@ The following example creates a user `jacknich`:
-------------------------------------------------- --------------------------------------------------
POST /_security/user/jacknich POST /_security/user/jacknich
{ {
"password" : "j@rV1s", "password" : "l0ng-r4nd0m-p@ssw0rd",
"roles" : [ "admin", "other_role1" ], "roles" : [ "admin", "other_role1" ],
"full_name" : "Jack Nicholson", "full_name" : "Jack Nicholson",
"email" : "jacknich@example.com", "email" : "jacknich@example.com",
@ -138,6 +138,6 @@ After you add a user, requests from that user can be authenticated. For example:
[source,shell] [source,shell]
-------------------------------------------------- --------------------------------------------------
curl -u jacknich:j@rV1s http://localhost:9200/_cluster/health curl -u jacknich:l0ng-r4nd0m-p@ssw0rd http://localhost:9200/_cluster/health
-------------------------------------------------- --------------------------------------------------
// NOTCONSOLE // NOTCONSOLE

View file

@ -131,7 +131,7 @@ Finally, create a user on cluster `one` and apply the `cluster_two_logs` role:
----------------------------------------------------------- -----------------------------------------------------------
POST /_security/user/alice POST /_security/user/alice
{ {
"password" : "somepassword", "password" : "somepasswordhere",
"roles" : [ "cluster_two_logs" ], "roles" : [ "cluster_two_logs" ],
"full_name" : "Alice", "full_name" : "Alice",
"email" : "alice@example.com", "email" : "alice@example.com",

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-test'
@ -20,3 +22,8 @@ testClusters.all {
} }
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("yamlRestTest").configure{enabled = false }
}

View file

@ -1,6 +1,17 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
dependencies { dependencies {
api project(':test:framework') api project(':test:framework')
} }
gradle.projectsEvaluated {
subprojects {
tasks.withType(Test).configureEach {
// These fail in CI but only when run as part of checkPart2 and not individually.
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
onlyIf { BuildParams.inFipsJvm == false}
}
}
}

View file

@ -25,27 +25,6 @@ tasks.register("writeJavaPolicy") {
if (policyFile.parentFile.exists() == false && policyFile.parentFile.mkdirs() == false) { if (policyFile.parentFile.exists() == false && policyFile.parentFile.mkdirs() == false) {
throw new GradleException("failed to create temporary directory [${tmp}]") throw new GradleException("failed to create temporary directory [${tmp}]")
} }
if (BuildParams.inFipsJvm) {
policyFile.write(
[
"grant {",
"permission java.security.SecurityPermission \"putProviderProperty.BCFIPS\";",
"permission java.security.SecurityPermission \"putProviderProperty.BCJSSE\";",
"permission java.lang.RuntimePermission \"getProtectionDomain\";",
"permission java.util.PropertyPermission \"java.runtime.name\", \"read\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"tlsAlgorithmsEnabled\";",
"permission java.lang.RuntimePermission \"accessClassInPackage.sun.security.internal.spec\";",
"permission java.lang.RuntimePermission \"accessDeclaredMembers\";",
"permission java.util.PropertyPermission \"intellij.debug.agent\", \"read\";",
"permission java.util.PropertyPermission \"intellij.debug.agent\", \"write\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"exportSecretKey\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"exportPrivateKey\";",
"permission java.io.FilePermission \"\${javax.net.ssl.trustStore}\", \"read\";",
"permission java.io.FilePermission \"${-> testClusters."follow-cluster".getFirstNode().getServerLog()}\", \"read\";",
"};"
].join("\n")
)
} else {
policyFile.write( policyFile.write(
[ [
"grant {", "grant {",
@ -55,16 +34,11 @@ tasks.register("writeJavaPolicy") {
) )
} }
} }
}
task "follow-cluster"(type: RestIntegTestTask) { task "follow-cluster"(type: RestIntegTestTask) {
dependsOn 'writeJavaPolicy', "leader-cluster" dependsOn 'writeJavaPolicy', "leader-cluster"
useCluster testClusters."leader-cluster" useCluster testClusters."leader-cluster"
if (BuildParams.inFipsJvm){
systemProperty 'java.security.policy', "=file://${policyFile}"
} else {
systemProperty 'java.security.policy', "file://${policyFile}" systemProperty 'java.security.policy', "file://${policyFile}"
}
systemProperty 'tests.target_cluster', 'follow' systemProperty 'tests.target_cluster', 'follow'
nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}" nonInputProperties.systemProperty 'tests.leader_host', "${-> testClusters."leader-cluster".getAllHttpSocketURI().get(0)}"
nonInputProperties.systemProperty 'log', "${-> testClusters."follow-cluster".getFirstNode().getServerLog()}" nonInputProperties.systemProperty 'log', "${-> testClusters."follow-cluster".getFirstNode().getServerLog()}"
@ -81,3 +55,8 @@ testClusters."follow-cluster" {
tasks.named("check").configure { dependsOn "follow-cluster" } tasks.named("check").configure { dependsOn "follow-cluster" }
// no unit tests for multi-cluster-search, only the rest integration test // no unit tests for multi-cluster-search, only the rest integration test
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
// We can't run in FIPS mode with a basic license
tasks.withType(Test).configureEach {
onlyIf { BuildParams.inFipsJvm == false}
}

View file

@ -53,6 +53,8 @@ dependencies {
testImplementation project(path: ':modules:lang-mustache') testImplementation project(path: ':modules:lang-mustache')
testImplementation project(path: ':modules:analysis-common') testImplementation project(path: ':modules:analysis-common')
testImplementation project(":client:rest-high-level") testImplementation project(":client:rest-high-level")
// Needed for Fips140ProviderVerificationTests
testCompileOnly('org.bouncycastle:bc-fips:1.0.2')
testImplementation(project(':x-pack:license-tools')) { testImplementation(project(':x-pack:license-tools')) {
transitive = false transitive = false

View file

@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core;
import org.bouncycastle.crypto.CryptoServicesRegistrar;
import org.elasticsearch.test.ESTestCase;
import java.security.Security;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
public class Fips140ProviderVerificationTests extends ESTestCase {
public void testBcFipsProviderInUse() {
if (inFipsJvm()) {
assertThat(Security.getProviders().length > 0, equalTo(true));
assertThat(Security.getProviders()[0].getName(), containsString("BCFIPS"));
}
}
public void testInApprovedOnlyMode() {
if (inFipsJvm()) {
assertThat(CryptoServicesRegistrar.isInApprovedOnlyMode(), equalTo(true));
}
}
}

View file

@ -22,6 +22,7 @@ import java.util.Map;
public class ProfileConfigurationsTests extends ESTestCase { public class ProfileConfigurationsTests extends ESTestCase {
public void testGetSecureTransportProfileConfigurations() { public void testGetSecureTransportProfileConfigurations() {
assumeFalse("Can't run in a FIPS JVM, uses JKS/PKCS12 keystores", inFipsJvm());
final Settings settings = getBaseSettings() final Settings settings = getBaseSettings()
.put("path.home", createTempDir()) .put("path.home", createTempDir())
.put("xpack.security.transport.ssl.verification_mode", VerificationMode.CERTIFICATE.name()) .put("xpack.security.transport.ssl.verification_mode", VerificationMode.CERTIFICATE.name())

View file

@ -35,7 +35,6 @@ import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.elasticsearch.test.ESIntegTestCase.inFipsJvm;
public class RestrictedTrustManagerTests extends ESTestCase { public class RestrictedTrustManagerTests extends ESTestCase {

View file

@ -321,6 +321,7 @@ public class SSLServiceTests extends ESTestCase {
} }
public void testThatHttpClientAuthDefaultsToNone() throws Exception { public void testThatHttpClientAuthDefaultsToNone() throws Exception {
assumeFalse("Can't run in a FIPS JVM, uses JKS/PKCS12 keystores", inFipsJvm());
MockSecureSettings secureSettings = new MockSecureSettings(); MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString("xpack.security.transport.ssl.keystore.secure_password", "testnode"); secureSettings.setString("xpack.security.transport.ssl.keystore.secure_password", "testnode");
secureSettings.setString("xpack.security.http.ssl.keystore.secure_password", "testnode"); secureSettings.setString("xpack.security.http.ssl.keystore.secure_password", "testnode");
@ -344,6 +345,7 @@ public class SSLServiceTests extends ESTestCase {
} }
public void testThatTruststorePasswordIsRequired() throws Exception { public void testThatTruststorePasswordIsRequired() throws Exception {
assumeFalse("Can't run in a FIPS JVM, uses JKS/PKCS12 keystores", inFipsJvm());
MockSecureSettings secureSettings = new MockSecureSettings(); MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString("xpack.security.transport.ssl.keystore.secure_password", "testnode"); secureSettings.setString("xpack.security.transport.ssl.keystore.secure_password", "testnode");
Settings settings = Settings.builder() Settings settings = Settings.builder()
@ -360,6 +362,7 @@ public class SSLServiceTests extends ESTestCase {
} }
public void testThatKeystorePasswordIsRequired() throws Exception { public void testThatKeystorePasswordIsRequired() throws Exception {
assumeFalse("Can't run in a FIPS JVM, uses JKS/PKCS12 keystores", inFipsJvm());
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put("xpack.security.transport.ssl.keystore.path", testnodeStore) .put("xpack.security.transport.ssl.keystore.path", testnodeStore)
.put("xpack.security.transport.ssl.keystore.type", testnodeStoreType) .put("xpack.security.transport.ssl.keystore.type", testnodeStoreType)

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
File repoDir = file("$buildDir/testclusters/repo") File repoDir = file("$buildDir/testclusters/repo")
@ -19,3 +21,8 @@ testClusters.matching { it.name == "javaRestTest" }.configureEach {
//disabling ILM history as it disturbs testDSXpackUsage test //disabling ILM history as it disturbs testDSXpackUsage test
setting 'indices.lifecycle.history_index_enabled', 'false' setting 'indices.lifecycle.history_index_enabled', 'false'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-test'
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
@ -18,3 +20,9 @@ testClusters.all {
// disable ILM history, since it disturbs tests using _all // disable ILM history, since it disturbs tests using _all
setting 'indices.lifecycle.history_index_enabled', 'false' setting 'indices.lifecycle.history_index_enabled', 'false'
} }
if (BuildParams.inFipsJvm){
// These fail in CI but only when run as part of checkPart2 and not individually.
// Tracked in :
tasks.named("javaRestTest").configure{enabled = false }
tasks.named("yamlRestTest").configure{enabled = false }
}

View file

@ -1,4 +1,5 @@
import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.util.GradleUtils
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.esplugin' apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
@ -30,3 +31,8 @@ testClusters.all {
} }
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -1,9 +1,15 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
import org.elasticsearch.gradle.info.BuildParams
dependencies { dependencies {
javaRestTestImplementation project(path: xpackModule('core')) javaRestTestImplementation project(path: xpackModule('core'))
javaRestTestImplementation project(path: xpackModule('enrich:qa:common')) javaRestTestImplementation project(path: xpackModule('enrich:qa:common'))
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'

View file

@ -1,6 +1,8 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
apply plugin: 'elasticsearch.yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-test'
import org.elasticsearch.gradle.info.BuildParams
restResources { restResources {
restApi { restApi {
includeCore '_common', 'indices', 'index' includeCore '_common', 'indices', 'index'
@ -12,6 +14,12 @@ dependencies {
javaRestTestImplementation project(path: xpackModule('enrich:qa:common')) javaRestTestImplementation project(path: xpackModule('enrich:qa:common'))
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
tasks.named("yamlRestTest").configure{enabled = false }
}
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'

View file

@ -4,6 +4,7 @@ apply plugin: 'elasticsearch.testclusters'
tasks.named("test").configure { enabled = false } tasks.named("test").configure { enabled = false }
import org.elasticsearch.gradle.testclusters.RunTask import org.elasticsearch.gradle.testclusters.RunTask
import org.elasticsearch.gradle.info.BuildParams
restResources { restResources {
restApi { restApi {
@ -31,6 +32,10 @@ Boolean preserveData = providers.systemProperty('eql.test.preserve.data')
.map { s -> Boolean.parseBoolean(s) } .map { s -> Boolean.parseBoolean(s) }
.getOrElse(false) .getOrElse(false)
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters { testClusters {
all { all {
plugin ':plugins:repository-gcs' plugin ':plugins:repository-gcs'

View file

@ -1,6 +1,8 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
apply plugin: 'elasticsearch.yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-test'
import org.elasticsearch.gradle.info.BuildParams
restResources { restResources {
restApi { restApi {
includeCore '_common', 'bulk', 'indices' includeCore '_common', 'bulk', 'indices'
@ -12,6 +14,11 @@ dependencies {
javaRestTestImplementation project(path: xpackModule('eql:qa:common')) javaRestTestImplementation project(path: xpackModule('eql:qa:common'))
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
tasks.named("yamlRestTest").configure{enabled = false }
}
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'

View file

@ -1,9 +1,16 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
import org.elasticsearch.gradle.info.BuildParams
dependencies { dependencies {
javaRestTestImplementation project(path: xpackModule('eql:qa:common')) javaRestTestImplementation project(path: xpackModule('eql:qa:common'))
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'

View file

@ -1,3 +1,4 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
dependencies { dependencies {
@ -45,3 +46,9 @@ testClusters.all {
user username: "idp_admin", password: "idp-password", role: "idp_admin" user username: "idp_admin", password: "idp-password", role: "idp_admin"
user username: "idp_user", password: "idp-password", role: "idp_user" user username: "idp_user", password: "idp-password", role: "idp_user"
} }
// We don't support the IDP in FIPS-140 mode, so no need to run java rest tests
tasks.named("javaRestTest").configure {
onlyIf { BuildParams.inFipsJvm == false }
}

View file

@ -1,4 +1,5 @@
import org.elasticsearch.gradle.test.RestIntegTestTask import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.testclusters' apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.standalone-test'
@ -11,14 +12,14 @@ dependencies {
File repoDir = file("$buildDir/testclusters/repo") File repoDir = file("$buildDir/testclusters/repo")
task 'leader-cluster'(type: RestIntegTestTask) { tasks.register('leader-cluster', RestIntegTestTask) {
mustRunAfter("precommit") mustRunAfter("precommit")
systemProperty 'tests.target_cluster', 'leader' systemProperty 'tests.target_cluster', 'leader'
/* To support taking index snapshots, we have to set path.repo setting */ /* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', repoDir.absolutePath systemProperty 'tests.path.repo', repoDir.absolutePath
} }
testClusters.'leader-cluster' { testClusters.matching { it.name == 'leader-cluster' }.configureEach {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath setting 'path.repo', repoDir.absolutePath
setting 'xpack.ccr.enabled', 'true' setting 'xpack.ccr.enabled', 'true'
@ -29,8 +30,8 @@ testClusters.'leader-cluster' {
setting 'indices.lifecycle.poll_interval', '1000ms' setting 'indices.lifecycle.poll_interval', '1000ms'
} }
task 'follow-cluster'(type: RestIntegTestTask) { tasks.register('follow-cluster', RestIntegTestTask) {
dependsOn 'leader-cluster' dependsOn tasks.findByName('leader-cluster')
useCluster testClusters.'leader-cluster' useCluster testClusters.'leader-cluster'
systemProperty 'tests.target_cluster', 'follow' systemProperty 'tests.target_cluster', 'follow'
nonInputProperties.systemProperty 'tests.leader_host', nonInputProperties.systemProperty 'tests.leader_host',
@ -41,7 +42,7 @@ task 'follow-cluster'(type: RestIntegTestTask) {
systemProperty 'tests.path.repo', repoDir.absolutePath systemProperty 'tests.path.repo', repoDir.absolutePath
} }
testClusters.'follow-cluster' { testClusters.matching{ it.name == 'follow-cluster' }.configureEach {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath setting 'path.repo', repoDir.absolutePath
setting 'xpack.ccr.enabled', 'true' setting 'xpack.ccr.enabled', 'true'
@ -54,5 +55,11 @@ testClusters.'follow-cluster' {
{ "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" } { "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" }
} }
check.dependsOn 'follow-cluster' tasks.named("check").configure { dependsOn 'follow-cluster' }
test.enabled = false // no unit tests for this module, only the rest integration test // no unit tests for this module, only the rest integration test
tasks.named("test").configure { enabled = false }
// Security is explicitly disabled for follow-cluster and leader-cluster, do not run these in FIPS mode
tasks.withType(Test).configureEach {
onlyIf { BuildParams.inFipsJvm == false}
}

View file

@ -1,4 +1,5 @@
import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.util.GradleUtils
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
@ -30,3 +31,8 @@ testClusters.all {
setting 'logger.org.elasticsearch.xpack.core.ilm', 'TRACE' setting 'logger.org.elasticsearch.xpack.core.ilm', 'TRACE'
setting 'logger.org.elasticsearch.xpack.ilm', 'TRACE' setting 'logger.org.elasticsearch.xpack.ilm', 'TRACE'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -161,14 +161,14 @@ public class PermissionsIT extends ESRestTestCase {
"\"indices\": [{ \"names\": [\".slm-history*\"],\"privileges\": [\"all\"] }] }"); "\"indices\": [{ \"names\": [\".slm-history*\"],\"privileges\": [\"all\"] }] }");
assertOK(adminClient().performRequest(roleRequest)); assertOK(adminClient().performRequest(roleRequest));
createUser("slm_admin", "slm-pass", "slm-manage"); createUser("slm_admin", "slm-admin-password", "slm-manage");
createUser("slm_user", "slm-user-pass", "slm-read"); createUser("slm_user", "slm-user-password", "slm-read");
final HighLevelClient hlAdminClient = new HighLevelClient(adminClient()); final HighLevelClient hlAdminClient = new HighLevelClient(adminClient());
// Build two high level clients, each using a different user // Build two high level clients, each using a different user
final RestClientBuilder adminBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0])); final RestClientBuilder adminBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
final String adminToken = basicAuthHeaderValue("slm_admin", new SecureString("slm-pass".toCharArray())); final String adminToken = basicAuthHeaderValue("slm_admin", new SecureString("slm-admin-password".toCharArray()));
configureClient(adminBuilder, Settings.builder() configureClient(adminBuilder, Settings.builder()
.put(ThreadContext.PREFIX + ".Authorization", adminToken) .put(ThreadContext.PREFIX + ".Authorization", adminToken)
.build()); .build());
@ -176,7 +176,7 @@ public class PermissionsIT extends ESRestTestCase {
final RestHighLevelClient adminHLRC = new RestHighLevelClient(adminBuilder); final RestHighLevelClient adminHLRC = new RestHighLevelClient(adminBuilder);
final RestClientBuilder userBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0])); final RestClientBuilder userBuilder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
final String userToken = basicAuthHeaderValue("slm_user", new SecureString("slm-user-pass".toCharArray())); final String userToken = basicAuthHeaderValue("slm_user", new SecureString("slm-user-password".toCharArray()));
configureClient(userBuilder, Settings.builder() configureClient(userBuilder, Settings.builder()
.put(ThreadContext.PREFIX + ".Authorization", userToken) .put(ThreadContext.PREFIX + ".Authorization", userToken)
.build()); .build());

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
testClusters.all { testClusters.all {
@ -11,3 +13,8 @@ testClusters.all {
setting 'indices.lifecycle.history_index_enabled', 'false' setting 'indices.lifecycle.history_index_enabled', 'false'
setting 'slm.history_index_enabled', 'false' setting 'slm.history_index_enabled', 'false'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
//dependencies { //dependencies {
@ -10,3 +12,8 @@ testClusters.all {
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.ml.enabled', 'false' setting 'xpack.ml.enabled', 'false'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -1,3 +1,5 @@
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
testClusters.all { testClusters.all {
@ -5,3 +7,8 @@ testClusters.all {
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -66,7 +66,7 @@ if (!gcsServiceAccount && !gcsBucket && !gcsBasePath) {
tasks.register("createServiceAccountFile") { tasks.register("createServiceAccountFile") {
doLast { doLast {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA") KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA")
keyPairGenerator.initialize(1024) keyPairGenerator.initialize(2048)
KeyPair keyPair = keyPairGenerator.generateKeyPair() KeyPair keyPair = keyPairGenerator.generateKeyPair()
String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded()) String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded())

View file

@ -27,8 +27,8 @@ String s3Bucket = System.getenv("amazon_s3_bucket")
String s3BasePath = System.getenv("amazon_s3_base_path") String s3BasePath = System.getenv("amazon_s3_base_path")
if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
s3AccessKey = 'access_key' s3AccessKey = 's3_test_access_key'
s3SecretKey = 'secret_key' s3SecretKey = 's3_test_secret_key'
s3Bucket = 'bucket' s3Bucket = 'bucket'
s3BasePath = null s3BasePath = null
useFixture = true useFixture = true

View file

@ -9,6 +9,8 @@ apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.rest-resources'
import org.elasticsearch.gradle.info.BuildParams
dependencies { dependencies {
testImplementation project(path: xpackModule('rollup')) testImplementation project(path: xpackModule('rollup'))
} }
@ -19,10 +21,13 @@ restResources {
includeXpack 'rollup' includeXpack 'rollup'
} }
} }
if (BuildParams.inFipsJvm){
testClusters.integTest { // This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("integTest").configure{enabled = false }
tasks.named("testingConventions").configure{enabled = false }
}
testClusters.matching { it.name == "integTest" }.configureEach {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.license.self_generated.type', 'basic' setting 'xpack.license.self_generated.type', 'basic'
systemProperty 'es.rollup_v2_feature_flag_enabled', 'true' systemProperty 'es.rollup_v2_feature_flag_enabled', 'true'
} }

View file

@ -48,7 +48,7 @@ if (!gcsServiceAccount && !gcsBucket && !gcsBasePath) {
tasks.register("createServiceAccountFile") { tasks.register("createServiceAccountFile") {
doLast { doLast {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA") KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA")
keyPairGenerator.initialize(1024) keyPairGenerator.initialize(2048)
KeyPair keyPair = keyPairGenerator.generateKeyPair() KeyPair keyPair = keyPairGenerator.generateKeyPair()
String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded()) String encodedKey = Base64.getEncoder().encodeToString(keyPair.private.getEncoded())

View file

@ -36,8 +36,8 @@ testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
plugin repositoryPlugin.path plugin repositoryPlugin.path
keystore 's3.client.searchable_snapshots.access_key', 'access_key' keystore 's3.client.searchable_snapshots.access_key', 's3_test_access_key'
keystore 's3.client.searchable_snapshots.secret_key', 'secret_key' keystore 's3.client.searchable_snapshots.secret_key', 's3_test_secret_key'
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'
setting 's3.client.searchable_snapshots.protocol', 'http' setting 's3.client.searchable_snapshots.protocol', 'http'
setting 's3.client.searchable_snapshots.endpoint', { "${-> fixtureAddress()}" }, IGNORE_VALUE setting 's3.client.searchable_snapshots.endpoint', { "${-> fixtureAddress()}" }, IGNORE_VALUE

View file

@ -27,8 +27,8 @@ String s3Bucket = System.getenv("amazon_s3_bucket")
String s3BasePath = System.getenv("amazon_s3_base_path") String s3BasePath = System.getenv("amazon_s3_base_path")
if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
s3AccessKey = 'access_key' s3AccessKey = 's3_test_access_key'
s3SecretKey = 'secret_key' s3SecretKey = 's3_test_secret_key'
s3Bucket = 'bucket' s3Bucket = 'bucket'
s3BasePath = null s3BasePath = null
useFixture = true useFixture = true

View file

@ -1,5 +1,6 @@
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
import org.elasticsearch.gradle.test.rest.JavaRestTestPlugin import org.elasticsearch.gradle.test.rest.JavaRestTestPlugin
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
@ -14,6 +15,11 @@ tasks.named("javaRestTest").configure {
systemProperty 'tests.has_security', 'false' systemProperty 'tests.has_security', 'false'
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters { testClusters {
javaRestTest { javaRestTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
@ -31,6 +37,9 @@ tasks.register("javaRestTestWithSecurity", StandaloneRestIntegTestTask) {
systemProperty 'tests.has_security', 'true' systemProperty 'tests.has_security', 'true'
testClassesDirs = sourceSets.javaRestTest.output.classesDirs testClassesDirs = sourceSets.javaRestTest.output.classesDirs
classpath = sourceSets.javaRestTest.runtimeClasspath classpath = sourceSets.javaRestTest.runtimeClasspath
onlyIf {
BuildParams.inFipsJvm == false
}
doFirst { doFirst {
testClusters.javaRestTest { testClusters.javaRestTest {
// TODO Rene: revisit if using dedicated new cluster definitions would be more efficient. // TODO Rene: revisit if using dedicated new cluster definitions would be more efficient.

View file

@ -1,12 +1,19 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
import org.elasticsearch.gradle.info.BuildParams
dependencies { dependencies {
javaRestTestImplementation project(path: xpackModule('core'), configuration: 'default') javaRestTestImplementation project(path: xpackModule('core'), configuration: 'default')
javaRestTestImplementation project(path: xpackModule('security'), configuration: 'testArtifacts') javaRestTestImplementation project(path: xpackModule('security'), configuration: 'testArtifacts')
javaRestTestImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') javaRestTestImplementation project(path: xpackModule('core'), configuration: 'testArtifacts')
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters.all { testClusters.all {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
numberOfNodes = 2 numberOfNodes = 2

View file

@ -5,6 +5,7 @@
* For example: If a cluster has a pipeline with the set_security_user processor * For example: If a cluster has a pipeline with the set_security_user processor
* defined, it should be not fail * defined, it should be not fail
*/ */
import org.elasticsearch.gradle.info.BuildParams
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
@ -24,3 +25,8 @@ testClusters.all {
setting 'xpack.license.self_generated.type', 'trial' setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
} }
if (BuildParams.inFipsJvm){
// Test clusters run with security disabled
tasks.named("javaRestTest").configure{enabled = false }
}

View file

@ -42,9 +42,9 @@ import static org.hamcrest.Matchers.notNullValue;
public class ApiKeyRestIT extends SecurityOnTrialLicenseRestTestCase { public class ApiKeyRestIT extends SecurityOnTrialLicenseRestTestCase {
private static final String SYSTEM_USER = "system_user"; private static final String SYSTEM_USER = "system_user";
private static final SecureString SYSTEM_USER_PASSWORD = new SecureString("sys-pass".toCharArray()); private static final SecureString SYSTEM_USER_PASSWORD = new SecureString("system-user-password".toCharArray());
private static final String END_USER = "end_user"; private static final String END_USER = "end_user";
private static final SecureString END_USER_PASSWORD = new SecureString("user-pass".toCharArray()); private static final SecureString END_USER_PASSWORD = new SecureString("end-user-password".toCharArray());
@Before @Before
public void createUsers() throws IOException { public void createUsers() throws IOException {

View file

@ -1,11 +1,18 @@
apply plugin: 'elasticsearch.java-rest-test' apply plugin: 'elasticsearch.java-rest-test'
import org.elasticsearch.gradle.info.BuildParams
dependencies { dependencies {
testImplementation project(path: xpackModule('core'), configuration: 'default') testImplementation project(path: xpackModule('core'), configuration: 'default')
testImplementation project(path: xpackModule('security'), configuration: 'testArtifacts') testImplementation project(path: xpackModule('security'), configuration: 'testArtifacts')
testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts')
} }
if (BuildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
testClusters.javaRestTest { testClusters.javaRestTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
numberOfNodes = 2 numberOfNodes = 2

View file

@ -12,7 +12,7 @@ import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response; import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.test.SecuritySingleNodeTestCase; import org.elasticsearch.test.SecuritySingleNodeTestCase;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
@ -94,7 +94,8 @@ public abstract class AbstractPrivilegeTestCase extends SecuritySingleNodeTestCa
private void setUser(Request request, String user) { private void setUser(Request request, String user) {
RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder(); RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder();
options.addHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue(user, new SecureString("passwd".toCharArray()))); options.addHeader("Authorization",
UsernamePasswordToken.basicAuthHeaderValue(user, SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
request.setOptions(options); request.setOptions(options);
} }
} }

View file

@ -190,8 +190,8 @@ public class ClearRealmsCacheTests extends SecurityIntegTestCase {
@Override @Override
protected String configUsers() { protected String configUsers() {
StringBuilder builder = new StringBuilder(SecuritySettingsSource.CONFIG_STANDARD_USER); StringBuilder builder = new StringBuilder(SecuritySettingsSource.CONFIG_STANDARD_USER);
final String usersPasswdHashed = new String(getFastStoredHashAlgoForTests().hash(new SecureString final String usersPasswdHashed =
("passwd".toCharArray()))); new String(getFastStoredHashAlgoForTests().hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
for (String username : usernames) { for (String username : usernames) {
builder.append(username).append(":").append(usersPasswdHashed).append("\n"); builder.append(username).append(":").append(usersPasswdHashed).append("\n");
} }
@ -223,7 +223,7 @@ public class ClearRealmsCacheTests extends SecurityIntegTestCase {
private void testScenario(Scenario scenario) throws Exception { private void testScenario(Scenario scenario) throws Exception {
Map<String, UsernamePasswordToken> tokens = new HashMap<>(); Map<String, UsernamePasswordToken> tokens = new HashMap<>();
for (String user : usernames) { for (String user : usernames) {
tokens.put(user, new UsernamePasswordToken(user, new SecureString("passwd"))); tokens.put(user, new UsernamePasswordToken(user, SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
} }
List<Realm> realms = new ArrayList<>(); List<Realm> realms = new ArrayList<>();

View file

@ -10,8 +10,8 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.client.Request; import org.elasticsearch.client.Request;
import org.elasticsearch.cluster.SnapshotsInProgress; import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.authc.support.Hasher;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.AfterClass; import org.junit.AfterClass;
@ -79,8 +79,8 @@ public class ClusterPrivilegeIntegrationTests extends AbstractPrivilegeTestCase
@Override @Override
protected String configUsers() { protected String configUsers() {
final String usersPasswdHashed = new String(Hasher.resolve( final Hasher passwdHasher = getFastStoredHashAlgoForTests();
randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9")).hash(new SecureString("passwd".toCharArray()))); final String usersPasswdHashed = new String(passwdHasher.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
return super.configUsers() + return super.configUsers() +
"user_a:" + usersPasswdHashed + "\n" + "user_a:" + usersPasswdHashed + "\n" +
"user_b:" + usersPasswdHashed + "\n" + "user_b:" + usersPasswdHashed + "\n" +

View file

@ -7,7 +7,7 @@
package org.elasticsearch.integration; package org.elasticsearch.integration;
import org.elasticsearch.client.Request; import org.elasticsearch.client.Request;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.authc.support.Hasher;
import org.junit.Before; import org.junit.Before;
@ -43,8 +43,8 @@ public class CreateDocsIndexPrivilegeTests extends AbstractPrivilegeTestCase {
@Override @Override
protected String configUsers() { protected String configUsers() {
final String usersPasswdHashed = new String(Hasher.resolve( final Hasher passwdHasher = getFastStoredHashAlgoForTests();
randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9")).hash(new SecureString("passwd".toCharArray()))); final String usersPasswdHashed = new String(passwdHasher.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
return super.configUsers() + return super.configUsers() +
"admin:" + usersPasswdHashed + "\n" + "admin:" + usersPasswdHashed + "\n" +

View file

@ -22,6 +22,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import java.util.Collections; import java.util.Collections;
@ -33,7 +34,7 @@ import static org.hamcrest.Matchers.is;
public class DateMathExpressionIntegTests extends SecurityIntegTestCase { public class DateMathExpressionIntegTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
protected String configUsers() { protected String configUsers() {

View file

@ -24,6 +24,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import java.util.Arrays; import java.util.Arrays;
@ -44,7 +45,7 @@ import static org.hamcrest.Matchers.is;
public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase { public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
protected String configUsers() { protected String configUsers() {

View file

@ -11,6 +11,7 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
@ -25,7 +26,7 @@ import static org.hamcrest.Matchers.equalTo;
public class DocumentLevelSecurityRandomTests extends SecurityIntegTestCase { public class DocumentLevelSecurityRandomTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
// can't add a second test method, because each test run creates a new instance of this class and that will will result // can't add a second test method, because each test run creates a new instance of this class and that will will result
// in a new random value: // in a new random value:

View file

@ -60,6 +60,7 @@ import org.elasticsearch.search.suggest.term.TermSuggestion;
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; import org.elasticsearch.search.suggest.term.TermSuggestionBuilder;
import org.elasticsearch.test.InternalSettingsPlugin; import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction; import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction;
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest; import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest;
@ -97,7 +98,7 @@ import static org.hamcrest.Matchers.notNullValue;
@LuceneTestCase.SuppressCodecs("*") // suppress test codecs otherwise test using completion suggester fails @LuceneTestCase.SuppressCodecs("*") // suppress test codecs otherwise test using completion suggester fails
public class DocumentLevelSecurityTests extends SecurityIntegTestCase { public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
protected Collection<Class<? extends Plugin>> nodePlugins() { protected Collection<Class<? extends Plugin>> nodePlugins() {

View file

@ -11,6 +11,7 @@ import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
@ -32,7 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
public class FieldLevelSecurityRandomTests extends SecurityIntegTestCase { public class FieldLevelSecurityRandomTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
private static Set<String> allowedFields; private static Set<String> allowedFields;
private static Set<String> disAllowedFields; private static Set<String> disAllowedFields;

View file

@ -47,6 +47,7 @@ import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalSettingsPlugin; import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction; import org.elasticsearch.xpack.core.search.action.ClosePointInTimeAction;
import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest; import org.elasticsearch.xpack.core.search.action.ClosePointInTimeRequest;
@ -87,7 +88,7 @@ import static org.hamcrest.Matchers.nullValue;
@ESIntegTestCase.ClusterScope @ESIntegTestCase.ClusterScope
public class FieldLevelSecurityTests extends SecurityIntegTestCase { public class FieldLevelSecurityTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
protected Collection<Class<? extends Plugin>> nodePlugins() { protected Collection<Class<? extends Plugin>> nodePlugins() {

View file

@ -11,6 +11,7 @@ import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.authc.support.Hasher;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
import org.junit.Before; import org.junit.Before;
@ -120,8 +121,8 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
@Override @Override
protected String configUsers() { protected String configUsers() {
final String usersPasswdHashed = new String(Hasher.resolve( final Hasher passwdHasher = getFastStoredHashAlgoForTests();
randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9")).hash(new SecureString("passwd".toCharArray()))); final String usersPasswdHashed = new String(passwdHasher.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
return super.configUsers() + return super.configUsers() +
"admin:" + usersPasswdHashed + "\n" + "admin:" + usersPasswdHashed + "\n" +

View file

@ -9,6 +9,7 @@ import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
@ -22,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo;
public class IndicesPermissionsWithAliasesWildcardsAndRegexsTests extends SecurityIntegTestCase { public class IndicesPermissionsWithAliasesWildcardsAndRegexsTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
protected String configUsers() { protected String configUsers() {

View file

@ -11,6 +11,7 @@ import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
import java.util.Locale; import java.util.Locale;
@ -21,7 +22,7 @@ import static org.hamcrest.Matchers.is;
public class KibanaSystemRoleIntegTests extends SecurityIntegTestCase { public class KibanaSystemRoleIntegTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
public String configUsers() { public String configUsers() {

View file

@ -17,6 +17,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.NativeRealmIntegTestCase; import org.elasticsearch.test.NativeRealmIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
import java.util.Map; import java.util.Map;
@ -32,7 +33,7 @@ import static org.hamcrest.Matchers.notNullValue;
public class KibanaUserRoleIntegTests extends NativeRealmIntegTestCase { public class KibanaUserRoleIntegTests extends NativeRealmIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("change_me".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Override @Override
public String configRoles() { public String configRoles() {

View file

@ -24,6 +24,7 @@ import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSource; import org.elasticsearch.test.SecuritySettingsSource;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.authc.support.Hasher;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
import org.junit.After; import org.junit.After;
@ -42,12 +43,12 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase { public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase {
protected static final SecureString USERS_PASSWD = new SecureString("passwd".toCharArray()); protected static final SecureString USERS_PASSWD = SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
@Before @Before
public void waitForSecurityIndexWritable() throws Exception { public void waitForSecurityIndexWritable() throws Exception {
// adds a dummy user to the native realm to force .security index creation // adds a dummy user to the native realm to force .security index creation
securityClient().preparePutUser("dummy_user", "password".toCharArray(), Hasher.BCRYPT, "missing_role").get(); securityClient().preparePutUser("dummy_user", "dummy_user_password".toCharArray(), Hasher.BCRYPT, "missing_role").get();
assertSecurityIndexActive(); assertSecurityIndexActive();
} }

View file

@ -13,6 +13,7 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata;
import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSourceField;
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken; import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
import java.util.Collections; import java.util.Collections;
@ -49,7 +50,8 @@ public class PermissionPrecedenceTests extends SecurityIntegTestCase {
@Override @Override
protected String configUsers() { protected String configUsers() {
final String usersPasswdHashed = new String(getFastStoredHashAlgoForTests().hash(new SecureString("test123".toCharArray()))); final String usersPasswdHashed =
new String(getFastStoredHashAlgoForTests().hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
return "admin:" + usersPasswdHashed + "\n" + return "admin:" + usersPasswdHashed + "\n" +
"client:" + usersPasswdHashed + "\n" + "client:" + usersPasswdHashed + "\n" +
"user:" + usersPasswdHashed + "\n"; "user:" + usersPasswdHashed + "\n";
@ -69,7 +71,7 @@ public class PermissionPrecedenceTests extends SecurityIntegTestCase {
@Override @Override
protected SecureString nodeClientPassword() { protected SecureString nodeClientPassword() {
return new SecureString("test123".toCharArray()); return SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
} }
@Override @Override
@ -79,7 +81,7 @@ public class PermissionPrecedenceTests extends SecurityIntegTestCase {
@Override @Override
protected SecureString transportClientPassword() { protected SecureString transportClientPassword() {
return new SecureString("test123".toCharArray()); return SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING;
} }
public void testDifferentCombinationsOfIndices() throws Exception { public void testDifferentCombinationsOfIndices() throws Exception {
@ -108,7 +110,7 @@ public class PermissionPrecedenceTests extends SecurityIntegTestCase {
.setPatterns(Collections.singletonList("test_*"))::get, PutIndexTemplateAction.NAME, "user"); .setPatterns(Collections.singletonList("test_*"))::get, PutIndexTemplateAction.NAME, "user");
Map<String, String> headers = Collections.singletonMap(UsernamePasswordToken.BASIC_AUTH_HEADER, basicAuthHeaderValue("user", Map<String, String> headers = Collections.singletonMap(UsernamePasswordToken.BASIC_AUTH_HEADER, basicAuthHeaderValue("user",
new SecureString("test123"))); SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING));
assertThrowsAuthorizationException(client.filterWithHeader(headers).admin().indices().prepareGetTemplates("template1")::get, assertThrowsAuthorizationException(client.filterWithHeader(headers).admin().indices().prepareGetTemplates("template1")::get,
GetIndexTemplatesAction.NAME, "user"); GetIndexTemplatesAction.NAME, "user");
} }

Some files were not shown because too many files have changed in this diff Show more