Trim group names on group creation
Usually we trim all user input. There is no reason why group names should be an exception. Change-Id: I18fc1d779fe09eceeb47e2ffbdef8aee6ad02f03 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
		@@ -35,6 +35,6 @@ public class CreateGroupArgs {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public void setGroupName(String n) {
 | 
			
		||||
    groupName = n != null ? AccountGroup.nameKey(n) : null;
 | 
			
		||||
    groupName = n != null ? AccountGroup.nameKey(n.trim()) : null;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -362,6 +362,13 @@ public class GroupsIT extends AbstractDaemonTest {
 | 
			
		||||
    assertGroupInfo(group(newGroupName), g);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void createGroupNameIsTrimmed() throws Exception {
 | 
			
		||||
    String newGroupName = name("newGroup");
 | 
			
		||||
    GroupInfo g = gApi.groups().create(" " + newGroupName + " ").get();
 | 
			
		||||
    assertGroupInfo(group(newGroupName), g);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void createDuplicateInternalGroupCaseSensitiveName_Conflict() throws Exception {
 | 
			
		||||
    String dupGroupName = name("dupGroup");
 | 
			
		||||
@@ -1348,17 +1355,6 @@ public class GroupsIT extends AbstractDaemonTest {
 | 
			
		||||
    assertStaleGroupAndReindex(groupUuid);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void groupNamesWithLeadingAndTrailingWhitespace() throws Exception {
 | 
			
		||||
    for (String leading : ImmutableList.of("", " ", "  ")) {
 | 
			
		||||
      for (String trailing : ImmutableList.of("", " ", "  ")) {
 | 
			
		||||
        String name = leading + name("group") + trailing;
 | 
			
		||||
        GroupInfo g = gApi.groups().create(name).get();
 | 
			
		||||
        assertThat(g.name).isEqualTo(name);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  @Sandboxed
 | 
			
		||||
  public void groupsOfUserCanBeListedInSlaveMode() throws Exception {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user