Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Elastic{Index|ReindexIT} Remove tests for 6.2 and 6.3
  ElasticVersionTest#version6: Add missing test for V6_4
  Allow more email RFC accepted chars in username
  Make inheritance of receive.maxObjectSizeLimit optional
  Allow to inherit receive.maxObjectSizeLimit from parent project
  CreateAccount: Simplify error message when username is invalid
  Bazel: Provide toolchain with activated error prone warnings
  Use ExternalId.isValidUsername instead of ExternalId.USER_NAME_PATTERN_REGEX
  Move regular expressions for user name from Account to ExternalId
  AccountIT: Add basic tests for creating user with {in}valid username
  Revert refactoring of Account.USER_NAME_PATTERN

Change-Id: Ie96721e9135fad25672dc1fd1599cd3394f20c33
This commit is contained in:
David Pursehouse
2018-09-06 16:24:38 +09:00
32 changed files with 445 additions and 126 deletions

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.server.account;
import static com.google.gerrit.reviewdb.client.Account.USER_NAME_PATTERN;
import static com.google.gerrit.reviewdb.client.Account.USER_NAME_PATTERN_COMPILED;
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_MAILTO;
import com.google.gerrit.common.Nullable;
@@ -122,9 +120,8 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
throw new BadRequestException("username must match URL");
}
if (!USER_NAME_PATTERN_COMPILED.matcher(username).matches()) {
throw new BadRequestException(
"Username '" + username + "' must comply with [" + USER_NAME_PATTERN + "] pattern.");
if (!ExternalId.isValidUsername(username)) {
throw new BadRequestException("Invalid username '" + username + "'");
}
Set<AccountGroup.UUID> groups = parseGroups(input.groups);