Search in sources :

Example 41 with TestAccount

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

the class AccountIT method updateAccountWithoutAccountConfigNoteDb.

@Test
public void updateAccountWithoutAccountConfigNoteDb() throws Exception {
    TestAccount anonymousCoward = accountCreator.create();
    assertUserBranchWithoutAccountConfig(anonymousCoward.id());
    String status = "OOO";
    Optional<AccountState> accountState = accountsUpdateProvider.get().update("Set status", anonymousCoward.id(), u -> u.setStatus(status));
    assertThat(accountState).isPresent();
    Account account = accountState.get().account();
    assertThat(account.fullName()).isNull();
    assertThat(account.status()).isEqualTo(status);
    assertUserBranch(anonymousCoward.id(), null, status);
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) AccountState(com.google.gerrit.server.account.AccountState) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 42 with TestAccount

use of com.google.gerrit.acceptance.TestAccount 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)

Example 43 with TestAccount

use of com.google.gerrit.acceptance.TestAccount 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 44 with TestAccount

use of com.google.gerrit.acceptance.TestAccount 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)

Example 45 with TestAccount

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

the class AccountIT method cannotGetEmailsOfOtherAccountWithoutModifyAccount.

@Test
public void cannotGetEmailsOfOtherAccountWithoutModifyAccount() throws Exception {
    String email = "preferred2@example.com";
    TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
    requestScopeOperations.setApiUser(user.id());
    AuthException thrown = assertThrows(AuthException.class, () -> gApi.accounts().id(foo.id().get()).getEmails());
    assertThat(thrown).hasMessageThat().contains("modify account not permitted");
}
Also used : AuthException(com.google.gerrit.extensions.restapi.AuthException) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

TestAccount (com.google.gerrit.acceptance.TestAccount)137 Test (org.junit.Test)122 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)106 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)54 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)19 AbstractNotificationTest (com.google.gerrit.acceptance.AbstractNotificationTest)15 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)14 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)13 ArrayList (java.util.ArrayList)13 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)12 AccountIndexedCounter (com.google.gerrit.acceptance.AccountIndexedCounter)10 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)10 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)10 Message (com.google.gerrit.testing.FakeEmailSender.Message)10 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)9 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)9 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)9 AuthException (com.google.gerrit.extensions.restapi.AuthException)9 AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)8 Change (com.google.gerrit.entities.Change)8