use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CorsIT method origin.
@Test
public void origin() throws Exception {
Result change = createChange();
String url = "/changes/" + change.getChangeId() + "/detail";
RestResponse r = adminRestSession.get(url);
r.assertOK();
assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
assertThat(r.getHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS)).isNull();
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.RestResponse in project gerrit by GerritCodeReview.
the class CorsIT method check.
private RestResponse check(String url, boolean accept, String origin) throws Exception {
Header hdr = new BasicHeader(ORIGIN, origin);
RestResponse r = adminRestSession.getWithHeader(url, hdr);
r.assertOK();
checkCors(r, accept, origin);
return r;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CreateChangeIT method setSignedOffByFooter.
// TODO(davido): Expose setting of account preferences in the API
private void setSignedOffByFooter() throws Exception {
RestResponse r = adminRestSession.get("/accounts/" + admin.email + "/preferences");
r.assertOK();
GeneralPreferencesInfo i = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
i.signedOffBy = true;
r = adminRestSession.put("/accounts/" + admin.email + "/preferences", i);
r.assertOK();
GeneralPreferencesInfo o = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
assertThat(o.signedOffBy).isTrue();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class GetRelatedIT method getRelated.
private List<ChangeAndCommit> getRelated(Change.Id changeId, int ps) throws Exception {
String url = String.format("/changes/%d/revisions/%d/related", changeId.get(), ps);
RestResponse r = adminRestSession.get(url);
r.assertOK();
return newGson().fromJson(r.getReader(), RelatedInfo.class).changes;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ChangeEditIT method diff.
@Test
public void diff() throws Exception {
createEmptyEditFor(changeId);
gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
Optional<EditInfo> edit = getEdit(changeId);
assertThat(edit).isPresent();
String editCommitId = edit.get().commit.commit;
RestResponse r = adminRestSession.getJsonAccept(urlDiff(changeId, editCommitId, FILE_NAME));
DiffInfo diff = readContentFromJson(r, DiffInfo.class);
assertThat(diff.diffHeader.get(0)).contains(FILE_NAME);
r = adminRestSession.getJsonAccept(urlDiff(changeId, FILE_NAME));
diff = readContentFromJson(r, DiffInfo.class);
assertThat(diff.diffHeader.get(0)).contains(FILE_NAME);
}
Aggregations