From 1dc810dd93dbd78e78f5bf9e67fa0d02e1955637 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Wed, 4 May 2022 16:59:25 -0400 Subject: [PATCH] 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). --- .../flows/domain/DomainFlowUtils.java | 11 +++-- .../flows/domain/DomainFlowUtilsTest.java | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index c6ddf68d5..3ea488afb 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -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()); } } diff --git a/core/src/test/java/google/registry/flows/domain/DomainFlowUtilsTest.java b/core/src/test/java/google/registry/flows/domain/DomainFlowUtilsTest.java index 1f3730d15..401112ea7 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainFlowUtilsTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainFlowUtilsTest.java @@ -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 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()); + } }