Home / Class/ SslManagerBundleTests Class — spring-boot Architecture

SslManagerBundleTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/ssl/SslManagerBundleTests.java lines 37–108

class SslManagerBundleTests {

	private final KeyManagerFactory keyManagerFactory = mock(KeyManagerFactory.class);

	private final TrustManagerFactory trustManagerFactory = mock(TrustManagerFactory.class);

	@Test
	void getKeyManagersDelegatesToFactory() {
		SslManagerBundle bundle = SslManagerBundle.of(this.keyManagerFactory, this.trustManagerFactory);
		bundle.getKeyManagers();
		then(this.keyManagerFactory).should().getKeyManagers();
	}

	@Test
	void getTrustManagersDelegatesToFactory() {
		SslManagerBundle bundle = SslManagerBundle.of(this.keyManagerFactory, this.trustManagerFactory);
		bundle.getTrustManagers();
		then(this.trustManagerFactory).should().getTrustManagers();
	}

	@Test
	void createSslContextCreatesInitializedSslContext() {
		SslManagerBundle bundle = SslManagerBundle.of(this.keyManagerFactory, this.trustManagerFactory);
		SSLContext sslContext = bundle.createSslContext("TLS");
		assertThat(sslContext).isNotNull();
		assertThat(sslContext.getProtocol()).isEqualTo("TLS");
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenKeyManagerFactoryIsNullThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> SslManagerBundle.of(null, this.trustManagerFactory))
			.withMessage("'keyManagerFactory' must not be null");
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenTrustManagerFactoryIsNullThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> SslManagerBundle.of(this.keyManagerFactory, null))
			.withMessage("'trustManagerFactory' must not be null");
	}

	@Test
	void ofCreatesSslManagerBundle() {
		SslManagerBundle bundle = SslManagerBundle.of(this.keyManagerFactory, this.trustManagerFactory);
		assertThat(bundle.getKeyManagerFactory()).isSameAs(this.keyManagerFactory);
		assertThat(bundle.getTrustManagerFactory()).isSameAs(this.trustManagerFactory);
	}

	@Test
	void fromCreatesDefaultSslManagerBundle() {
		SslManagerBundle bundle = SslManagerBundle.from(SslStoreBundle.NONE, SslBundleKey.NONE);
		assertThat(bundle).isInstanceOf(DefaultSslManagerBundle.class);
	}

	@Test
	void shouldReturnTrustManagerFactory() {
		SslManagerBundle bundle = SslManagerBundle.from(this.trustManagerFactory);
		assertThat(bundle.getKeyManagerFactory()).isNotNull();
		assertThat(bundle.getTrustManagerFactory()).isSameAs(this.trustManagerFactory);
	}

	@Test
	void shouldReturnTrustManagers() {
		TrustManager trustManager1 = mock(TrustManager.class);
		TrustManager trustManager2 = mock(TrustManager.class);
		SslManagerBundle bundle = SslManagerBundle.from(trustManager1, trustManager2);
		assertThat(bundle.getKeyManagerFactory()).isNotNull();
		assertThat(bundle.getTrustManagerFactory().getTrustManagers()).containsExactly(trustManager1, trustManager2);
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free