Search in sources :

Example 21 with EmailInput

use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.

the class AccountIT method detailOfOtherAccountIncludeSecondaryEmailsWithModifyAccount.

@Test
public void detailOfOtherAccountIncludeSecondaryEmailsWithModifyAccount() throws Exception {
    String email = "preferred@example.com";
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
    String secondaryEmail = "secondary@example.com";
    EmailInput input = newEmailInput(secondaryEmail);
    gApi.accounts().id(foo.id().get()).addEmail(input);
    AccountDetailInfo detail = gApi.accounts().id(foo.id().get()).detail();
    assertThat(detail.secondaryEmails).containsExactly(secondaryEmail);
}
Also used : AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 22 with EmailInput

use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.

the class AccountIT method addEmail.

@Test
public void addEmail() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        List<String> emails = ImmutableList.of("new.email@example.com", "new.email@example.systems");
        Set<String> currentEmails = getEmails();
        for (String email : emails) {
            assertThat(currentEmails).doesNotContain(email);
            EmailInput input = newEmailInput(email);
            gApi.accounts().self().addEmail(input);
            accountIndexedCounter.assertReindexOf(admin);
        }
        requestScopeOperations.resetCurrentApiUser();
        assertThat(getEmails()).containsAtLeastElementsIn(emails);
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 23 with EmailInput

use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.

the class AccountIT method detailOfOtherAccountDoesntIncludeSecondaryEmailsWithoutModifyAccount.

@Test
public void detailOfOtherAccountDoesntIncludeSecondaryEmailsWithoutModifyAccount() throws Exception {
    String email = "preferred@example.com";
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
    String secondaryEmail = "secondary@example.com";
    EmailInput input = newEmailInput(secondaryEmail);
    gApi.accounts().id(foo.id().get()).addEmail(input);
    requestScopeOperations.setApiUser(user.id());
    AccountDetailInfo detail = gApi.accounts().id(foo.id().get()).detail();
    assertThat(detail.secondaryEmails).isNull();
}
Also used : AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 24 with EmailInput

use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.

the class SuggestReviewersIT method createAccountWithSecondaryEmail.

private TestAccount createAccountWithSecondaryEmail(String name, String secondaryEmail) throws Exception {
    TestAccount foo = accountCreator.create(name(name), "foo.primary@example.com", "Foo", null);
    EmailInput input = new EmailInput();
    input.email = secondaryEmail;
    input.noConfirmation = true;
    gApi.accounts().id(foo.id().get()).addEmail(input);
    return foo;
}
Also used : EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) TestAccount(com.google.gerrit.acceptance.TestAccount)

Aggregations

EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)24 Test (org.junit.Test)19 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)18 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)16 TestAccount (com.google.gerrit.acceptance.TestAccount)9 AccountIndexedCounter (com.google.gerrit.acceptance.AccountIndexedCounter)7 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)7 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)4 AccountDetailInfo (com.google.gerrit.extensions.common.AccountDetailInfo)4 EmailInfo (com.google.gerrit.extensions.common.EmailInfo)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)3 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)2 Sandboxed (com.google.gerrit.acceptance.Sandboxed)2 EmailException (com.google.gerrit.exceptions.EmailException)2 StopStrategies (com.github.rholder.retry.StopStrategies)1 FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1