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