1
0
mirror of https://github.com/google/nomulus synced 2026-01-05 04:56:03 +00:00

Fix BSA validation (#2401)

Unblocked reserved names wrongly reported as missing unblockable domain.
This commit is contained in:
Weimin Yu
2024-04-12 15:54:59 -04:00
committed by GitHub
parent e434528cd3
commit 8721085d14
2 changed files with 24 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.bsa.BsaTransactions.bsaQuery;
import static google.registry.bsa.ReservedDomainsUtils.getAllReservedNames;
import static google.registry.bsa.ReservedDomainsUtils.isReservedDomain;
import static google.registry.bsa.persistence.BsaLabelUtils.isLabelBlocked;
import static google.registry.bsa.persistence.Queries.batchReadBsaLabelText;
import static google.registry.bsa.persistence.Queries.queryMissedRegisteredUnblockables;
import static google.registry.bsa.persistence.Queries.queryUnblockableDomainByLabels;
@@ -299,7 +300,9 @@ public class BsaValidateAction implements Runnable {
ImmutableList<String> checkForMissingReservedUnblockables(DateTime now) {
ImmutableList.Builder<String> errors = new ImmutableList.Builder<>();
try (Stream<ImmutableList<String>> reservedNames =
toBatches(getAllReservedNames(now), transactionBatchSize)) {
toBatches(
getAllReservedNames(now).filter(BsaValidateAction::isBlockedByBsa),
transactionBatchSize)) {
reservedNames
.map(this::checkOneBatchReservedDomainsForMissingUnblockables)
.forEach(errors::addAll);
@@ -338,6 +341,11 @@ public class BsaValidateAction implements Runnable {
return errors.build();
}
static boolean isBlockedByBsa(String domainInBsaEnrolledTld) {
InternetDomainName domainName = InternetDomainName.from(domainInBsaEnrolledTld);
return isLabelBlocked(domainName.parts().get(0));
}
static String parseBlockListLine(String line) {
int firstComma = line.indexOf(',');
checkArgument(firstComma > 0, "Invalid block list line: %s", line);

View File

@@ -337,6 +337,21 @@ public class BsaValidateActionTest {
.containsExactly("Missing unblockable domain: reserved-missing-in-app.app is reserved.");
}
@Test
void checkForMissingReservedUnblockables_unblockedReservedNotReported() {
persistResource(
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
createReservedList(
"rl",
Stream.of("reserved-only")
.collect(toImmutableMap(x -> x, x -> ReservationType.RESERVED_FOR_SPECIFIC_USE)));
addReservedListsToTld("app", ImmutableList.of("rl"));
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.nowUtc());
assertThat(errors).isEmpty();
}
@Test
void checkForMissingRegisteredUnblockables_success() {
persistResource(