use of org.finra.herd.model.api.xml.IamRole in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank.
@Test
public void updateNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank() {
String expectedNamespace = "namespace";
List<IamRole> iamRoles = new ArrayList<>();
IamRole iamRole1 = new IamRole(" ", "iamRoleDescription1");
iamRoles.add(iamRole1);
IamRole iamRole2 = new IamRole(" ", " ");
iamRoles.add(iamRole2);
NamespaceIamRoleAuthorizationUpdateRequest expectedNamespaceIamRoleAuthorizationUpdateRequest = new NamespaceIamRoleAuthorizationUpdateRequest(iamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("IAM role name must be specified", e.getMessage());
}
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.IamRole in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole("iamRoleName2", " ");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest(" ", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("Namespace must be specified", e.getMessage());
}
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.IamRole in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole(" ", "iamRoleDescription2");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("IAM role name must be specified", e.getMessage());
}
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.IamRole in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty() {
List<IamRole> expectedIamRoles = Arrays.asList();
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("At least 1 IAM roles must be specified", e.getMessage());
}
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.IamRole in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenAuthorizationAlreadyExist.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenAuthorizationAlreadyExist() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole("iamRoleName2", "iamRoleDescription2");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
NamespaceEntity expectedNamespaceEntity = new NamespaceEntity();
expectedNamespaceEntity.setCode("NAMESPACE");
when(namespaceDaoHelper.getNamespaceEntity(any())).thenReturn(expectedNamespaceEntity);
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(Arrays.asList(new NamespaceIamRoleAuthorizationEntity()));
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
fail();
} catch (Exception e) {
assertEquals(AlreadyExistsException.class, e.getClass());
assertEquals(String.format("Namespace IAM role authorizations with namespace \"%s\" already exist", expectedNamespaceEntity.getCode()), e.getMessage());
}
verify(namespaceDaoHelper).getNamespaceEntity(expectedRequest.getNamespace());
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(expectedNamespaceEntity);
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Aggregations