use of org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method deleteNamespaceIamRoleAuthorization.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public NamespaceIamRoleAuthorization deleteNamespaceIamRoleAuthorization(String namespace) {
Assert.hasText(namespace, "Namespace must be specified");
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespace.trim());
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = getNamespaeIamRoleAuthorizationEntities(namespaceEntity);
NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
namespaceIamRoleAuthorizationDao.delete(namespaceIamRoleAuthorizationEntity);
result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return result;
}
use of org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method getNamespaceIamRoleAuthorization.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public NamespaceIamRoleAuthorization getNamespaceIamRoleAuthorization(String namespace) {
Assert.hasText(namespace, "Namespace must be specified");
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespace.trim());
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = getNamespaeIamRoleAuthorizationEntities(namespaceEntity);
NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return result;
}
use of org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method createNamespaceIamRoleAuthorizationEntity.
/**
* Creates a new NamespaceIamRoleAuthorizationEntity from the given parameters.
*
* @param namespaceEntity The namespace entity
* @param iamRole The IAM role
*
* @return The NamespaceIamRoleAuthorizationEntity
*/
private NamespaceIamRoleAuthorizationEntity createNamespaceIamRoleAuthorizationEntity(NamespaceEntity namespaceEntity, IamRole iamRole) {
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity.setNamespace(namespaceEntity);
namespaceIamRoleAuthorizationEntity.setIamRoleName(iamRole.getIamRoleName().trim());
if (StringUtils.isNotBlank(iamRole.getIamRoleDescription())) {
namespaceIamRoleAuthorizationEntity.setDescription(iamRole.getIamRoleDescription().trim());
}
return namespaceIamRoleAuthorizationEntity;
}
use of org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationDaoTest method getNamespaceIamRoleAuthorizationsAssertFilterByNamespaceWhenGiven.
@Test
public void getNamespaceIamRoleAuthorizationsAssertFilterByNamespaceWhenGiven() {
NamespaceEntity namespaceEntity1 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
NamespaceEntity namespaceEntity2 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(namespaceEntity1);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(0, namespaceIamRoleAuthorizations.size());
}
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity1 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity1.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity1.setIamRoleName("iamRoleName1");
namespaceIamRoleAuthorizationEntity1.setDescription("description1");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity1);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity2 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity2.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity2.setIamRoleName("iamRoleName2");
namespaceIamRoleAuthorizationEntity2.setDescription("description2");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity3 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity3.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity3.setIamRoleName("iamRoleName3");
namespaceIamRoleAuthorizationEntity3.setDescription("description3");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity3);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(namespaceEntity1);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(2, namespaceIamRoleAuthorizations.size());
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(0);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity1.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity1.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(1);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity3.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity3.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
}
}
use of org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationDaoTest method getNamespaceIamRoleAuthorizationsAssertGetAllWhenNamespaceIsNotGiven.
@Test
public void getNamespaceIamRoleAuthorizationsAssertGetAllWhenNamespaceIsNotGiven() {
NamespaceEntity namespaceEntity1 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
NamespaceEntity namespaceEntity2 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity1 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity1.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity1.setIamRoleName("iamRoleName1");
namespaceIamRoleAuthorizationEntity1.setDescription("description1");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity1);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity2 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity2.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity2.setIamRoleName("iamRoleName2");
namespaceIamRoleAuthorizationEntity2.setDescription("description2");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity3 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity3.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity3.setIamRoleName("iamRoleName3");
namespaceIamRoleAuthorizationEntity3.setDescription("description3");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity3);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(null);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(3, namespaceIamRoleAuthorizations.size());
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(0);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity1.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity1.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(1);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity3.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity3.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(2);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity2.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity2.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity2.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
}
}
Aggregations