use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CacheOperationsIT method flushWebSessions_Forbidden.
@Test
public void flushWebSessions_Forbidden() throws Exception {
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
try {
RestResponse r = userRestSession.postOK("/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("projects")));
r.consume();
userRestSession.post("/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("web_sessions"))).assertForbidden();
} finally {
removeGlobalCapabilities(REGISTERED_USERS, GlobalCapability.FLUSH_CACHES, GlobalCapability.VIEW_CACHES);
}
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CheckMergeabilityIT method getMergeableInfo.
private MergeableInfo getMergeableInfo(String targetBranch, String source, String strategy) throws Exception {
String url = "/projects/" + project.get() + "/branches/" + targetBranch;
url += "/mergeable?source=" + source;
if (!Strings.isNullOrEmpty(strategy)) {
url += "&strategy=" + strategy;
}
RestResponse r = userRestSession.get(url);
r.assertOK();
MergeableInfo result = newGson().fromJson(r.getReader(), MergeableInfo.class);
r.consume();
return result;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CommitIncludedInIT method getIncludedIn.
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
RestResponse r = userRestSession.get("/projects/" + project.get() + "/commits/" + id.name() + "/in");
IncludedInInfo result = newGson().fromJson(r.getReader(), IncludedInInfo.class);
r.consume();
return result;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class BanCommitIT method banAlreadyBannedCommit.
@Test
public void banAlreadyBannedCommit() throws Exception {
RestResponse r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
r.consume();
r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
r.assertOK();
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
assertThat(Iterables.getOnlyElement(info.alreadyBanned)).isEqualTo("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96");
assertThat(info.newlyBanned).isNull();
assertThat(info.ignored).isNull();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class RevisionIT method contentOfInvalidParent.
@Test
public void contentOfInvalidParent() throws Exception {
String parentContent = "parent content";
PushOneCommit.Result parent = createChange("Parent change", FILE_NAME, parentContent);
parent.assertOkStatus();
gApi.changes().id(parent.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(parent.getChangeId()).current().submit();
PushOneCommit.Result child = createChange("Child change", FILE_NAME, FILE_CONTENT);
child.assertOkStatus();
assertContent(child, FILE_NAME, FILE_CONTENT);
RestResponse response = adminRestSession.get("/changes/" + child.getChangeId() + "/revisions/current/files/" + FILE_NAME + "/content?parent=10");
response.assertBadRequest();
assertThat(response.getEntityContent()).isEqualTo("invalid parent");
}
Aggregations