use of com.epam.ta.reportportal.entity.project.Project in project service-authorization by reportportal.
the class SamlUserReplicator method replicateUser.
public User replicateUser(ReportPortalSamlAuthentication samlAuthentication) {
String userName = CROP_DOMAIN.apply(samlAuthentication.getPrincipal());
Optional<User> userOptional = userRepository.findByLogin(userName);
if (userOptional.isPresent()) {
return userOptional.get();
}
IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType);
Optional<Integration> samlProvider = providers.stream().filter(provider -> {
Optional<String> idpUrlOptional = SamlParameter.IDP_URL.getParameter(provider);
return idpUrlOptional.isPresent() && idpUrlOptional.get().equalsIgnoreCase(samlAuthentication.getIssuer());
}).findFirst();
User user = new User();
user.setLogin(userName);
List<Attribute> details = samlAuthentication.getDetails();
if (samlProvider.isPresent()) {
populateUserDetailsIfSettingsArePresent(user, samlProvider.get(), details);
} else {
populateUserDetails(user, details);
}
user.setUserType(UserType.SAML);
user.setRole(UserRole.USER);
user.setExpired(false);
Project project = generatePersonalProject(user);
user.getProjects().add(project.getUsers().iterator().next());
user.setMetadata(defaultMetaData());
userRepository.save(user);
return user;
}
use of com.epam.ta.reportportal.entity.project.Project in project service-authorization by reportportal.
the class GitHubUserReplicator method createUser.
private User createUser(UserResource userResource, GitHubClient gitHubClient) {
User user = new User();
String login = normalizeId(userResource.getLogin());
user.setLogin(login);
updateUser(user, userResource, gitHubClient);
user.setUserType(UserType.GITHUB);
user.setRole(UserRole.USER);
user.setExpired(false);
final Project project = generatePersonalProject(user);
user.getProjects().addAll(project.getUsers());
return user;
}
use of com.epam.ta.reportportal.entity.project.Project in project commons-dao by reportportal.
the class IntegrationRepositoryTest method findAllProjectByIntegrationGroup.
@Test
void findAllProjectByIntegrationGroup() {
Project project = new Project();
project.setId(1L);
List<Integration> integrations = integrationRepository.findAllProjectByGroup(project, IntegrationGroupEnum.BTS);
assertThat(integrations, hasSize(4));
}
Aggregations