use of com.epam.ta.reportportal.entity.user.User in project service-authorization by reportportal.
the class ReportPortalSamlAuthenticationManager method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (authentication instanceof DefaultSamlAuthentication) {
ReportPortalSamlAuthentication reportPortalSamlAuthentication = new ReportPortalSamlAuthentication((DefaultSamlAuthentication) authentication);
if (reportPortalSamlAuthentication.isAuthenticated()) {
User user = samlUserReplicator.replicateUser(reportPortalSamlAuthentication);
reportPortalSamlAuthentication.setAuthorities(AuthUtils.AS_AUTHORITIES.apply(user.getRole()));
SecurityContextHolder.getContext().setAuthentication(reportPortalSamlAuthentication);
}
return reportPortalSamlAuthentication;
}
return authentication;
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class UserCommonDataStoreServiceTest method saveUserPhoto.
@Test
void saveUserPhoto() throws IOException {
CommonsMultipartFile multipartFile = getMultipartFile("meh.jpg");
User user = userRepository.findByLogin("default").get();
userDataStoreService.saveUserPhoto(user, multipartFile);
user = userRepository.findByLogin("default").get();
BinaryData binaryData = userDataStoreService.loadUserPhoto(user, false);
assertThat(IOUtils.contentEquals(multipartFile.getInputStream(), binaryData.getInputStream())).isTrue();
BinaryData binaryDataThumbnail = userDataStoreService.loadUserPhoto(user, true);
assertThat(IOUtils.contentEquals(thumbnailator.createThumbnail(multipartFile.getInputStream()), binaryDataThumbnail.getInputStream())).isTrue();
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class UserRepositoryTest method loadUserByLastLogin.
@Test
void loadUserByLastLogin() {
// given
long now = new Date().getTime();
Filter filter = Filter.builder().withTarget(User.class).withCondition(FilterCondition.builder().withCondition(Condition.LOWER_THAN).withSearchCriteria(CRITERIA_LAST_LOGIN).withValue(String.valueOf(now)).build()).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_ID, "3").build()).build();
// when
List<User> users = userRepository.findByFilter(filter);
// then
assertThat("Users should exist", users.size(), Matchers.greaterThan(0));
users.forEach(user -> assertThat("Last login should be lower than in the filer", Long.parseLong((String) user.getMetadata().getMetadata().get("last_login")), Matchers.lessThan(now)));
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class UserRepositoryTest method loadUsersByFilterForProject.
@Test
void loadUsersByFilterForProject() {
// given
Filter filter = buildDefaultUserFilter();
filter.withCondition(new FilterCondition(Condition.EQUALS, false, "3", CRITERIA_PROJECT_ID));
// when
List<User> users = userRepository.findByFilterExcluding(filter, PageRequest.of(0, 5), "email").getContent();
// then
assertThat("Users not found", users, Matchers.notNullValue());
assertThat("Incorrect size of founded users", users, Matchers.hasSize(3));
users.forEach(it -> assertNull(it.getEmail()));
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class UserRepositoryTest method findAllMembersByProjectManagerRole.
@Test
void findAllMembersByProjectManagerRole() {
List<String> emails = userRepository.findEmailsByProjectAndRole(1L, ProjectRole.PROJECT_MANAGER);
assertFalse(emails.isEmpty());
emails.forEach(e -> {
User user = userRepository.findByEmail(e).get();
assertEquals(ProjectRole.PROJECT_MANAGER, user.getProjects().stream().filter(it -> it.getId().getProjectId().equals(1L)).map(ProjectUser::getProjectRole).findFirst().get());
});
}
Aggregations