From d4bd1587ce3ea956d8ee44dc7902050c528604c5 Mon Sep 17 00:00:00 2001 From: Tomasz Wrobel Date: Mon, 5 Dec 2022 21:44:02 +0100 Subject: [SDK] Increase code coveredge Issue-ID: DCAEGEN2-3165 Signed-off-by: Tomasz Wrobel Change-Id: I76ba5e8cf4e5b1525ef7aab8bc9e18b46d540dab --- Changelog.md | 2 +- .../services/sdk/security/ssl/SslFactoryTest.java | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 81ad1232..3d6c993a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.9.1] - 2022/09/07 ### Added - [DCAEGEN2-3165] (https://jira.onap.org/browse/DCAEGEN2-3165) - Fix calculation of code coverage - - [DCAEGEN2-3165] (https://jira.onap.org/browse/DCAEGEN2-3165) - increase code coverage + - [DCAEGEN2-3165] (https://jira.onap.org/browse/DCAEGEN2-3165) - increase code coverage ## [1.9.0] - 2022/09/07 ### Added 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())); } + } -- cgit 1.2.3-korg