diff --git a/src/test/java/org/opensearch/security/ssl/SslContextHandlerTest.java b/src/test/java/org/opensearch/security/ssl/SslContextHandlerTest.java index c250b83583..803b1c846f 100644 --- a/src/test/java/org/opensearch/security/ssl/SslContextHandlerTest.java +++ b/src/test/java/org/opensearch/security/ssl/SslContextHandlerTest.java @@ -76,8 +76,11 @@ void writeCertificates( @Test public void failsIfCertificatesAreSame() throws Exception { final var sslContextHandler = sslContextHandler(); - final var e = assertThrows(CertificateException.class, sslContextHandler::reloadSslContext); - assertThat(e.getMessage(), is("Existing certificates are the same as new one")); + + final var sslContextBefore = sslContextHandler.sslContext(); + sslContextHandler.reloadSslContext(); + + assertThat("SSL Context is the same", sslContextBefore.equals(sslContextHandler.sslContext())); } @Test @@ -100,7 +103,7 @@ public void failsIfCertificatesNasNotValidDates() throws Exception { newAccessCertificate = certificatesRule.generateAccessCertificate( keyPair, accessCertificate.getNotBefore().toInstant().plus(10, ChronoUnit.DAYS), - accessCertificate.getNotAfter().toInstant() + accessCertificate.getNotAfter().toInstant().plus(20, ChronoUnit.DAYS) ); writeCertificates(newCaCertificate, newAccessCertificate.v2(), newAccessCertificate.v1()); diff --git a/src/test/java/org/opensearch/security/ssl/config/SslCertificatesLoaderTest.java b/src/test/java/org/opensearch/security/ssl/config/SslCertificatesLoaderTest.java index 04c65061bf..c2c6961430 100644 --- a/src/test/java/org/opensearch/security/ssl/config/SslCertificatesLoaderTest.java +++ b/src/test/java/org/opensearch/security/ssl/config/SslCertificatesLoaderTest.java @@ -25,6 +25,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.notNullValue; public abstract class SslCertificatesLoaderTest extends RandomizedTest { @@ -47,7 +48,7 @@ void assertTrustStoreConfiguration( ) { assertThat("Truststore configuration created", nonNull(trustStoreConfiguration)); assertThat(trustStoreConfiguration.file(), is(expectedFile)); - assertThat(trustStoreConfiguration.certificates(), contains(expectedCertificates)); + assertThat(trustStoreConfiguration.certificates(), containsInAnyOrder(expectedCertificates)); assertThat(trustStoreConfiguration.createTrustManagerFactory(), is(notNullValue())); } @@ -58,7 +59,7 @@ void assertKeyStoreConfiguration( ) { assertThat("Keystore configuration created", nonNull(keyStoreConfiguration)); assertThat(keyStoreConfiguration.files(), contains(expectedFiles.toArray(new Path[0]))); - assertThat(keyStoreConfiguration.certificates(), contains(expectedCertificates)); + assertThat(keyStoreConfiguration.certificates(), containsInAnyOrder(expectedCertificates)); assertThat(keyStoreConfiguration.createKeyManagerFactory(), is(notNullValue())); }