diff options
author | Tomasz Wrobel <tomasz.wrobel@nokia.com> | 2022-12-05 21:44:02 +0100 |
---|---|---|
committer | Tomasz Wrobel <tomasz.wrobel@nokia.com> | 2022-12-06 08:49:31 +0100 |
commit | d4bd1587ce3ea956d8ee44dc7902050c528604c5 (patch) | |
tree | 7e6508b75566384702109aa5e2419eafcafa94ac /security | |
parent | aa199470f2bbaac66d09c80098c27392fee2d507 (diff) |
[SDK] Increase code coveredge
Issue-ID: DCAEGEN2-3165
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: I76ba5e8cf4e5b1525ef7aab8bc9e18b46d540dab
Diffstat (limited to 'security')
-rw-r--r-- | security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java b/security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java index 088c7219..e3605e21 100644 --- a/security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java +++ b/security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java @@ -28,6 +28,7 @@ import java.net.URISyntaxException; import java.nio.file.Paths; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.onap.dcaegen2.services.sdk.security.ssl.Passwords.fromResource; @@ -88,8 +89,30 @@ class SslFactoryTest { .hasMessageContaining("Keystore was tampered with, or password was incorrect"); } + @Test + void testCreateInsecureClient () { + assertThatCode(() -> sut.createInsecureClientContext()) + .doesNotThrowAnyException(); + } + + @Test + void testCreateSecureClientContextFromSecurityKeys() throws Exception { + // given + final SecurityKeys securityKeys = ImmutableSecurityKeys.builder() + .keyStore(keyStoreFromResource("/sample/cert.jks")) + .keyStorePassword(fromResource("/sample/jks.pass")) + .trustStore(keyStoreFromResource("/sample/trust.jks")) + .trustStorePassword(fromResource("/sample/trust.pass")) + .build(); + + // when + assertThatCode(() -> sut.createSecureClientContext(securityKeys)) + .doesNotThrowAnyException(); + } + private @NotNull SecurityKeysStore keyStoreFromResource(String resource) throws URISyntaxException { return SecurityKeysStore.fromPath( Paths.get(Passwords.class.getResource(resource).toURI())); } + } |