aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-auth-github
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2023-04-21 21:22:42 +0200
committersonartech <sonartech@sonarsource.com>2023-05-11 20:03:13 +0000
commit1655663b7e4ea2249f2d1b5f5db05e6599be783a (patch)
tree288d1146170151f385d677b1b5a11e529a3933e1 /server/sonar-auth-github
parentb0ba2e2efa4eda19e4896509f0ebf180863eabd4 (diff)
downloadsonarqube-1655663b7e4ea2249f2d1b5f5db05e6599be783a.tar.gz
sonarqube-1655663b7e4ea2249f2d1b5f5db05e6599be783a.zip
SONAR-19084 Compute isManaged flag correctly for GitHub users
Diffstat (limited to 'server/sonar-auth-github')
-rw-r--r--server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubManagedInstanceService.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubManagedInstanceService.java b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubManagedInstanceService.java
index e88da1259f9..7921892fe92 100644
--- a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubManagedInstanceService.java
+++ b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubManagedInstanceService.java
@@ -53,18 +53,27 @@ public class GitHubManagedInstanceService implements ManagedInstanceService {
@Override
public Map<String, Boolean> getUserUuidToManaged(DbSession dbSession, Set<String> userUuids) {
+ Set<String> gitHubUserUuids = findManagedUserUuids(dbSession, userUuids);
+
+ return userUuids.stream()
+ .collect(toMap(Function.identity(), gitHubUserUuids::contains));
+ }
+
+ private Set<String> findManagedUserUuids(DbSession dbSession, Set<String> userUuids) {
+ List<UserDto> userDtos = findManagedUsers(dbSession, userUuids);
+
+ return userDtos.stream()
+ .map(UserDto::getUuid)
+ .collect(toSet());
+ }
+
+ private List<UserDto> findManagedUsers(DbSession dbSession, Set<String> userUuids) {
UserQuery managedUsersQuery = UserQuery.builder()
.userUuids(userUuids)
.isManagedClause(getManagedUsersSqlFilter(true))
.build();
- List<UserDto> userDtos = userDao.selectUsers(dbSession, managedUsersQuery);
- Set<String> gitHubUserUuids = userDtos.stream()
- .map(UserDto::getUuid)
- .collect(toSet());
-
- return userUuids.stream()
- .collect(toMap(Function.identity(), gitHubUserUuids::contains));
+ return userDao.selectUsers(dbSession, managedUsersQuery);
}
@Override