mirror of
https://github.com/google/nomulus
synced 2026-01-09 23:47:49 +00:00
BSA check in DomainCheckFlow should check TLD (#2472)
Should not block labels if the tld is not enrolled with BSA.
This commit is contained in:
@@ -33,6 +33,7 @@ import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPredelegation;
|
||||
import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE;
|
||||
import static google.registry.model.tld.Tld.isEnrolledWithBsa;
|
||||
import static google.registry.model.tld.label.ReservationType.getTypeOfHighestSeverity;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
|
||||
@@ -188,7 +189,7 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
ImmutableSet<InternetDomainName> bsaBlockedDomainNames =
|
||||
existingDomains.size() == parsedDomains.size()
|
||||
? ImmutableSet.of()
|
||||
: getBsaBlockedDomains(parsedDomains.values());
|
||||
: getBsaBlockedDomains(parsedDomains.values(), now);
|
||||
Optional<AllocationTokenExtension> allocationTokenExtension =
|
||||
eppInput.getSingleExtension(AllocationTokenExtension.class);
|
||||
Optional<AllocationTokenDomainCheckResults> tokenDomainCheckResults =
|
||||
@@ -441,9 +442,11 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
}
|
||||
|
||||
static ImmutableSet<InternetDomainName> getBsaBlockedDomains(
|
||||
ImmutableCollection<InternetDomainName> parsedDomains) {
|
||||
ImmutableCollection<InternetDomainName> parsedDomains, DateTime now) {
|
||||
Map<String, ImmutableList<InternetDomainName>> labelToDomainNames =
|
||||
parsedDomains.stream()
|
||||
.filter(
|
||||
parsedDomain -> isEnrolledWithBsa(Tld.get(parsedDomain.parent().toString()), now))
|
||||
.collect(
|
||||
Collectors.groupingBy(
|
||||
parsedDomain -> parsedDomain.parts().get(0), toImmutableList()));
|
||||
|
||||
@@ -87,6 +87,7 @@ import google.registry.model.tld.Tld.TldState;
|
||||
import google.registry.model.tld.label.ReservedList;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -160,6 +161,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_otherwiseAvailable_blocked() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("example1");
|
||||
doCheckTest(
|
||||
create(false, "example1.tld", "Blocked by a GlobalBlock service"),
|
||||
@@ -169,6 +172,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_alsoRegistered_registered() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("example1");
|
||||
persistActiveDomain("example1.tld");
|
||||
doCheckTest(
|
||||
@@ -179,6 +184,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_alsoReserved_reserved() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("reserved");
|
||||
persistBsaLabel("allowedinsunrise");
|
||||
setEppInput("domain_check_one_tld_reserved.xml");
|
||||
@@ -191,6 +198,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_createAllowedWithToken() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("example1");
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistResource(
|
||||
@@ -208,6 +217,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_withIrrelevantTokenType() throws Exception {
|
||||
persistResource(
|
||||
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("example1");
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistResource(
|
||||
@@ -223,6 +234,19 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
create(false, "specificuse.tld", "Reserved; alloc. token required"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_bsaBlocked_onlyInEnrolledTlds() throws Exception {
|
||||
setEppInput("domain_check.xml");
|
||||
createTlds("com", "net", "org");
|
||||
persistResource(
|
||||
Tld.get("com").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
persistBsaLabel("example");
|
||||
doCheckTest(
|
||||
create(false, "example.com", "Blocked by a GlobalBlock service"),
|
||||
create(true, "example.net", null),
|
||||
create(true, "example.org", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_clTridNotSpecified() throws Exception {
|
||||
setEppInput("domain_check_no_cltrid.xml");
|
||||
|
||||
Reference in New Issue
Block a user