Skip to content

Commit

Permalink
fix RepositoryS3RestReloadCredentialsIT
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Nov 28, 2024
1 parent ce54a80 commit 0809994
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ protected String getTestRestCluster() {
}

public void testReloadCredentialsFromKeystore() throws IOException {
assumeFalse("doesn't work in a FIPS JVM, but that's ok", inFipsJvm());

// Register repository (?verify=false because we don't have access to the blob store yet)
final var repositoryName = randomIdentifier();
registerRepository(
Expand All @@ -77,15 +75,21 @@ public void testReloadCredentialsFromKeystore() throws IOException {
final var accessKey1 = randomIdentifier();
repositoryAccessKey = accessKey1;
keystoreSettings.put("s3.client.default.access_key", accessKey1);
keystoreSettings.put("s3.client.default.secret_key", randomIdentifier());
keystoreSettings.put("s3.client.default.secret_key", randomSecretKey());
cluster.updateStoredSecureSettings();
assertOK(client().performRequest(new Request("POST", "/_nodes/reload_secure_settings")));
final Request reloadSecureSettingsRequest = new Request("POST", "/_nodes/reload_secure_settings");
reloadSecureSettingsRequest.setJsonEntity("""
{
"secure_settings_password": "keystore-password"
}
""");
assertOK(client().performRequest(reloadSecureSettingsRequest));

// Check access using initial credentials
assertOK(client().performRequest(verifyRequest));

// Rotate credentials in blob store
final var accessKey2 = randomValueOtherThan(accessKey1, ESTestCase::randomIdentifier);
final var accessKey2 = randomValueOtherThan(accessKey1, ESTestCase::randomSecretKey);
repositoryAccessKey = accessKey2;

// Ensure that initial credentials now invalid
Expand All @@ -99,7 +103,7 @@ public void testReloadCredentialsFromKeystore() throws IOException {
// Set up refreshed credentials
keystoreSettings.put("s3.client.default.access_key", accessKey2);
cluster.updateStoredSecureSettings();
assertOK(client().performRequest(new Request("POST", "/_nodes/reload_secure_settings")));
assertOK(client().performRequest(reloadSecureSettingsRequest));

// Check access using refreshed credentials
assertOK(client().performRequest(verifyRequest));
Expand Down

0 comments on commit 0809994

Please sign in to comment.