}
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) {
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"));
"es_queue",
"events",
"event_component_changes",
+ "external_groups",
"file_sources",
"groups",
"groups_users",
*/
package org.sonar.db.user;
+import java.util.Objects;
import javax.annotation.Nullable;
public record ExternalGroupDto(String groupUuid, String externalId, String externalIdentityProvider, @Nullable String name) {
public ExternalGroupDto(String groupUuid, String externalId, String externalIdentityProvider) {
this(groupUuid, externalId, externalIdentityProvider, null);
}
+
+ public String getNameOrThrow() {
+ return Objects.requireNonNull(name);
+ }
}
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Arrays.stream;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
import static org.sonar.db.user.GroupTesting.newGroupDto;
return dto;
}
+ public void markGroupAsGithubManaged(String groupUuid) {
+ db.getDbClient().externalGroupDao().insert(db.getSession(), new ExternalGroupDto(groupUuid, randomAlphanumeric(20), "github"));
+ db.commit();
+ }
+
public ScimGroupDto insertScimGroup(GroupDto dto) {
ScimGroupDto result = db.getDbClient().scimGroupDao().enableScimForGroup(db.getSession(), dto.getUuid());
db.commit();