use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class GroupOperationsImpl method createNewGroup.
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation) throws ConfigInvalidException, IOException {
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
GroupDelta groupDelta = toGroupDelta(groupCreation);
InternalGroup internalGroup = groupsUpdate.createGroup(internalGroupCreation, groupDelta);
return internalGroup.getGroupUUID();
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class ServiceUserClassifierImpl method isServiceUser.
@Override
public boolean isServiceUser(Account.Id user) {
Optional<InternalGroup> maybeGroup = groupCache.get(AccountGroup.nameKey(SERVICE_USERS));
if (!maybeGroup.isPresent()) {
return false;
}
List<AccountGroup.UUID> toTraverse = new ArrayList<>();
toTraverse.add(maybeGroup.get().getGroupUUID());
Set<AccountGroup.UUID> seen = new HashSet<>();
while (!toTraverse.isEmpty()) {
InternalGroup currentGroup = groupCache.get(toTraverse.remove(0)).orElseThrow(() -> new IllegalStateException("invalid subgroup"));
if (seen.contains(currentGroup.getGroupUUID())) {
logger.atFine().log("Skipping %s because it's a cyclic subgroup", currentGroup.getGroupUUID());
continue;
}
seen.add(currentGroup.getGroupUUID());
if (currentGroup.getMembers().contains(user)) {
// The user is a member of the 'Service Users' group or a subgroup.
return true;
}
boolean hasExternalSubgroup = currentGroup.getSubgroups().stream().anyMatch(g -> !internalGroupBackend.handles(g));
if (hasExternalSubgroup) {
// memberships.
return identifiedUserFactory.create(user).getEffectiveGroups().contains(maybeGroup.get().getGroupUUID());
}
toTraverse.addAll(currentGroup.getSubgroups());
}
return false;
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method group.
protected InternalGroup group(String groupName) {
InternalGroup group = groupCache.get(AccountGroup.nameKey(groupName)).orElse(null);
assertWithMessage(groupName).that(group).isNotNull();
return group;
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method groupRef.
protected GroupReference groupRef(String groupName) {
InternalGroup group = groupCache.get(AccountGroup.nameKey(groupName)).orElse(null);
assertThat(group).isNotNull();
return GroupReference.create(group.getGroupUUID(), group.getName());
}
use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method group.
protected InternalGroup group(AccountGroup.UUID groupUuid) {
InternalGroup group = groupCache.get(groupUuid).orElse(null);
assertWithMessage(groupUuid.get()).that(group).isNotNull();
return group;
}
Aggregations