use of com.google.gerrit.extensions.restapi.UnprocessableEntityException in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteOnBehalfOfInvisibleUserNotAllowed.
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void voteOnBehalfOfInvisibleUserNotAllowed() throws Exception {
allowCodeReviewOnBehalfOf();
requestScopeOperations.setApiUser(accountCreator.user2().id());
assertThat(accountControlFactory.get().canSee(user.id())).isFalse();
PushOneCommit.Result r = createChange();
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
ReviewInput in = new ReviewInput();
in.onBehalfOf = user.id().toString();
in.label("Code-Review", 1);
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> revision.review(in));
assertThat(thrown).hasMessageThat().contains("not found");
assertThat(thrown).hasMessageThat().contains(in.onBehalfOf);
}
use of com.google.gerrit.extensions.restapi.UnprocessableEntityException in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteOnBehalfOfMissingUser.
@Test
public void voteOnBehalfOfMissingUser() throws Exception {
allowCodeReviewOnBehalfOf();
PushOneCommit.Result r = createChange();
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
ReviewInput in = new ReviewInput();
in.onBehalfOf = "doesnotexist";
in.label("Code-Review", 1);
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> revision.review(in));
assertThat(thrown).hasMessageThat().contains("not found");
assertThat(thrown).hasMessageThat().contains("doesnotexist");
}
use of com.google.gerrit.extensions.restapi.UnprocessableEntityException in project gerrit by GerritCodeReview.
the class ImpersonationIT method submitOnBehalfOfInvisibleUserNotAllowed.
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void submitOnBehalfOfInvisibleUserNotAllowed() throws Exception {
allowSubmitOnBehalfOf();
requestScopeOperations.setApiUser(accountCreator.user2().id());
assertThat(accountControlFactory.get().canSee(user.id())).isFalse();
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(changeId).current().review(ReviewInput.approve());
SubmitInput in = new SubmitInput();
in.onBehalfOf = user.email();
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.changes().id(changeId).current().submit(in));
assertThat(thrown).hasMessageThat().contains("not found");
assertThat(thrown).hasMessageThat().contains(in.onBehalfOf);
}
Aggregations