Search in sources :

Example 71 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class MailProcessorIT method limitCumulativeCommentSize.

@Test
@GerritConfig(name = "change.cumulativeCommentSizeLimit", value = "7k")
public void limitCumulativeCommentSize() throws Exception {
    // Use large sizes because autogenerated messages already have O(100) bytes.
    String commentText2000Bytes = new String(new char[2000]).replace("\0", "x");
    String changeId = createChangeWithReview();
    CommentInput commentInput = new CommentInput();
    commentInput.line = 1;
    commentInput.message = commentText2000Bytes;
    commentInput.path = FILE_NAME;
    ReviewInput reviewInput = new ReviewInput().message(commentText2000Bytes);
    reviewInput.comments = ImmutableMap.of(FILE_NAME, ImmutableList.of(commentInput));
    // Use up ~4000 bytes.
    gApi.changes().id(changeId).current().review(reviewInput);
    ChangeInfo changeInfo = gApi.changes().id(changeId).get();
    String ts = MailProcessingUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(gApi.changes().id(changeId).get().updated.toInstant(), ZoneId.of("UTC")));
    // Hit the limit when trying that again.
    MailMessage.Builder mailMessage = messageBuilderWithDefaultFields();
    String txt = newPlaintextBody(getChangeUrl(changeInfo) + "/1", "change message: " + commentText2000Bytes, "reply to comment: " + commentText2000Bytes, null);
    mailMessage.textContent(txt + textFooterForChange(changeInfo._number, ts));
    List<CommentInfo> commentsBefore = testCommentHelper.getPublishedComments(changeId);
    mailProcessor.process(mailMessage.build());
    assertThat(testCommentHelper.getPublishedComments(changeId)).isEqualTo(commentsBefore);
    assertNotifyTo(user);
    Message message = sender.nextMessage();
    assertThat(message.body()).contains("rejected one or more comments");
}
Also used : MailMessage(com.google.gerrit.mail.MailMessage) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) MailMessage(com.google.gerrit.mail.MailMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test)

Example 72 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class ExternalUserPermissionIT method externalUser_isNotContainedInRegisteredUsersIfNotConfigured.

@GerritConfig(name = "groups.includeExternalUsersInRegisteredUsersGroup", value = "false")
@Test
public void externalUser_isNotContainedInRegisteredUsersIfNotConfigured() {
    ExternalUser user = createUserInGroup("1", "it-department");
    assertThat(user.getEffectiveGroups().contains(REGISTERED_USERS)).isFalse();
}
Also used : ExternalUser(com.google.gerrit.server.ExternalUser) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 73 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class AbstractIndexTests method indexChange.

@Test
@GerritConfig(name = "index.autoReindexIfStale", value = "false")
public void indexChange() throws Exception {
    ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
        PushOneCommit.Result change = createChange("first change", "test1.txt", "test1");
        String changeId = change.getChangeId();
        String changeLegacyId = change.getChange().getId().toString();
        ChangeInfo changeInfo = gApi.changes().id(changeId).get();
        disableChangeIndexWrites();
        amendChange(changeId, "second test", "test2.txt", "test2");
        assertChangeQuery(change.getChange(), false);
        enableChangeIndexWrites();
        changeIndexedCounter.clear();
        String cmd = Joiner.on(" ").join("gerrit", "index", "changes", changeLegacyId);
        adminSshSession.exec(cmd);
        adminSshSession.assertSuccess();
        changeIndexedCounter.assertReindexOf(changeInfo, 1);
        assertChangeQuery(change.getChange(), true);
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ChangeIndexedCounter(com.google.gerrit.acceptance.ChangeIndexedCounter) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 74 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class AccountIT method addEmailSendsConfirmationEmail.

@Test
@GerritConfig(name = "auth.registerEmailPrivateKey", value = "HsOc6l_2lhS9G7sE_RsnS7Z6GJjdRDX14co=")
public void addEmailSendsConfirmationEmail() throws Exception {
    String email = "new.email@example.com";
    EmailInput input = newEmailInput(email, false);
    gApi.accounts().self().addEmail(input);
    assertThat(sender.getMessages()).hasSize(1);
    Message m = sender.getMessages().get(0);
    assertThat(m.rcpt()).containsExactly(Address.create(email));
}
Also used : Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 75 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class AccountIT method addEmailToBeConfirmedToOtherAccount.

@Test
@GerritConfig(name = "auth.registerEmailPrivateKey", value = "HsOc6l_2lhS9G7sE-RsnS7Z6GJjdRDX14co=")
public void addEmailToBeConfirmedToOtherAccount() throws Exception {
    TestAccount user = accountCreator.create();
    String email = "me@example.com";
    gApi.accounts().id(user.id().get()).addEmail(newEmailInput(email, false));
}
Also used : PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)187 Test (org.junit.Test)185 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)170 RestResponse (com.google.gerrit.acceptance.RestResponse)56 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)40 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)35 Repository (org.eclipse.jgit.lib.Repository)21 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)19 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)17 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)17 ExternalIdNotes (com.google.gerrit.server.account.externalids.ExternalIdNotes)16 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)14 TestRepository (org.eclipse.jgit.junit.TestRepository)14 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)11 TestAccount (com.google.gerrit.acceptance.TestAccount)10 Account (com.google.gerrit.entities.Account)10 RevCommit (org.eclipse.jgit.revwalk.RevCommit)10 Project (com.google.gerrit.entities.Project)9 ConfigInfo (com.google.gerrit.extensions.api.projects.ConfigInfo)9 Change (com.google.gerrit.entities.Change)8