Search in sources :

Example 56 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class ChangeIncludedInIT method includedInOpenChange.

@Test
public void includedInOpenChange() throws Exception {
    Result result = createChange();
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).isEmpty();
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).isEmpty();
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 57 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class ChangeIncludedInIT method includedInMergedChange.

@Test
public void includedInMergedChange() throws Exception {
    Result result = createChange();
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).review(ReviewInput.approve());
    gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).containsExactly("master");
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).isEmpty();
    projectOperations.project(project).forUpdate().add(allow(Permission.CREATE_TAG).ref(R_TAGS + "*").group(adminGroupUuid())).update();
    gApi.projects().name(project.get()).tag("test-tag").create(new TagInput());
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).containsExactly("test-tag");
    createBranch(BranchNameKey.create(project, "test-branch"));
    assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches).containsExactly("master", "test-branch");
}
Also used : TagInput(com.google.gerrit.extensions.api.projects.TagInput) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 58 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class CorsIT method origins.

@Test
public void origins() throws Exception {
    Result change = createChange();
    String url = "/changes/" + change.getChangeId() + "/detail";
    check(url, true, "http://example.com");
    check(url, true, "https://sub.example.com");
    check(url, true, "http://friend.ly");
    check(url, false, "http://evil.attacker");
    check(url, false, "http://friendsly");
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 59 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class CorsIT method putWithOtherOriginAccepted.

@Test
public void putWithOtherOriginAccepted() throws Exception {
    Result change = createChange();
    String origin = "http://example.com";
    RestResponse r = adminRestSession.putWithHeaders("/changes/" + change.getChangeId() + "/topic", /* content = */
    "A", new BasicHeader(ORIGIN, origin));
    r.assertOK();
    checkCors(r, true, origin);
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) BasicHeader(org.apache.http.message.BasicHeader) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 60 with Result

use of com.google.gerrit.acceptance.PushOneCommit.Result in project gerrit by GerritCodeReview.

the class CorsIT method preflightOk.

@Test
public void preflightOk() throws Exception {
    Result change = createChange();
    String origin = "http://example.com";
    Request req = Request.Options(adminRestSession.url() + "/a/changes/" + change.getChangeId() + "/detail");
    req.addHeader(ORIGIN, origin);
    req.addHeader(ACCESS_CONTROL_REQUEST_METHOD, "GET");
    req.addHeader(ACCESS_CONTROL_REQUEST_HEADERS, "X-Requested-With");
    RestResponse res = adminRestSession.execute(req);
    res.assertOK();
    String vary = res.getHeader(VARY);
    assertWithMessage(VARY).that(vary).isNotNull();
    assertThat(Splitter.on(", ").splitToList(vary)).containsExactly(ORIGIN, ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
    checkCors(res, true, origin);
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) Request(org.apache.http.client.fluent.Request) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

Result (com.google.gerrit.acceptance.PushOneCommit.Result)75 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)59 Test (org.junit.Test)59 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)28 RestResponse (com.google.gerrit.acceptance.RestResponse)17 ObjectId (org.eclipse.jgit.lib.ObjectId)11 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)9 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)8 DiffInfo (com.google.gerrit.extensions.common.DiffInfo)7 BasicHeader (org.apache.http.message.BasicHeader)7 Request (org.apache.http.client.fluent.Request)6 FileInfo (com.google.gerrit.extensions.common.FileInfo)5 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)4 TagInput (com.google.gerrit.extensions.api.projects.TagInput)4 Project (com.google.gerrit.entities.Project)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)3 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)3 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 Before (org.junit.Before)3