use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.
the class AccountIT method addEmailToBeConfirmedToOwnAccount.
@Test
@GerritConfig(name = "auth.registerEmailPrivateKey", value = "HsOc6l_2lhS9G7sE-RsnS7Z6GJjdRDX14co=")
public void addEmailToBeConfirmedToOwnAccount() throws Exception {
TestAccount user = accountCreator.create();
requestScopeOperations.setApiUser(user.id());
String email = "self@example.com";
EmailInput input = newEmailInput(email, false);
gApi.accounts().self().addEmail(input);
}
use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.
the class AccountIT method getEmailsOfOtherAccount.
@Test
public void getEmailsOfOtherAccount() throws Exception {
String email = "preferred3@example.com";
String secondaryEmail = "secondary3@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id().get()).addEmail(input);
assertThat(gApi.accounts().id(foo.id().get()).getEmails().stream().map(e -> e.email).collect(toSet())).containsExactly(email, secondaryEmail);
}
use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.
the class AccountIT method cannotAddNonConfirmedEmailWithoutModifyAccountPermission.
@Test
public void cannotAddNonConfirmedEmailWithoutModifyAccountPermission() throws Exception {
TestAccount account = accountCreator.create(name("user"));
EmailInput input = newEmailInput("test@example.com");
requestScopeOperations.setApiUser(user.id());
assertThrows(AuthException.class, () -> gApi.accounts().id(account.username()).addEmail(input));
}
use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.
the class AccountIT method getOwnEmails.
@Test
public void getOwnEmails() throws Exception {
String email = "preferred@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
requestScopeOperations.setApiUser(foo.id());
assertThat(getEmails()).containsExactly(email);
requestScopeOperations.setApiUser(admin.id());
String secondaryEmail = "secondary@example.com";
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id().get()).addEmail(input);
requestScopeOperations.setApiUser(foo.id());
assertThat(getEmails()).containsExactly(email, secondaryEmail);
}
use of com.google.gerrit.extensions.api.accounts.EmailInput in project gerrit by GerritCodeReview.
the class AccountIT method deleteEmail.
@Test
public void deleteEmail() throws Exception {
AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
String email = "foo.bar@example.com";
EmailInput input = newEmailInput(email);
gApi.accounts().self().addEmail(input);
requestScopeOperations.resetCurrentApiUser();
assertThat(getEmails()).contains(email);
accountIndexedCounter.clear();
gApi.accounts().self().deleteEmail(input.email);
accountIndexedCounter.assertReindexOf(admin);
requestScopeOperations.resetCurrentApiUser();
assertThat(getEmails()).doesNotContain(email);
}
}
Aggregations