Search in sources :

Example 6 with IamRole

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);
}
Also used : IamRole(org.finra.herd.model.api.xml.IamRole) ArrayList(java.util.ArrayList) NamespaceIamRoleAuthorizationUpdateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 7 with IamRole

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);
}
Also used : NamespaceIamRoleAuthorizationCreateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest) IamRole(org.finra.herd.model.api.xml.IamRole) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 8 with IamRole

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);
}
Also used : NamespaceIamRoleAuthorizationCreateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest) IamRole(org.finra.herd.model.api.xml.IamRole) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 9 with IamRole

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);
}
Also used : NamespaceIamRoleAuthorizationCreateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest) IamRole(org.finra.herd.model.api.xml.IamRole) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 10 with IamRole

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);
}
Also used : NamespaceIamRoleAuthorizationCreateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) IamRole(org.finra.herd.model.api.xml.IamRole) NamespaceIamRoleAuthorizationEntity(org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Aggregations

IamRole (org.finra.herd.model.api.xml.IamRole)22 Test (org.junit.Test)16 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)15 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)14 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)13 ArrayList (java.util.ArrayList)10 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)7 NamespaceIamRoleAuthorizationCreateRequest (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest)6 NamespaceIamRoleAuthorizationUpdateRequest (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest)5 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)4 NamespaceIamRoleAuthorizations (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations)2 LinkedHashMap (java.util.LinkedHashMap)1