use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.
the class SecurityFunctionDaoTest method createSecurityFunctionEntity.
/**
* Creates and persists a security function entity.
*
* @param code the name of the security function role
*
* @return the security role entity
*/
private SecurityFunctionEntity createSecurityFunctionEntity(String code) {
SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
securityFunctionEntity.setCode(code);
return herdDao.saveAndRefresh(securityFunctionEntity);
}
use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.
the class HttpHeaderAuthenticationFilterTest method setupTestFunctions.
private void setupTestFunctions(String roleId) {
SecurityRoleEntity securityRoleEntity = new SecurityRoleEntity();
securityRoleEntity.setCode(roleId);
herdDao.saveAndRefresh(securityRoleEntity);
for (String function : TEST_FUNCTIONS) {
SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
securityFunctionEntity.setCode(function);
herdDao.saveAndRefresh(securityFunctionEntity);
SecurityRoleFunctionEntity securityRoleFunctionEntity = new SecurityRoleFunctionEntity();
securityRoleFunctionEntity.setSecurityRole(securityRoleEntity);
securityRoleFunctionEntity.setSecurityFunction(securityFunctionEntity);
herdDao.saveAndRefresh(securityRoleFunctionEntity);
}
}
use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.
the class SecurityHelperTest method testGetUnrestrictedFunctions.
@Test
public void testGetUnrestrictedFunctions() {
// Create a security function not mapped to any of the security roles.
SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
securityFunctionEntity.setCode(SECURITY_FUNCTION);
herdDao.saveAndRefresh(securityFunctionEntity);
// Clear the cache.
cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
// Get unrestricted functions.
Set<GrantedAuthority> result = securityHelper.getUnrestrictedFunctions();
// Validate that result list contains the test security function.
assertTrue(result.contains(new SimpleGrantedAuthority(SECURITY_FUNCTION)));
}
Aggregations