use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method lookUpByPreferredEmail.
@Test
public void lookUpByPreferredEmail() throws Exception {
// create an inconsistent account that has a preferred email without external ID
String prefix = "foo.preferred";
String prefEmail = prefix + "@example.com";
TestAccount foo = accountCreator.create(name("foo"));
accountsUpdateProvider.get().update("Set Preferred Email", foo.id(), u -> u.setPreferredEmail(prefEmail));
// verify that the account is still found when using the preferred email to lookup the account
ImmutableSet<Account.Id> accountsByPrefEmail = emails.getAccountFor(prefEmail);
assertThat(accountsByPrefEmail).hasSize(1);
assertThat(Iterables.getOnlyElement(accountsByPrefEmail)).isEqualTo(foo.id());
// look up by email prefix doesn't find the account
accountsByPrefEmail = emails.getAccountFor(prefix);
assertThat(accountsByPrefEmail).isEmpty();
// look up by other case doesn't find the account
accountsByPrefEmail = emails.getAccountFor(prefEmail.toUpperCase(Locale.US));
assertThat(accountsByPrefEmail).isEmpty();
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method createByAccountCreator.
private Account.Id createByAccountCreator(int expectedAccountReindexCalls) throws Exception {
AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
String name = "foo";
TestAccount foo = accountCreator.create(name);
AccountInfo info = gApi.accounts().id(foo.id().get()).get();
assertThat(info.username).isEqualTo(name);
assertThat(info.name).isEqualTo(name);
accountIndexedCounter.assertReindexOf(foo, expectedAccountReindexCalls);
assertUserBranch(foo.id(), name, null);
return foo.id();
}
}
use of com.google.gerrit.acceptance.TestAccount 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);
}
use of com.google.gerrit.acceptance.TestAccount 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();
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AbstractSubmitOnPush method pushForSubmitWithNotifyingUsersExplicitly.
@Test
public void pushForSubmitWithNotifyingUsersExplicitly() throws Exception {
projectOperations.project(project).forUpdate().add(allow(Permission.SUBMIT).ref("refs/for/refs/heads/master").group(adminGroupUuid())).update();
TestAccount user = accountCreator.user1();
String pushSpec = "refs/for/master%reviewer=" + user.email() + ",cc=" + user.email();
TestAccount user2 = accountCreator.user2();
sender.clear();
PushOneCommit.Result result = pushTo(pushSpec + ",submit,notify=" + NotifyHandling.NONE + ",notify-to=" + user2.email());
result.assertOkStatus();
assertThatEmailsForChangeCreationAndSubmitWereSent(user2, RecipientType.TO);
sender.clear();
result = pushTo(pushSpec + ",submit,notify=" + NotifyHandling.NONE + ",notify-cc=" + user2.email());
result.assertOkStatus();
assertThatEmailsForChangeCreationAndSubmitWereSent(user2, RecipientType.CC);
sender.clear();
result = pushTo(pushSpec + ",submit,notify=" + NotifyHandling.NONE + ",notify-bcc=" + user2.email());
result.assertOkStatus();
assertThatEmailsForChangeCreationAndSubmitWereSent(user2, RecipientType.BCC);
}
Aggregations