Merge "Allow admins to see all groups (including external ones) of a user"

This commit is contained in:
David Pursehouse
2018-03-15 23:01:37 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 7 deletions

View File

@@ -177,6 +177,6 @@ public class GroupControl {
if (group instanceof GroupDescription.Internal) {
return ((GroupDescription.Internal) group).isVisibleToAll() || isOwner();
}
return false;
return canAdministrateServer();
}
}

View File

@@ -1982,13 +1982,11 @@ public class AccountIT extends AbstractDaemonTest {
assertGroups(
admin.username, ImmutableList.of("Anonymous Users", "Registered Users", "Administrators"));
// TODO: update when test user is fixed to be included in "Anonymous Users" and
// "Registered Users" groups
assertGroups(user.username, ImmutableList.of());
assertGroups(user.username, ImmutableList.of("Anonymous Users", "Registered Users"));
String group = createGroup("group");
String newUser = createAccount("user1", group);
assertGroups(newUser, ImmutableList.of(group));
assertGroups(newUser, ImmutableList.of("Anonymous Users", "Registered Users", group));
}
@Test
@@ -2367,11 +2365,14 @@ public class AccountIT extends AbstractDaemonTest {
}
private void assertGroups(String user, List<String> expected) throws Exception {
List<String> actual =
gApi.accounts().id(user).getGroups().stream().map(g -> g.name).collect(toList());
List<String> actual = getNamesOfGroupsOfUser(user);
assertThat(actual).containsExactlyElementsIn(expected);
}
private List<String> getNamesOfGroupsOfUser(String user) throws RestApiException {
return gApi.accounts().id(user).getGroups().stream().map(g -> g.name).collect(toList());
}
private void assertSequenceNumbers(List<SshKeyInfo> sshKeys) {
int seq = 1;
for (SshKeyInfo key : sshKeys) {