From 751994b3d0b67fbebd83d97ef4faa8ce8bc10505 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 7 Sep 2018 13:20:40 +0900 Subject: Ansible ConnectionBuilder cert based test Issue-ID: CCSDK-521 Change-Id: I5c1b4b86ff8c23c3c8a96bf2f217dd8d86b8261f Signed-off-by: Ganesh Chandrasekaran --- .../ansible/impl/TestConnectionBuilder.java | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'ansible-adapter/ansible-adapter-bundle/src/test/java') diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/ccsdk/adapter/ansible/impl/TestConnectionBuilder.java b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/ccsdk/adapter/ansible/impl/TestConnectionBuilder.java index 2a60adbc..c94655f5 100644 --- a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/ccsdk/adapter/ansible/impl/TestConnectionBuilder.java +++ b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/ccsdk/adapter/ansible/impl/TestConnectionBuilder.java @@ -99,7 +99,7 @@ public class TestConnectionBuilder { } @Test (expected = FileNotFoundException.class) - public void testGetModeCert() + public void testGetModeNoCert() throws KeyStoreException, CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, SvcLogicException { String user = "testUser"; @@ -116,4 +116,40 @@ public class TestConnectionBuilder { assertEquals("UNKNOWN", result.getResults()); } + @Test + public void testGetModeCert() + throws KeyStoreException, CertificateException, IOException, + KeyManagementException, NoSuchAlgorithmException, SvcLogicException { + String user = "testUser"; + String pass = "testPassword"; + String agentUrl = "test/server.com"; + String certFile = "src/test/resources/cert"; + + builder = new ConnectionBuilder(certFile); + builder.setHttpContext(user, pass); + AnsibleResult result = builder.get(agentUrl); + + assertEquals(611, result.getStatusCode()); + assertEquals(null, result.getStatusMessage()); + assertEquals("UNKNOWN", result.getResults()); + } + + @Test (expected = IOException.class) + public void testGetModeStore() + throws KeyStoreException, CertificateException, IOException, + KeyManagementException, NoSuchAlgorithmException, SvcLogicException { + String user = "testUser"; + String pass = "testPassword"; + String agentUrl = "test/server.com"; + String store = "src/test/resources/cert"; + + builder = new ConnectionBuilder(store, new char['t'] ); + builder.setHttpContext(user, pass); + AnsibleResult result = builder.get(agentUrl); + + assertEquals(611, result.getStatusCode()); + assertEquals(null, result.getStatusMessage()); + assertEquals("UNKNOWN", result.getResults()); + } + } -- cgit 1.2.3-korg