Search in sources :

Example 71 with RestResponse

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);
    }
}
Also used : PostCaches(com.google.gerrit.server.config.PostCaches) RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 72 with RestResponse

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;
}
Also used : MergeableInfo(com.google.gerrit.extensions.common.MergeableInfo) RestResponse(com.google.gerrit.acceptance.RestResponse)

Example 73 with RestResponse

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;
}
Also used : IncludedInInfo(com.google.gerrit.extensions.api.changes.IncludedInInfo) RestResponse(com.google.gerrit.acceptance.RestResponse)

Example 74 with RestResponse

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();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) BanResultInfo(com.google.gerrit.server.project.BanCommit.BanResultInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 75 with RestResponse

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");
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

RestResponse (com.google.gerrit.acceptance.RestResponse)79 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Test (org.junit.Test)67 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)17 TypeToken (com.google.gson.reflect.TypeToken)15 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 CacheInfo (com.google.gerrit.server.config.ListCaches.CacheInfo)6 TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)6 ReviewResult (com.google.gerrit.extensions.api.changes.ReviewResult)5 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 Result (com.google.gerrit.acceptance.PushOneCommit.Result)4 AccountExternalIdInfo (com.google.gerrit.extensions.common.AccountExternalIdInfo)4 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)4 ArrayList (java.util.ArrayList)4 ApprovalInfo (com.google.gerrit.extensions.common.ApprovalInfo)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)2 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)2 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)2 PublishChangeEditInput (com.google.gerrit.extensions.api.changes.PublishChangeEditInput)2