mirror of
https://github.com/google/nomulus
synced 2026-09-08 17:17:02 +00:00
Check PAK is present on billing domain flows (#1605)
* Check PAK on domain create * Add unit test * update docs * Remove unneccesary setup * Fix blank line * Add check and test to all relevant flows * Change error message
This commit is contained in:
@@ -30,6 +30,7 @@ import static google.registry.testing.DatabaseHelper.persistReservedList;
|
||||
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.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -57,6 +58,7 @@ import google.registry.flows.domain.DomainFlowUtils.FeeChecksDontSupportPhasesEx
|
||||
import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException;
|
||||
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.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RestoresAreAlwaysForOneYearException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
|
||||
@@ -600,6 +602,24 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccount() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown = assertThrows(MissingBillingAccountMapException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistActiveDomain("example2.tld");
|
||||
|
||||
@@ -21,16 +21,20 @@ import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
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.JPY;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.domain.DomainClaimsCheckFlow.DomainClaimsCheckNotAllowedWithAllocationTokens;
|
||||
import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.ClaimsPeriodEndedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
|
||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||
@@ -40,6 +44,7 @@ import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.ReplayExtension;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -133,6 +138,24 @@ public class DomainClaimsCheckFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccount() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown = assertThrows(MissingBillingAccountMapException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistClaimsList(
|
||||
|
||||
@@ -59,6 +59,7 @@ import static google.registry.tmch.LordnTaskUtils.QUEUE_CLAIMS;
|
||||
import static google.registry.tmch.LordnTaskUtils.QUEUE_SUNRISE;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -117,6 +118,7 @@ import google.registry.flows.domain.DomainFlowUtils.LinkedResourcesDoNotExistExc
|
||||
import google.registry.flows.domain.DomainFlowUtils.MalformedTcnIdException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MaxSigLifeNotSupportedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingClaimsNoticeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingContactTypeException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingRegistrantException;
|
||||
@@ -2222,6 +2224,25 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccountMap() {
|
||||
persistContactsAndHosts();
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown = assertThrows(MissingBillingAccountMapException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_registrantNotAllowListed() {
|
||||
persistActiveContact("someone");
|
||||
|
||||
@@ -35,6 +35,7 @@ import static google.registry.testing.TestDataHelper.updateSubstitutions;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -55,6 +56,7 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyValueScaleException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.ExceedsMaxRegistrationYearsException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForPremiumNameException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrarMustBeActiveForThisOperationException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeException;
|
||||
@@ -122,6 +124,11 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
@BeforeEach
|
||||
void initDomainTest() {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar")
|
||||
.asBuilder()
|
||||
.setBillingAccountMap(ImmutableMap.of(USD, "123", EUR, "567"))
|
||||
.build());
|
||||
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5"));
|
||||
}
|
||||
|
||||
@@ -759,6 +766,25 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccountMap() throws Exception {
|
||||
persistDomain();
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown = assertThrows(MissingBillingAccountMapException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_pendingTransfer() throws Exception {
|
||||
persistDomain();
|
||||
|
||||
@@ -34,6 +34,7 @@ import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -53,6 +54,7 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyValueScaleException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.DomainReservedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForPremiumNameException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.PremiumNameBlockedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrarMustBeActiveForThisOperationException;
|
||||
@@ -106,6 +108,11 @@ class DomainRestoreRequestFlowTest
|
||||
@BeforeEach
|
||||
void initDomainTest() {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar")
|
||||
.asBuilder()
|
||||
.setBillingAccountMap(ImmutableMap.of(USD, "123", EUR, "567"))
|
||||
.build());
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
}
|
||||
|
||||
@@ -705,6 +712,25 @@ class DomainRestoreRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccount() throws Exception {
|
||||
persistPendingDeleteDomain();
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown = assertThrows(MissingBillingAccountMapException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
persistResource(
|
||||
|
||||
@@ -44,6 +44,7 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -70,6 +71,7 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyUnitMismatchExceptio
|
||||
import google.registry.flows.domain.DomainFlowUtils.CurrencyValueScaleException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForPremiumNameException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.PremiumNameBlockedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RegistrarMustBeActiveForThisOperationException;
|
||||
@@ -1065,6 +1067,30 @@ class DomainTransferRequestFlowTest
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testFailure_missingBillingAccount() {
|
||||
setupDomain("example", "tld");
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
.build());
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
MissingBillingAccountMapException.class,
|
||||
() ->
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_request.xml", "domain_transfer_request_response.xml"));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_superuserNotAuthorizedForTld() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
|
||||
Reference in New Issue
Block a user