use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.
the class ImpersonationIT method submitOnBehalfOfInvisibleUserNotAllowed.
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void submitOnBehalfOfInvisibleUserNotAllowed() throws Exception {
allowSubmitOnBehalfOf();
setApiUser(accounts.user2());
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;
exception.expect(UnprocessableEntityException.class);
exception.expectMessage("Account Not Found: " + in.onBehalfOf);
gApi.changes().id(changeId).current().submit(in);
}
use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteOnBehalfOfInvisibleUserNotAllowed.
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void voteOnBehalfOfInvisibleUserNotAllowed() throws Exception {
allowCodeReviewOnBehalfOf();
setApiUser(accounts.user2());
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);
exception.expect(UnprocessableEntityException.class);
exception.expectMessage("Account Not Found: " + in.onBehalfOf);
revision.review(in);
}
use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.
the class ImpersonationIT method runAsDisabledByConfig.
@GerritConfig(name = "auth.enableRunAs", value = "false")
@Test
public void runAsDisabledByConfig() throws Exception {
allowRunAs();
RestResponse res = adminRestSession.getWithHeader("/changes/", runAsHeader(user.id));
res.assertForbidden();
assertThat(res.getEntityContent()).isEqualTo("X-Gerrit-RunAs disabled by auth.enableRunAs = false");
}
use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteOnBehalfOfWithRobotComment.
@GerritConfig(name = "notedb.writeJson", value = "true")
@Test
public void voteOnBehalfOfWithRobotComment() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
allowCodeReviewOnBehalfOf();
PushOneCommit.Result r = createChange();
ReviewInput in = new ReviewInput();
in.onBehalfOf = user.id.toString();
in.label("Code-Review", 1);
RobotCommentInput ci = new RobotCommentInput();
ci.robotId = "my-robot";
ci.robotRunId = "abcd1234";
ci.path = Patch.COMMIT_MSG;
ci.side = Side.REVISION;
ci.line = 1;
ci.message = "message";
in.robotComments = ImmutableMap.of(ci.path, ImmutableList.of(ci));
gApi.changes().id(r.getChangeId()).current().review(in);
ChangeData cd = r.getChange();
RobotComment c = Iterables.getOnlyElement(commentsUtil.robotCommentsByChange(cd.notes()));
assertThat(c.message).isEqualTo(ci.message);
assertThat(c.robotId).isEqualTo(ci.robotId);
assertThat(c.robotRunId).isEqualTo(ci.robotRunId);
assertThat(c.author.getId()).isEqualTo(user.id);
assertThat(c.getRealAuthor().getId()).isEqualTo(admin.id);
}
use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.
the class ServerInfoIT method serverConfigWithPlugin.
@Test
@UseSsh
@GerritConfig(name = "plugins.allowRemoteAdmin", value = "true")
public void serverConfigWithPlugin() throws Exception {
Path plugins = tempSiteDir.newFolder("plugins").toPath();
Path jsplugin = plugins.resolve("js-plugin-1.js");
Files.write(jsplugin, "Gerrit.install(function(self){});\n".getBytes(UTF_8));
adminSshSession.exec("gerrit plugin reload");
ServerInfo i = gApi.config().server().getInfo();
// plugin
assertThat(i.plugin.jsResourcePaths).hasSize(1);
}
Aggregations