use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ListCachesIT method listCacheNames.
@Test
public void listCacheNames() throws Exception {
RestResponse r = adminRestSession.get("/config/server/caches/?format=LIST");
r.assertOK();
List<String> result = newGson().fromJson(r.getReader(), new TypeToken<List<String>>() {
}.getType());
assertThat(result).contains("accounts");
assertThat(result).contains("projects");
assertThat(Ordering.natural().isOrdered(result)).isTrue();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ImpersonationIT method runAsValidUser.
@Test
public void runAsValidUser() throws Exception {
allowRunAs();
RestResponse res = adminRestSession.getWithHeader("/accounts/self", runAsHeader(user.id));
res.assertOK();
AccountInfo account = newGson().fromJson(res.getEntityContent(), AccountInfo.class);
assertThat(account._accountId).isEqualTo(user.id.get());
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class PutUsernameIT method set.
@Test
public void set() throws Exception {
PutUsername.Input in = new PutUsername.Input();
in.username = "myUsername";
RestResponse r = adminRestSession.put("/accounts/" + accounts.create().id.get() + "/username", in);
r.assertOK();
assertThat(newGson().fromJson(r.getReader(), String.class)).isEqualTo(in.username);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ImpersonationIT method runAsInvalidUser.
@Test
public void runAsInvalidUser() throws Exception {
allowRunAs();
RestResponse res = adminRestSession.getWithHeader("/changes/", runAsHeader("doesnotexist"));
res.assertForbidden();
assertThat(res.getEntityContent()).isEqualTo("no account matches X-Gerrit-RunAs");
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteUsingRunAsAvoidsRestrictionsOfOnBehalfOf.
@Test
public void voteUsingRunAsAvoidsRestrictionsOfOnBehalfOf() throws Exception {
allowRunAs();
PushOneCommit.Result r = createChange();
setApiUser(user);
DraftInput di = new DraftInput();
di.path = Patch.COMMIT_MSG;
di.side = Side.REVISION;
di.line = 1;
di.message = "inline comment";
gApi.changes().id(r.getChangeId()).current().createDraft(di);
setApiUser(admin);
// Things that aren't allowed with on_behalf_of:
// - no labels.
// - publish other user's drafts.
ReviewInput in = new ReviewInput();
in.message = "message";
in.drafts = DraftHandling.PUBLISH;
RestResponse res = adminRestSession.postWithHeader("/changes/" + r.getChangeId() + "/revisions/current/review", in, runAsHeader(user.id));
res.assertOK();
ChangeMessageInfo m = Iterables.getLast(gApi.changes().id(r.getChangeId()).get().messages);
assertThat(m.message).endsWith(in.message);
assertThat(m.author._accountId).isEqualTo(user.id.get());
CommentInfo c = Iterables.getOnlyElement(gApi.changes().id(r.getChangeId()).comments().get(di.path));
assertThat(c.author._accountId).isEqualTo(user.id.get());
assertThat(c.message).isEqualTo(di.message);
setApiUser(user);
assertThat(gApi.changes().id(r.getChangeId()).drafts()).isEmpty();
}
Aggregations