Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Pleskach <[email protected]>
  • Loading branch information
willyborankin committed Aug 23, 2024
1 parent b353893 commit b94eba4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()));
}

Expand All @@ -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()));
}

Expand Down

0 comments on commit b94eba4

Please sign in to comment.