use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterBlockDoesNotFilterNotListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "BLOCK")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@gerritcodereview\\.com", "a@b\\.com" })
public void listFilterBlockDoesNotFilterNotListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(3);
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterAllowDoesNotFilterListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "ALLOW")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+ser1@example\\.com", "a@b\\.com" })
public void listFilterAllowDoesNotFilterListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(3);
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method mergeableFailsWhenNotIndexed.
@Test
@GerritConfig(name = "change.mergeabilityComputationBehavior", value = "NEVER")
public void mergeableFailsWhenNotIndexed() throws Exception {
TestRepository<Repo> repo = createProject("repo");
RevCommit commit1 = repo.parseBody(repo.commit().add("file1", "contents1").create());
insert(repo, newChangeForCommit(repo, commit1));
Throwable thrown = assertThrows(Throwable.class, () -> assertQuery("status:open is:mergeable"));
assertThat(thrown.getCause()).isInstanceOf(QueryParseException.class);
assertThat(thrown).hasMessageThat().contains("'is:mergeable' operator is not supported by server");
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class PostReviewIT method validateCumulativeCommentSize.
@Test
@GerritConfig(name = "change.cumulativeCommentSizeLimit", value = "7k")
public void validateCumulativeCommentSize() throws Exception {
PushOneCommit.Result r = createChange();
when(mockCommentValidator.validateComments(eq(contextFor(r)), any())).thenReturn(ImmutableList.of());
// Use large sizes because autogenerated messages already have O(100) bytes.
String commentText2000Bytes = new String(new char[2000]).replace("\0", "x");
String filePath = r.getChange().currentFilePaths().get(0);
ReviewInput reviewInput = new ReviewInput().message(commentText2000Bytes);
CommentInput commentInput = new CommentInput();
commentInput.line = 1;
commentInput.message = commentText2000Bytes;
commentInput.path = filePath;
reviewInput.comments = ImmutableMap.of(filePath, ImmutableList.of(commentInput));
// Use up ~4000 bytes.
gApi.changes().id(r.getChangeId()).current().review(reviewInput);
// Hit the limit when trying that again.
BadRequestException exception = assertThrows(BadRequestException.class, () -> gApi.changes().id(r.getChangeId()).current().review(reviewInput));
assertThat(exception).hasMessageThat().contains("Exceeding maximum cumulative size of comments");
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class RevertIT method cantCreateRevertSubmissionWithoutProjectWritePermission.
@Test
@GerritConfig(name = "change.submitWholeTopic", value = "true")
public void cantCreateRevertSubmissionWithoutProjectWritePermission() throws Exception {
String secondProject = "secondProject";
projectOperations.newProject().name(secondProject).create();
TestRepository<InMemoryRepository> secondRepo = cloneProject(Project.nameKey("secondProject"), admin);
String topic = "topic";
String change1 = createChange(testRepo, "master", "first change", "a.txt", "message", topic).getChangeId();
String change2 = createChange(secondRepo, "master", "second change", "b.txt", "message", topic).getChangeId();
gApi.changes().id(change1).current().review(ReviewInput.approve());
gApi.changes().id(change2).current().review(ReviewInput.approve());
gApi.changes().id(change1).current().submit();
// revoke write permissions for the first repository.
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateProject(p -> p.setState(ProjectState.READ_ONLY));
u.save();
}
String expected = "project state " + ProjectState.READ_ONLY + " does not permit write";
// assert that if first repository has no write permissions, it will fail.
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(change1).revertSubmission());
assertThat(thrown).hasMessageThat().contains(expected);
// assert that if the first repository has no write permissions and a change from another
// repository is trying to revert the submission, it will fail.
thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(change2).revertSubmission());
assertThat(thrown).hasMessageThat().contains(expected);
}
Aggregations