Skip to content

Commit 582ac36

Browse files
ywangdtvernum
andauthored
[Test] Adjust assertions ReloadSecureSettings test for FIPS jvm (#66965) (#66966)
When the JVM is configured to be in FIPS mode, the reload security settings API returns a different error message that is specific to FIPS when given an empty password. This PR adjust the assertions so that they are matched correspondingly. Co-authored-by: Tim Vernum <[email protected]>
1 parent ed13a9e commit 582ac36

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

x-pack/qa/password-protected-keystore/src/test/java/org/elasticsearch/password_protected_keystore/ReloadSecureSettingsWithPasswordProtectedKeystoreRestIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
1717
import static org.hamcrest.Matchers.anyOf;
18+
import static org.hamcrest.Matchers.containsString;
1819
import static org.hamcrest.Matchers.equalTo;
1920
import static org.hamcrest.Matchers.instanceOf;
2021
import static org.hamcrest.Matchers.nullValue;
@@ -79,8 +80,13 @@ public void testReloadSecureSettingsWithEmptyPassword() throws Exception {
7980
assertThat(node.get("reload_exception"), instanceOf(Map.class));
8081
assertThat(ObjectPath.eval("reload_exception.reason", node), anyOf(
8182
equalTo("Provided keystore password was incorrect"),
82-
equalTo("Keystore has been corrupted or tampered with")));
83-
assertThat(ObjectPath.eval("reload_exception.type", node), equalTo("security_exception"));
83+
equalTo("Keystore has been corrupted or tampered with"),
84+
containsString("Error generating an encryption key from the provided password") // FIPS
85+
));
86+
assertThat(ObjectPath.eval("reload_exception.type", node),
87+
// Depends on exact security provider (eg Sun vs BCFIPS)
88+
anyOf(equalTo("security_exception"), equalTo("general_security_exception"))
89+
);
8490
}
8591
}
8692

0 commit comments

Comments
 (0)