use of eu.bcvsolutions.idm.core.security.api.dto.LoginDto in project CzechIdMng by bcvsolutions.
the class SelfRoleRequestEvaluatorIntegrationTest method testCanReadSelfRoleRequest.
@Test
public void testCanReadSelfRoleRequest() {
IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
// assign role request
IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
IdmRoleRequestDto read = roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
assertEquals(roleRequest, read);
//
IdmConceptRoleRequestFilter filter = new IdmConceptRoleRequestFilter();
filter.setRoleRequestId(roleRequest.getId());
Page<IdmConceptRoleRequestDto> concepts = conceptRoleRequestController.find(filter, null, IdmBasePermission.READ);
assertEquals(1, concepts.getTotalElements());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.dto.LoginDto in project CzechIdMng by bcvsolutions.
the class SelfRoleRequestEvaluatorIntegrationTest method testCreateRoleRequestForSelf.
@Test
public void testCreateRoleRequestForSelf() {
IdmIdentityDto identityOne = helper.createIdentity();
// assign default role
helper.createIdentityRole(identityOne, roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME));
//
try {
loginService.login(new LoginDto(identityOne.getUsername(), identityOne.getPassword()));
//
IdmRoleRequestDto roleRequest = new IdmRoleRequestDto();
roleRequest.setApplicant(identityOne.getId());
roleRequest.setRequestedByType(RoleRequestedByType.MANUALLY);
roleRequest = roleRequestService.save(roleRequest, IdmBasePermission.CREATE);
//
Assert.notNull(roleRequest.getId());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.dto.LoginDto in project CzechIdMng by bcvsolutions.
the class SelfRoleRequestEvaluatorIntegrationTest method testCannotReadForeignRoleRequest.
@Test(expected = ForbiddenEntityException.class)
public void testCannotReadForeignRoleRequest() {
IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
// prepare identities
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityDto identityTwo = helper.createIdentity();
// assign role request
IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
//
try {
loginService.login(new LoginDto(identityTwo.getUsername(), identityTwo.getPassword()));
//
roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.dto.LoginDto in project CzechIdMng by bcvsolutions.
the class DefaultJwtAuthenticationServiceTest method createJwtAuthenticationAndAuthenticateTest.
@Test
public void createJwtAuthenticationAndAuthenticateTest() {
createTestUser();
IdmIdentityDto identityDto = getTestIdentity();
LoginDto loginDto = getTestLoginDto();
LoginDto resultLoginDto = jwtAuthenticationService.createJwtAuthenticationAndAuthenticate(loginDto, identityDto, MODULE);
Assert.assertTrue(securityService.isAuthenticated());
Assert.assertEquals(USERNAME, securityService.getCurrentUsername());
Assert.assertEquals(USERNAME, resultLoginDto.getUsername());
Assert.assertEquals(MODULE, resultLoginDto.getAuthenticationModule());
Assert.assertNotNull(resultLoginDto.getToken());
IdmJwtAuthenticationDto jwtAuthenticationDto = resultLoginDto.getAuthentication();
Assert.assertNotNull(jwtAuthenticationDto);
Assert.assertEquals(USERNAME, jwtAuthenticationDto.getCurrentUsername());
Assert.assertEquals(MODULE, jwtAuthenticationDto.getFromModule());
Assert.assertTrue(jwtAuthenticationDto.getAuthorities().isEmpty());
}
use of eu.bcvsolutions.idm.core.security.api.dto.LoginDto in project CzechIdMng by bcvsolutions.
the class DefaultJwtAuthenticationServiceTest method getTestLoginDto.
private LoginDto getTestLoginDto() {
LoginDto loginDto = new LoginDto();
loginDto.setUsername(USERNAME);
return loginDto;
}
Aggregations