import static org.mockito.BDDMockito.then;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verifyZeroInteractions;
@RunWith(JUnitParamsRunner.class)
assertEquals(CREATED, status);
}
- @Test
- public void shouldDeleteDmaapGrant() {
- DmaapGrant grant = new DmaapGrant(new DmaapPerm("perm", "type", "action"), "roles");
-
- int status = aafService.delGrant(grant);
-
- then(aafConnection).should().delAaf(grant, AAF_URL + "authz/role/:" + grant.getRole() + "/perm");
- assertEquals(OK, status);
- }
-
@Test
public void shouldNotConnectToAafDuringCreate() {
aafService = new AafServiceImpl(false, AAF_URL, IDENTITY, aafConnection);
assertEquals(CREATED, status);
}
- @Test
- public void shouldNotConnectToAafDuringDelete() {
- aafService = new AafServiceImpl(false, AAF_URL, IDENTITY, aafConnection);
- DmaapGrant grant = new DmaapGrant(new DmaapPerm("perm", "type", "action"), "roles");
-
- int status = aafService.delGrant(grant);
-
- verifyZeroInteractions(aafConnection);
- assertEquals(OK, status);
- }
-
@Test
@Parameters({"401", "403", "409", "200", "500"})
public void shouldHandleErrorDuringCreate(int aafServiceReturnedCode) {
@Parameters({"401", "403", "404", "200", "500"})
public void shouldHandleErrorDuringDelete(int aafServiceReturnedCode) {
given(aafConnection.delAaf(any(AafObject.class), anyString())).willReturn(aafServiceReturnedCode);
- DmaapGrant grant = new DmaapGrant(new DmaapPerm("perm", "type", "action"), "roles");
+ DmaapPerm perm = new DmaapPerm("perm", "type", "action");
- int status = aafService.delGrant(grant);
+ int status = aafService.delPerm(perm, false);
assertEquals(aafServiceReturnedCode, status);
}
+
+ @Test
+ public void shouldDeletePermission() {
+ DmaapPerm perm = new DmaapPerm("permName", "type", "action");
+
+ int status = aafService.delPerm(perm, false);
+
+ then(aafConnection).should().delAaf(any(AafEmpty.class), eq(AAF_URL + "authz/perm/permName/type/action"));
+ assertEquals(OK, status);
+ }
+
+ @Test
+ public void shouldDeletePermissionWithForce() {
+ DmaapPerm perm = new DmaapPerm("permName", "type", "action");
+
+ int status = aafService.delPerm(perm, true);
+
+ then(aafConnection).should().delAaf(any(AafEmpty.class), eq(AAF_URL + "authz/perm/permName/type/action?force=true"));
+ assertEquals(OK, status);
+ }
+
+ @Test
+ public void shouldDeleteNamespace() {
+ AafNamespace ns = new AafNamespace("nsName", "ident");
+
+ int status = aafService.delNamespace(ns, false);
+
+ then(aafConnection).should().delAaf(any(AafEmpty.class), eq(AAF_URL + "authz/ns/nsName"));
+ assertEquals(OK, status);
+ }
+
+ @Test
+ public void shouldDeleteNamespaceWithForce() {
+ AafNamespace ns = new AafNamespace("nsName", "ident");
+
+ int status = aafService.delNamespace(ns, true);
+
+ then(aafConnection).should().delAaf(any(AafEmpty.class), eq(AAF_URL + "authz/ns/nsName?force=true"));
+ assertEquals(OK, status);
+ }
+
+ @Test
+ public void shouldReturnExpectedCodeDuringPostWhenUseAffIsSetToFalse() {
+ aafService = new AafServiceImpl(false, AAF_URL, IDENTITY, aafConnection);
+ DmaapPerm perm = new DmaapPerm("perm", "type", "action");
+
+ int status = aafService.addPerm(perm);
+
+ assertEquals(CREATED, status);
+ }
+
+ @Test
+ public void shouldReturnExpectedCodeDuringDeleteWhenUseAffIsSetToFalse() {
+ aafService = new AafServiceImpl(false, AAF_URL, IDENTITY, aafConnection);
+ DmaapPerm perm = new DmaapPerm("perm", "type", "action");
+
+ int status = aafService.delPerm(perm, false);
+
+ assertEquals(OK, status);
+ }
}
\ No newline at end of file