Don't enforce billing account map check on TEST TLDs (#1622)

* Don't enforce billing account map check on TEST TLDs

This was affecting monitoring (i.e. prober TLDs). Note that test TLDs are
already excluded from the billing account map check in the Registrar builder()
method (see PR #1601), but we forgot to make that same test TLD exclusion in the
EPP flows check (see PR #1605).
This commit is contained in:
Ben McIlwain 2022-05-04 16:59:25 -04:00 committed by GitHub
parent f1f05c49f8
commit 1dc810dd93
2 changed files with 51 additions and 3 deletions

View file

@ -124,6 +124,7 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldState;
import google.registry.model.tld.Registry.TldType;
import google.registry.model.tld.label.ReservationType;
import google.registry.model.tld.label.ReservedList;
import google.registry.model.tmch.ClaimsListDao;
@ -295,12 +296,16 @@ public class DomainFlowUtils {
/** Check if the registrar has the correct billing account map configured. */
public static void checkHasBillingAccount(String registrarId, String tld) throws EppException {
CurrencyUnit currency = Registry.get(tld).getCurrency();
Registry registry = Registry.get(tld);
// Don't enforce the billing account check on test (i.e. prober/OT&E) TLDs.
if (registry.getTldType() == TldType.TEST) {
return;
}
if (!Registrar.loadByRegistrarIdCached(registrarId)
.get()
.getBillingAccountMap()
.containsKey(currency)) {
throw new DomainFlowUtils.MissingBillingAccountMapException(currency);
.containsKey(registry.getCurrency())) {
throw new DomainFlowUtils.MissingBillingAccountMapException(registry.getCurrency());
}
}

View file

@ -15,11 +15,16 @@
package google.registry.flows.domain;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.flows.domain.DomainFlowUtils.checkHasBillingAccount;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newRegistry;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.CHF;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSortedMap;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.domain.DomainFlowUtils.BadDomainNameCharacterException;
@ -29,12 +34,15 @@ import google.registry.flows.domain.DomainFlowUtils.DomainLabelTooLongException;
import google.registry.flows.domain.DomainFlowUtils.EmptyDomainNamePartException;
import google.registry.flows.domain.DomainFlowUtils.InvalidPunycodeException;
import google.registry.flows.domain.DomainFlowUtils.LeadingDashException;
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
import google.registry.model.domain.DomainBase;
import google.registry.model.tld.Registry.TldType;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DualDatabaseTest;
import google.registry.testing.TestOfyAndSql;
import org.joda.money.Money;
import org.junit.jupiter.api.BeforeEach;
@DualDatabaseTest
@ -153,4 +161,39 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBas
.isEqualTo("Non-IDN domain names cannot contain dashes in the third or fourth position");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@TestOfyAndSql
void testCheckHasBillingAccount_ignoresTestTlds() throws EppException {
persistFoobarTld(TldType.TEST);
checkHasBillingAccount("TheRegistrar", "foobar");
}
@TestOfyAndSql
void testCheckHasBillingAccount_failsOnRealTld() throws EppException {
persistFoobarTld(TldType.REAL);
MissingBillingAccountMapException thrown =
assertThrows(
MissingBillingAccountMapException.class,
() -> checkHasBillingAccount("TheRegistrar", "foobar"));
assertThat(thrown)
.hasMessageThat()
.isEqualTo("Registrar is not fully onboarded for TLDs that bill in CHF");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
private void persistFoobarTld(TldType tldType) {
persistResource(
newRegistry("foobar", "FOOBAR")
.asBuilder()
.setTldType(tldType)
.setCurrency(CHF)
.setCreateBillingCost(Money.ofMajor(CHF, 800))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(CHF, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(CHF, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(CHF, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(CHF, 800))
.setRestoreBillingCost(Money.ofMajor(CHF, 800))
.build());
}
}