Search in sources :

Example 16 with AccountIndexedCounter

use of com.google.gerrit.acceptance.AccountIndexedCounter in project gerrit by GerritCodeReview.

the class AccountIT method shouldAllowQueryByEmailForInactiveUser.

@Test
public void shouldAllowQueryByEmailForInactiveUser() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        Account.Id activatableAccountId = accountOperations.newAccount().inactive().preferredEmail("foo@activatable.com").create();
        accountIndexedCounter.assertReindexOf(activatableAccountId, 1);
    }
    gApi.changes().query("owner:foo@activatable.com").get();
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 17 with AccountIndexedCounter

use of com.google.gerrit.acceptance.AccountIndexedCounter in project gerrit by GerritCodeReview.

the class AccountIT method addOtherUsersGpgKey_Conflict.

@Test
public void addOtherUsersGpgKey_Conflict() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        // Both users have a matching external ID for this key.
        addExternalIdEmail(admin, "test5@example.com");
        accountIndexedCounter.clear();
        accountsUpdateProvider.get().update("Add External ID", user.id(), u -> u.addExternalId(externalIdFactory.create("foo", "myId", user.id())));
        accountIndexedCounter.assertReindexOf(user);
        TestKey key = validKeyWithSecondUserId();
        addGpgKey(key.getPublicKeyArmored());
        requestScopeOperations.setApiUser(user.id());
        ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> addGpgKey(user, key.getPublicKeyArmored()));
        assertThat(thrown).hasMessageThat().contains("GPG key already associated with another account");
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) TestKey(com.google.gerrit.gpg.testing.TestKey) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 18 with AccountIndexedCounter

use of com.google.gerrit.acceptance.AccountIndexedCounter in project gerrit by GerritCodeReview.

the class AccountIT method createAnonymousCowardByAccountCreator.

@Test
public void createAnonymousCowardByAccountCreator() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        TestAccount anonymousCoward = accountCreator.create();
        accountIndexedCounter.assertReindexOf(anonymousCoward);
        assertUserBranchWithoutAccountConfig(anonymousCoward.id());
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 19 with AccountIndexedCounter

use of com.google.gerrit.acceptance.AccountIndexedCounter in project gerrit by GerritCodeReview.

the class AccountIT method addReviewerToIgnoredChange.

@Test
public void addReviewerToIgnoredChange() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        PushOneCommit.Result r = createChange();
        requestScopeOperations.setApiUser(user.id());
        gApi.changes().id(r.getChangeId()).ignore(true);
        sender.clear();
        requestScopeOperations.setApiUser(admin.id());
        ReviewerInput in = new ReviewerInput();
        in.reviewer = user.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        List<Message> messages = sender.getMessages();
        assertThat(messages).hasSize(0);
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 20 with AccountIndexedCounter

use of com.google.gerrit.acceptance.AccountIndexedCounter in project gerrit by GerritCodeReview.

the class AccountIT method ignoreChange.

@Test
public void ignoreChange() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        TestAccount user2 = accountCreator.user2();
        accountIndexedCounter.clear();
        PushOneCommit.Result r = createChange();
        ReviewerInput in = new ReviewerInput();
        in.reviewer = user.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        in = new ReviewerInput();
        in.reviewer = user2.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        requestScopeOperations.setApiUser(user.id());
        gApi.changes().id(r.getChangeId()).ignore(true);
        sender.clear();
        requestScopeOperations.setApiUser(admin.id());
        gApi.changes().id(r.getChangeId()).abandon();
        List<Message> messages = sender.getMessages();
        assertThat(messages).hasSize(1);
        assertThat(messages.get(0).rcpt()).containsExactly(user2.getNameEmail());
        accountIndexedCounter.assertNoReindex();
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AccountIndexedCounter (com.google.gerrit.acceptance.AccountIndexedCounter)47 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)47 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)44 Test (org.junit.Test)44 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)18 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)18 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)16 TestAccount (com.google.gerrit.acceptance.TestAccount)13 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)13 Config (org.eclipse.jgit.lib.Config)13 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)7 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)5 TestKey (com.google.gerrit.gpg.testing.TestKey)5 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)4 Message (com.google.gerrit.testing.FakeEmailSender.Message)4 UseSsh (com.google.gerrit.acceptance.UseSsh)3 Account (com.google.gerrit.entities.Account)3 GpgKeyInfo (com.google.gerrit.extensions.common.GpgKeyInfo)3 SshKeyInfo (com.google.gerrit.extensions.common.SshKeyInfo)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3