aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorpkaras <piotr.karas@nokia.com>2019-05-31 12:42:52 +0200
committerpkaras <piotr.karas@nokia.com>2019-05-31 15:21:56 +0200
commitac2041bbd4f3f7212f91b75bc72d3735b6bc3642 (patch)
tree74a37647b1d87e380f08e7f734371bc2bb83376e /src/test/java
parent45ccf584c8574e9f96dd6fa3b8016accf24fc541 (diff)
AafPermissionService refactor
Change-Id: I7c1fecf232f86b4352d24b26ae3b8da47559c428 Issue-ID: DMAAP-1211 Signed-off-by: piotr.karas <piotr.karas@nokia.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/AafPermissionServiceTest.java30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/AafPermissionServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/AafPermissionServiceTest.java
index 1bba2bf..bad66b8 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/AafPermissionServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/AafPermissionServiceTest.java
@@ -39,6 +39,8 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status.INVALID;
+import static org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status.VALID;
@RunWith(JUnitParamsRunner.class)
public class AafPermissionServiceTest {
@@ -70,87 +72,87 @@ public class AafPermissionServiceTest {
@Test
@Parameters({"201", "409"})
public void shouldAssignClientToRole(int aafServiceReturnedCode) {
- ApiError apiError = new ApiError();
AafUserRole userRole = new AafUserRole(IDENTITY, ROLE);
given(aafService.addUserRole(userRole)).willReturn(aafServiceReturnedCode);
- aafPermissionService.assignIdentityToRole(mrClient, ROLE, apiError);
+ ApiError apiError = aafPermissionService.assignClientToRole(mrClient, ROLE);
then(aafService).should().addUserRole(userRole);
+ then(mrClient).should().setStatus(VALID);
assertOkStatus(apiError);
}
@Test
public void shouldReturnErrorStatusWhenClientWasNotAssignedToRole() {
- ApiError apiError = new ApiError();
AafUserRole userRole = new AafUserRole(IDENTITY, ROLE);
given(aafService.addUserRole(userRole)).willReturn(INTERNAL_SERVER_ERROR);
- aafPermissionService.assignIdentityToRole(mrClient, ROLE, apiError);
+ ApiError apiError = aafPermissionService.assignClientToRole(mrClient, ROLE);
+ then(mrClient).should().setStatus(INVALID);
assertErrorStatus(apiError, INTERNAL_SERVER_ERROR);
}
@Test
@Parameters({"201", "409"})
public void shouldGrantActionPermissionForClientRole(int aafServiceReturnedCode) {
- ApiError apiError = new ApiError();
DmaapGrant grant = new DmaapGrant(new DmaapPerm(TOPIC_PERM, ":topic." + FQTN, PUB_ACTION), ROLE);
given(mrClient.getClientRole()).willReturn(ROLE);
given(aafService.addGrant(grant)).willReturn(aafServiceReturnedCode);
- aafPermissionService.grantClientRolePerms(mrClient, apiError);
+ ApiError apiError = aafPermissionService.grantClientRolePerms(mrClient);
then(aafService).should().addGrant(grant);
+ then(mrClient).should().setStatus(VALID);
assertOkStatus(apiError);
}
@Test
public void shouldReturnErrorStatusWhenPermissionWasNotGrantToRole() {
- ApiError apiError = new ApiError();
DmaapGrant grant = new DmaapGrant(new DmaapPerm(TOPIC_PERM, ":topic." + FQTN, PUB_ACTION), ROLE);
given(mrClient.getClientRole()).willReturn(ROLE);
given(aafService.addGrant(grant)).willReturn(INTERNAL_SERVER_ERROR);
- aafPermissionService.grantClientRolePerms(mrClient, apiError);
+ ApiError apiError = aafPermissionService.grantClientRolePerms(mrClient);
+ then(mrClient).should().setStatus(INVALID);
assertErrorStatus(apiError, INTERNAL_SERVER_ERROR);
}
@Test
public void shouldReturnOkStatusWhenClientRoleIsNull() {
- ApiError apiError = new ApiError();
given(mrClient.getClientRole()).willReturn(null);
- aafPermissionService.grantClientRolePerms(mrClient, apiError);
+ ApiError apiError = aafPermissionService.grantClientRolePerms(mrClient);
verifyZeroInteractions(aafService);
+ then(mrClient).should().setStatus(VALID);
assertOkStatus(apiError);
}
@Test
@Parameters({"200", "404"})
public void shouldRevokeActionPermissionForClientRole(int aafServiceReturnedCode) {
- ApiError apiError = new ApiError();
DmaapGrant grant = new DmaapGrant(new DmaapPerm(TOPIC_PERM, ":topic." + FQTN, PUB_ACTION), ROLE);
given(mrClient.getClientRole()).willReturn(ROLE);
given(aafService.delGrant(grant)).willReturn(aafServiceReturnedCode);
- aafPermissionService.revokeClientPerms(mrClient, apiError);
+ ApiError apiError = aafPermissionService.revokeClientPerms(mrClient);
then(aafService).should().delGrant(grant);
+ then(mrClient).should().setStatus(VALID);
assertOkStatus(apiError);
}
@Test
public void shouldReturnErrorStatusWhenPermissionWasNotRevokedFromRole() {
- ApiError apiError = new ApiError();
DmaapGrant grant = new DmaapGrant(new DmaapPerm(TOPIC_PERM, ":topic." + FQTN, PUB_ACTION), ROLE);
given(mrClient.getClientRole()).willReturn(ROLE);
given(aafService.delGrant(grant)).willReturn(INTERNAL_SERVER_ERROR);
- aafPermissionService.revokeClientPerms(mrClient, apiError);
+ ApiError apiError = aafPermissionService.revokeClientPerms(mrClient);
+ then(mrClient).should().setStatus(INVALID);
assertErrorStatus(apiError, INTERNAL_SERVER_ERROR);
}