AccountIT: Expand tests for adding email addresses

Expand the tests to include adding a valid email address with .local
domain. Although this is not in the list of TLDs currently supported
by the commons validator, it was added to the TLD override list in
change I95bfabeeb.

Also expand the tests for invalid email address to include an address
that does not have username part, and one that uses a TLD that is
not recognized by the commons validator.

Change-Id: I057b4906cd8dff80013bc9e2e2674c24832ff483
This commit is contained in:
David Pursehouse 2017-01-28 16:08:27 +09:00
parent c4f1aec9c2
commit 2bee47f43c

View File

@ -408,7 +408,11 @@ public class AccountIT extends AbstractDaemonTest {
@Test
public void addEmail() throws Exception {
List<String> emails = ImmutableList.of(
"new.email@example.com", "new.email@example.systems");
"new.email@example.com",
"new.email@example.systems",
// Not in the list of TLDs but added to override in OutgoingEmailValidator
"new.email@example.local");
for (String email : emails) {
EmailInput input = new EmailInput();
input.email = email;
@ -419,13 +423,30 @@ public class AccountIT extends AbstractDaemonTest {
@Test
public void addInvalidEmail() throws Exception {
EmailInput input = new EmailInput();
input.email = "invalid@";
input.noConfirmation = true;
List<String> emails = ImmutableList.of(
// Missing domain part
"new.email",
exception.expect(BadRequestException.class);
exception.expectMessage("invalid email address");
gApi.accounts().self().addEmail(input);
// Missing domain part
"new.email@",
// Missing user part
"@example.com",
// Non-supported TLD (see tlds-alpha-by-domain.txt)
"new.email@example.blog"
);
for (String email : emails) {
EmailInput input = new EmailInput();
input.email = email;
input.noConfirmation = true;
try {
gApi.accounts().self().addEmail(input);
fail("Expected BadRequestException for invalid email address: " + email);
} catch (BadRequestException e) {
assertThat(e).hasMessage("invalid email address");
}
}
}
@Test