Home / Class/ PemSslStoreTests Class — spring-boot Architecture

PemSslStoreTests Class — spring-boot Architecture

Architecture documentation for the PemSslStoreTests class in PemSslStoreTests.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/ssl/pem/PemSslStoreTests.java lines 35–79

class PemSslStoreTests {

	@Test
	void withAliasReturnsStoreWithNewAlias() {
		List<X509Certificate> certificates = List.of(mock(X509Certificate.class));
		PrivateKey privateKey = mock(PrivateKey.class);
		PemSslStore store = PemSslStore.of("type", "alias", "secret", certificates, privateKey);
		assertThat(store.withAlias("newalias").alias()).isEqualTo("newalias");
	}

	@Test
	void withPasswordReturnsStoreWithNewPassword() {
		List<X509Certificate> certificates = List.of(mock(X509Certificate.class));
		PrivateKey privateKey = mock(PrivateKey.class);
		PemSslStore store = PemSslStore.of("type", "alias", "secret", certificates, privateKey);
		assertThat(store.withPassword("newsecret").password()).isEqualTo("newsecret");
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenNullCertificatesThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> PemSslStore.of(null, null, null, null, null))
			.withMessage("'certificates' must not be empty");
	}

	@Test
	void ofWhenEmptyCertificatesThrowsException() {
		assertThatIllegalArgumentException()
			.isThrownBy(() -> PemSslStore.of(null, null, null, Collections.emptyList(), null))
			.withMessage("'certificates' must not be empty");
	}

	@Test
	void ofReturnsPemSslStore() {
		List<X509Certificate> certificates = List.of(mock(X509Certificate.class));
		PrivateKey privateKey = mock(PrivateKey.class);
		PemSslStore store = PemSslStore.of("type", "alias", "password", certificates, privateKey);
		assertThat(store.type()).isEqualTo("type");
		assertThat(store.alias()).isEqualTo("alias");
		assertThat(store.password()).isEqualTo("password");
		assertThat(store.certificates()).isEqualTo(certificates);
		assertThat(store.privateKey()).isEqualTo(privateKey);
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free