Merge "Indicate in error messages that account identifiers may be ambiguous"
This commit is contained in:
@@ -72,10 +72,9 @@ public class AccountsCollection
|
||||
throws ResourceNotFoundException, AuthException, OrmException, IOException,
|
||||
ConfigInvalidException {
|
||||
IdentifiedUser user = parseId(id.get());
|
||||
if (user == null) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
} else if (!accountControlFactory.get().canSee(user.getAccount())) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
if (user == null || !accountControlFactory.get().canSee(user.getAccount())) {
|
||||
throw new ResourceNotFoundException(
|
||||
String.format("Account '%s' is not found or ambiguous", id));
|
||||
}
|
||||
return new AccountResource(user);
|
||||
}
|
||||
@@ -122,10 +121,9 @@ public class AccountsCollection
|
||||
throws AuthException, UnprocessableEntityException, OrmException, IOException,
|
||||
ConfigInvalidException {
|
||||
IdentifiedUser user = parseIdOnBehalfOf(caller, id);
|
||||
if (user == null) {
|
||||
throw new UnprocessableEntityException(String.format("Account Not Found: %s", id));
|
||||
} else if (!accountControlFactory.get().canSee(user.getAccount())) {
|
||||
throw new UnprocessableEntityException(String.format("Account Not Found: %s", id));
|
||||
if (user == null || !accountControlFactory.get().canSee(user.getAccount())) {
|
||||
throw new UnprocessableEntityException(
|
||||
String.format("Account '%s' is not found or ambiguous", id));
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
@@ -278,7 +278,8 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
in.label("Code-Review", 1);
|
||||
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage("Account Not Found: doesnotexist");
|
||||
exception.expectMessage("not found");
|
||||
exception.expectMessage("doesnotexist");
|
||||
revision.review(in);
|
||||
}
|
||||
|
||||
@@ -314,7 +315,8 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
in.label("Code-Review", 1);
|
||||
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage("Account Not Found: " + in.onBehalfOf);
|
||||
exception.expectMessage("not found");
|
||||
exception.expectMessage(in.onBehalfOf);
|
||||
revision.review(in);
|
||||
}
|
||||
|
||||
@@ -345,7 +347,8 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
SubmitInput in = new SubmitInput();
|
||||
in.onBehalfOf = "doesnotexist";
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage("Account Not Found: doesnotexist");
|
||||
exception.expectMessage("not found");
|
||||
exception.expectMessage("doesnotexist");
|
||||
gApi.changes().id(changeId).current().submit(in);
|
||||
}
|
||||
|
||||
@@ -391,7 +394,8 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
SubmitInput in = new SubmitInput();
|
||||
in.onBehalfOf = user.email;
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage("Account Not Found: " + in.onBehalfOf);
|
||||
exception.expectMessage("not found");
|
||||
exception.expectMessage(in.onBehalfOf);
|
||||
gApi.changes().id(changeId).current().submit(in);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user