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) { if (group instanceof GroupDescription.Internal) {
return ((GroupDescription.Internal) group).isVisibleToAll() || isOwner(); return ((GroupDescription.Internal) group).isVisibleToAll() || isOwner();
} }
return false; return canAdministrateServer();
} }
} }

View File

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