diff options
author | Boslet, Cory <cory.boslet@att.com> | 2019-05-17 10:06:55 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-05-17 10:07:03 -0400 |
commit | 8ae4003f892a95dd76e9370d430548d57a35f82c (patch) | |
tree | 560292d78f2f1cb6387af1fc8fa9a47d99c62cbd /adapters/mso-openstack-adapters/src/test/java | |
parent | 24ad9609469cb7325c629e1efcdeec494bfecd7c (diff) |
Audit service enhancements
Update number of threads used for openstack audit
Refactored post construct audit service and added junits
Change-Id: Ic5bd42cda98835305d2e2d5d09a5c039376316a5
Issue-ID: SO-1898
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test/java')
-rw-r--r-- | adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java new file mode 100644 index 0000000000..2eb8d8ef39 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java @@ -0,0 +1,71 @@ +package org.onap.so.adapters.audit; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.camunda.bpm.client.ExternalTaskClient; +import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; +import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.utils.CryptoUtils; +import org.springframework.core.env.Environment; + +@RunWith(MockitoJUnitRunner.class) +public class AuditStackServiceTest { + + @Spy + @InjectMocks + AuditStackService auditStackService; + + @Mock + Environment mockEnvironment; + + + @Before + public void before() { + Mockito.doReturn("5").when(mockEnvironment).getProperty("workflow.topics.maxClients", "10"); + Mockito.doReturn("6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436") + .when(mockEnvironment).getRequiredProperty("mso.auth"); + Mockito.doReturn("07a7159d3bf51a0e53be7a8f89699be7").when(mockEnvironment).getRequiredProperty("mso.msoKey"); + Mockito.doReturn("something").when(mockEnvironment).getRequiredProperty("mso.config.cadi.aafId"); + Mockito.doReturn("host.com").when(mockEnvironment).getRequiredProperty("mso.workflow.endpoint"); + } + + @Test + public void testGetMaxClients() throws Exception { + int actual = auditStackService.getMaxClients(); + assertEquals(5, actual); + } + + @Test + public void testCreateClientRequestInterceptor() throws Exception { + String auth = CryptoUtils.decrypt( + "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436", + "07a7159d3bf51a0e53be7a8f89699be7"); + ClientRequestInterceptor expected = new BasicAuthProvider("something", auth); + ClientRequestInterceptor actual = auditStackService.createClientRequestInterceptor(); + assertThat(actual, sameBeanAs(expected)); + + } + + @Test + public void testCreateExternalTaskClient() throws Exception { + String auth = CryptoUtils.decrypt( + "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436", + "07a7159d3bf51a0e53be7a8f89699be7"); + ClientRequestInterceptor inter = new BasicAuthProvider("something", auth); + Mockito.doReturn(inter).when(auditStackService).createClientRequestInterceptor(); + ExternalTaskClient actual = auditStackService.createExternalTaskClient(); + assertNotNull(actual); + Mockito.verify(auditStackService, Mockito.times(1)).createClientRequestInterceptor(); + + } +} |