mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Enforce abuse WHOIS contact for REAL registrars when adding TLDs
We do not enforce this for non-REAL registrars or in any environment other than UNITTEST or PRODUCTION. This is similar but separate to [] since we can add allowed TLDs in either location. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=239510275
This commit is contained in:
parent
9bf6a860bb
commit
7ff6667bdf
6 changed files with 210 additions and 12 deletions
|
@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.Registrar.State;
|
||||
import google.registry.model.registrar.Registrar.Type;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
|
@ -86,43 +87,94 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
|
||||
@Test
|
||||
public void testSuccess_allowedTlds() throws Exception {
|
||||
persistWhoisAbuseContact();
|
||||
createTlds("xn--q9jyb4c", "foobar");
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
|
||||
.build());
|
||||
runCommand("--allowed_tlds=xn--q9jyb4c,foobar", "--force", "NewRegistrar");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--allowed_tlds=xn--q9jyb4c,foobar",
|
||||
"--force",
|
||||
"NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getAllowedTlds())
|
||||
.containsExactly("xn--q9jyb4c", "foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addAllowedTlds() throws Exception {
|
||||
persistWhoisAbuseContact();
|
||||
createTlds("xn--q9jyb4c", "foo", "bar");
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
|
||||
.build());
|
||||
runCommand("--add_allowed_tlds=foo,bar", "--force", "NewRegistrar");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--add_allowed_tlds=foo,bar",
|
||||
"--force",
|
||||
"NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getAllowedTlds())
|
||||
.containsExactly("xn--q9jyb4c", "foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addAllowedTldsWithDupes() throws Exception {
|
||||
persistWhoisAbuseContact();
|
||||
createTlds("xn--q9jyb4c", "foo", "bar");
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
|
||||
.build());
|
||||
runCommand("--add_allowed_tlds=xn--q9jyb4c,foo,bar", "--force", "NewRegistrar");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--add_allowed_tlds=xn--q9jyb4c,foo,bar",
|
||||
"--force",
|
||||
"NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getAllowedTlds())
|
||||
.isEqualTo(ImmutableSet.of("xn--q9jyb4c", "foo", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_allowedTldsInNonProductionEnvironment() throws Exception {
|
||||
createTlds("xn--q9jyb4c", "foobar");
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
|
||||
.build());
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.SANDBOX,
|
||||
"--allowed_tlds=xn--q9jyb4c,foobar",
|
||||
"--force",
|
||||
"NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getAllowedTlds())
|
||||
.containsExactly("xn--q9jyb4c", "foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_allowedTldsInPdtRegistrar() throws Exception {
|
||||
createTlds("xn--q9jyb4c", "foobar");
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
.setType(Type.PDT)
|
||||
.setIanaIdentifier(9995L)
|
||||
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
|
||||
.build());
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--allowed_tlds=xn--q9jyb4c,foobar",
|
||||
"--force",
|
||||
"NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getAllowedTlds())
|
||||
.containsExactly("xn--q9jyb4c", "foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_ipWhitelist() throws Exception {
|
||||
assertThat(loadRegistrar("NewRegistrar").getIpAddressWhitelist()).isEmpty();
|
||||
|
@ -531,6 +583,36 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
runCommand("--allowed_tlds=bar", "--add_allowed_tlds=foo", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setAllowedTldsWithoutAbuseContact() {
|
||||
createTlds("bar");
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--allowed_tlds=bar",
|
||||
"--force",
|
||||
"TheRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().startsWith("Cannot modify allowed TLDs");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addAllowedTldsWithoutAbuseContact() {
|
||||
createTlds("bar");
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--add_allowed_tlds=bar",
|
||||
"--force",
|
||||
"TheRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().startsWith("Cannot modify allowed TLDs");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidIpWhitelist() {
|
||||
assertThrows(
|
||||
|
@ -732,4 +814,12 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
runCommand("--po_number=null", "--force", "NewRegistrar");
|
||||
assertThat(loadRegistrar("NewRegistrar").getPoNumber()).isEmpty();
|
||||
}
|
||||
|
||||
private void persistWhoisAbuseContact() {
|
||||
persistResource(
|
||||
AppEngineRule.makeRegistrarContact1()
|
||||
.asBuilder()
|
||||
.setVisibleInDomainWhoisAsAbuse(true)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue