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();
}
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");
}
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");
}
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);
}
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);
}
Aggregations