diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2023-05-05 11:32:42 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-05-11 20:03:14 +0000 |
commit | fd8df3f967b7ef8a52a2c37ed21ceb7af8bcdb7e (patch) | |
tree | 88bb5f3c839b515e67b105ffb6d75bf52f6d2cf2 /server/sonar-auth-github | |
parent | c4819c189044e302cfc9ab38ee30d617199181a3 (diff) | |
download | sonarqube-fd8df3f967b7ef8a52a2c37ed21ceb7af8bcdb7e.tar.gz sonarqube-fd8df3f967b7ef8a52a2c37ed21ceb7af8bcdb7e.zip |
SONAR-19086 Compare DB groups and GitHub teams, update DB membership accordingly
Diffstat (limited to 'server/sonar-auth-github')
-rw-r--r-- | server/sonar-auth-github/src/main/java/org/sonar/auth/github/GithubTeamConverter.java | 6 | ||||
-rw-r--r-- | server/sonar-auth-github/src/test/java/org/sonar/auth/github/GithubTeamConverterTest.java | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GithubTeamConverter.java b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GithubTeamConverter.java index be7bc9cd432..39bdff80d91 100644 --- a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GithubTeamConverter.java +++ b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GithubTeamConverter.java @@ -31,7 +31,11 @@ public class GithubTeamConverter { } public static String toGroupName(GsonTeam team) { - return team.getOrganizationId() + "/" + team.getId(); + return toGroupName(team.getOrganizationId(), team.getId()); + } + + public static String toGroupName(String organization, String groupName) { + return organization + "/" + groupName; } public static Optional<String> extractOrganizationName(String groupName) { diff --git a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GithubTeamConverterTest.java b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GithubTeamConverterTest.java index 2f7ad3288be..5b96e885287 100644 --- a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GithubTeamConverterTest.java +++ b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GithubTeamConverterTest.java @@ -27,12 +27,17 @@ import static org.assertj.core.api.Assertions.assertThat; public class GithubTeamConverterTest { @Test - public void toGroup_creates_correct_groupName() { + public void toGroupName_withGsonTeam_returnsCorrectGroupName() { GsonTeam team = new GsonTeam("team-1", new GsonTeam.GsonOrganization("Org1")); assertThat(GithubTeamConverter.toGroupName(team)).isEqualTo("Org1/team-1"); } @Test + public void toGroupName_withGroupAndName_returnsCorrectGroupName() { + assertThat(GithubTeamConverter.toGroupName("Org1", "team-1")).isEqualTo("Org1/team-1"); + } + + @Test public void extractOrganizationName_whenNameIsCorrect_extractsOrganizationName() { assertThat(GithubTeamConverter.extractOrganizationName("Org1/team1")).isEqualTo(Optional.of("Org1")); assertThat(GithubTeamConverter.extractOrganizationName("Org1/team1/team2")).isEqualTo(Optional.of("Org1")); |