[SDK] Increase code coveredge 86/132586/2
authorTomasz Wrobel <tomasz.wrobel@nokia.com>
Mon, 5 Dec 2022 20:44:02 +0000 (21:44 +0100)
committerTomasz Wrobel <tomasz.wrobel@nokia.com>
Tue, 6 Dec 2022 07:49:31 +0000 (08:49 +0100)
Issue-ID: DCAEGEN2-3165
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: I76ba5e8cf4e5b1525ef7aab8bc9e18b46d540dab

Changelog.md
security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactoryTest.java

index 81ad123..3d6c993 100644 (file)
@@ -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
index 088c721..e3605e2 100644 (file)
@@ -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()));
     }
+
 }