AccountIT: Factor out a utility method to create EmailInput
Change-Id: I827c3a5098a15df91b069fabfd2e5cd2bfc4d1e4
This commit is contained in:
@@ -533,9 +533,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
Set<String> currentEmails = getEmails();
|
||||
for (String email : emails) {
|
||||
assertThat(currentEmails).doesNotContain(email);
|
||||
EmailInput input = new EmailInput();
|
||||
input.email = email;
|
||||
input.noConfirmation = true;
|
||||
EmailInput input = newEmailInput(email);
|
||||
gApi.accounts().self().addEmail(input);
|
||||
accountIndexedCounter.assertReindexOf(admin);
|
||||
}
|
||||
@@ -560,9 +558,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
// Non-supported TLD (see tlds-alpha-by-domain.txt)
|
||||
"new.email@example.africa");
|
||||
for (String email : emails) {
|
||||
EmailInput input = new EmailInput();
|
||||
input.email = email;
|
||||
input.noConfirmation = true;
|
||||
EmailInput input = newEmailInput(email);
|
||||
try {
|
||||
gApi.accounts().self().addEmail(input);
|
||||
fail("Expected BadRequestException for invalid email address: " + email);
|
||||
@@ -576,9 +572,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void cannotAddNonConfirmedEmailWithoutModifyAccountPermission() throws Exception {
|
||||
TestAccount account = accountCreator.create(name("user"));
|
||||
EmailInput input = new EmailInput();
|
||||
input.email = "test@test.com";
|
||||
input.noConfirmation = true;
|
||||
EmailInput input = newEmailInput("test@test.com");
|
||||
setApiUser(user);
|
||||
exception.expect(AuthException.class);
|
||||
gApi.accounts().id(account.username).addEmail(input);
|
||||
@@ -587,9 +581,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteEmail() throws Exception {
|
||||
String email = "foo.bar@example.com";
|
||||
EmailInput input = new EmailInput();
|
||||
input.email = email;
|
||||
input.noConfirmation = true;
|
||||
EmailInput input = newEmailInput(email);
|
||||
gApi.accounts().self().addEmail(input);
|
||||
|
||||
resetCurrentApiUser();
|
||||
@@ -1655,6 +1647,13 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
assertThat(newAccount.getMetaId()).isEqualTo(getMetaId(accountId));
|
||||
}
|
||||
|
||||
private EmailInput newEmailInput(String email) {
|
||||
EmailInput input = new EmailInput();
|
||||
input.email = email;
|
||||
input.noConfirmation = true;
|
||||
return input;
|
||||
}
|
||||
|
||||
private String getMetaId(Account.Id accountId) throws IOException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers);
|
||||
RevWalk rw = new RevWalk(repo);
|
||||
|
||||
Reference in New Issue
Block a user