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);
}
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));
}
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());
}
}
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();
}
}
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");
}
Aggregations