use of org.sonar.db.EmailSubscriberDto in project sonarqube by SonarSource.
the class PropertiesDaoTest method findEmailRecipientsForNotification_returns_empty_on_empty_properties_table.
@Test
public void findEmailRecipientsForNotification_returns_empty_on_empty_properties_table() {
db.users().insertUser();
String dispatcherKey = randomAlphabetic(5);
String channelKey = randomAlphabetic(6);
String projectKey = randomAlphabetic(7);
Set<EmailSubscriberDto> subscribers = underTest.findEmailSubscribersForNotification(db.getSession(), dispatcherKey, channelKey, projectKey);
assertThat(subscribers).isEmpty();
}
use of org.sonar.db.EmailSubscriberDto in project sonarqube by SonarSource.
the class DefaultNotificationManager method findSubscribedEmailRecipients.
@Override
public Set<EmailRecipient> findSubscribedEmailRecipients(String dispatcherKey, String projectKey, Set<String> logins, SubscriberPermissionsOnProject subscriberPermissionsOnProject) {
verifyProjectKey(projectKey);
requireNonNull(logins, "logins can't be null");
if (logins.isEmpty()) {
return emptySet();
}
try (DbSession dbSession = dbClient.openSession(false)) {
Set<EmailSubscriberDto> emailSubscribers = dbClient.propertiesDao().findEmailSubscribersForNotification(dbSession, dispatcherKey, EmailNotificationChannel.class.getSimpleName(), projectKey, logins);
return keepAuthorizedEmailSubscribers(dbSession, projectKey, subscriberPermissionsOnProject, emailSubscribers);
}
}
use of org.sonar.db.EmailSubscriberDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectGlobalAdministerEmailSubscribers_returns_only_global_administers.
@Test
public void selectGlobalAdministerEmailSubscribers_returns_only_global_administers() {
UserDto user1 = db.users().insertUser(withEmail("user1"));
db.users().insertPermissionOnUser(user1, ADMINISTER);
UserDto user2 = db.users().insertUser(withEmail("user2"));
db.users().insertPermissionOnUser(user2, ADMINISTER);
// user3 is global administer via a group
GroupDto administratorGroup2 = db.users().insertGroup();
db.users().insertPermissionOnGroup(administratorGroup2, ADMINISTER);
UserDto user3 = db.users().insertUser(withEmail("user3"));
db.users().insertMember(administratorGroup2, user3);
// user4 has another global permission via a group
GroupDto administratorGroup3 = db.users().insertGroup();
db.users().insertPermissionOnGroup(administratorGroup3, QUALITY_PROFILE_ADMIN);
UserDto user4 = db.users().insertUser(withEmail("user4"));
db.users().insertMember(administratorGroup3, user4);
ComponentDto project = db.components().insertPrivateProject();
// user5 is only project level administer
UserDto user5 = db.users().insertUser(withEmail("user5"));
// db.users().insertPermissionOnUser(user5, ADMINISTER);
db.users().insertProjectPermissionOnUser(user5, "admin", project);
// user6 has other global permission
UserDto user6 = db.users().insertUser(withEmail("user6"));
db.users().insertPermissionOnUser(user6, ADMINISTER_QUALITY_PROFILES);
// user7 has no permission
db.users().insertUser(withEmail("user7"));
Set<EmailSubscriberDto> subscribers = underTest.selectGlobalAdministerEmailSubscribers(dbSession);
assertThat(subscribers).containsOnly(globalEmailSubscriberOf(user1), globalEmailSubscriberOf(user2), globalEmailSubscriberOf(user3));
}
use of org.sonar.db.EmailSubscriberDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectQualityProfileAdministratorLogins_does_not_return_non_quality_profile_administrator.
@Test
public void selectQualityProfileAdministratorLogins_does_not_return_non_quality_profile_administrator() {
UserDto user1 = db.users().insertUser(withEmail("user1"));
db.users().insertPermissionOnUser(user1, ADMINISTER);
db.users().insertUser(withoutEmail("user2"));
Set<EmailSubscriberDto> subscribers = underTest.selectQualityProfileAdministratorLogins(dbSession);
assertThat(subscribers).isEmpty();
}
use of org.sonar.db.EmailSubscriberDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectQualityProfileAdministratorLogins_does_not_return_quality_profile_administrator_without_email.
@Test
public void selectQualityProfileAdministratorLogins_does_not_return_quality_profile_administrator_without_email() {
UserDto user1NoEmail = db.users().insertUser(withoutEmail("user1NoEmail"));
db.users().insertPermissionOnUser(user1NoEmail, ADMINISTER_QUALITY_PROFILES);
UserDto user1WithEmail = db.users().insertUser(withEmail("user1WithEmail"));
db.users().insertPermissionOnUser(user1WithEmail, ADMINISTER_QUALITY_PROFILES);
GroupDto qualityProfileAdministratorGroup1 = db.users().insertGroup();
db.users().insertPermissionOnGroup(qualityProfileAdministratorGroup1, ADMINISTER_QUALITY_PROFILES);
UserDto user2NoEmail = db.users().insertUser(withoutEmail("user2NoEmail"));
db.users().insertMember(qualityProfileAdministratorGroup1, user2NoEmail);
UserDto user2WithEmail = db.users().insertUser(withEmail("user2WithEmail"));
db.users().insertMember(qualityProfileAdministratorGroup1, user2WithEmail);
GroupDto qualityProfileAdministratorGroup2 = db.users().insertGroup();
db.users().insertPermissionOnGroup(qualityProfileAdministratorGroup2, ADMINISTER_QUALITY_PROFILES);
UserDto user3NoEmail = db.users().insertUser(withoutEmail("user3NoEmail"));
db.users().insertMember(qualityProfileAdministratorGroup2, user3NoEmail);
UserDto user3WithEmail = db.users().insertUser(withEmail("user3WithEmail"));
db.users().insertMember(qualityProfileAdministratorGroup2, user3WithEmail);
UserDto user4NoEmail = db.users().insertUser(withoutEmail("user4NoEmail"));
db.users().insertPermissionOnUser(user4NoEmail, ADMINISTER_QUALITY_PROFILES);
UserDto user4WithEmail = db.users().insertUser(withEmail("user4WithEmail"));
db.users().insertPermissionOnUser(user4WithEmail, ADMINISTER_QUALITY_PROFILES);
UserDto user5NoEmail = db.users().insertUser(withoutEmail("user5NoEmail"));
db.users().insertPermissionOnUser(user5NoEmail, ADMINISTER_QUALITY_PROFILES);
UserDto user5WithEmail = db.users().insertUser(withEmail("user5WithEmail"));
db.users().insertPermissionOnUser(user5WithEmail, ADMINISTER_QUALITY_PROFILES);
db.users().insertUser(withoutEmail("user6NoEmail"));
db.users().insertUser(withEmail("user6WithEmail"));
Set<EmailSubscriberDto> subscribers = underTest.selectQualityProfileAdministratorLogins(dbSession);
assertThat(subscribers).containsOnly(globalEmailSubscriberOf(user1WithEmail), globalEmailSubscriberOf(user2WithEmail), globalEmailSubscriberOf(user3WithEmail), globalEmailSubscriberOf(user4WithEmail), globalEmailSubscriberOf(user5WithEmail));
}
Aggregations