mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 11:38:35 +02:00
Validate provided email addresses when creating a Registrar
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240574585
This commit is contained in:
parent
4240be268a
commit
308d5eb76b
10 changed files with 137 additions and 24 deletions
|
@ -452,6 +452,42 @@ public class RegistrarTest extends EntityTestCase {
|
|||
() -> registrar.asBuilder().setAllowedTldsUncached(ImmutableSet.of("bad")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullEmail() {
|
||||
NullPointerException thrown =
|
||||
assertThrows(NullPointerException.class, () -> registrar.asBuilder().setEmailAddress(null));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Provided email was null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidEmail() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> registrar.asBuilder().setEmailAddress("lolcat"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Provided email lolcat is not a valid email address");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullIcannReferralEmail() {
|
||||
NullPointerException thrown =
|
||||
assertThrows(
|
||||
NullPointerException.class, () -> registrar.asBuilder().setIcannReferralEmail(null));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Provided email was null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidIcannEmail() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> registrar.asBuilder().setIcannReferralEmail("lolcat"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Provided email lolcat is not a valid email address");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_setAllowedTldsUncached_newTldNotInCache() {
|
||||
int origSingletonCacheRefreshSeconds =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue