mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Temporarily add null handling for autorenew billing events
These shouldn't ever be null, but we have some bad data in production for prober TLDs left over from the Registry 2.0 transition. Ignoring null values here is required to finish cleanup for this old data, which currently cannot even be deleted because it's throwing an NPE when trying to update these values. This commit will be reverted after the bad data is cleaned up, likely sometime next week. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158546840
This commit is contained in:
parent
7002026da5
commit
f5f383dc38
2 changed files with 30 additions and 3 deletions
|
@ -36,6 +36,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
|
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
|
||||||
|
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -63,6 +64,7 @@ import google.registry.model.EppResource;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.billing.BillingEvent.Flag;
|
import google.registry.model.billing.BillingEvent.Flag;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
|
import google.registry.model.billing.BillingEvent.Recurring;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DesignatedContact;
|
import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DesignatedContact.Type;
|
import google.registry.model.domain.DesignatedContact.Type;
|
||||||
|
@ -104,6 +106,7 @@ import google.registry.model.registry.label.ReservationType;
|
||||||
import google.registry.model.registry.label.ReservedList;
|
import google.registry.model.registry.label.ReservedList;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.model.tmch.ClaimsListShard;
|
import google.registry.model.tmch.ClaimsListShard;
|
||||||
|
import google.registry.util.FormattingLogger;
|
||||||
import google.registry.util.Idn;
|
import google.registry.util.Idn;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -118,6 +121,8 @@ import org.joda.time.DateTime;
|
||||||
/** Static utility functions for domain flows. */
|
/** Static utility functions for domain flows. */
|
||||||
public class DomainFlowUtils {
|
public class DomainFlowUtils {
|
||||||
|
|
||||||
|
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||||
|
|
||||||
/** Map from launch phases to the equivalent tld states. */
|
/** Map from launch phases to the equivalent tld states. */
|
||||||
private static final ImmutableMap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATE =
|
private static final ImmutableMap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATE =
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
|
@ -506,9 +511,17 @@ public class DomainFlowUtils {
|
||||||
ofy().save().entity(updatedAutorenewPollMessage);
|
ofy().save().entity(updatedAutorenewPollMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ofy().save().entity(ofy().load().key(domain.getAutorenewBillingEvent()).now().asBuilder()
|
Recurring recurring = ofy().load().key(domain.getAutorenewBillingEvent()).now();
|
||||||
.setRecurrenceEndTime(newEndTime)
|
// TODO(b/27472322): Revert handling of recurring being null once bad data is cleaned from prod.
|
||||||
.build());
|
// It shouldn't ever actually be null, and we only have some null data left because of issues
|
||||||
|
// dating back to the Registry 2.0 migration.
|
||||||
|
if (recurring == null) {
|
||||||
|
logger.warningfmt(
|
||||||
|
"Domain name %s has null autorenew billing event; ignoring. Domain key: %s.",
|
||||||
|
domain.getFullyQualifiedDomainName(), Key.create(domain));
|
||||||
|
} else {
|
||||||
|
ofy().save().entity(recurring.asBuilder().setRecurrenceEndTime(newEndTime).build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -492,6 +492,20 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
assertThat(domain.getTransferData()).isEqualTo(TransferData.EMPTY);
|
assertThat(domain.getTransferData()).isEqualTo(TransferData.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO(b/27472322): Delete test handling recurring being null once bad data is cleaned from prod.
|
||||||
|
@Test
|
||||||
|
public void testSuccess_nullAutorenewBillingEvent_isIgnore() throws Exception {
|
||||||
|
setClientIdForFlow("TheRegistrar");
|
||||||
|
setupSuccessfulTest();
|
||||||
|
ofy().deleteWithoutBackup().key(domain.getAutorenewBillingEvent()).now();
|
||||||
|
ofy().clearSessionCache();
|
||||||
|
clock.advanceOneMilli();
|
||||||
|
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
|
||||||
|
// If the previous statement doesn't throw an error, then the test is successful.
|
||||||
|
assertThat(ofy().load().key(reloadResourceByForeignKey().getAutorenewBillingEvent()).now())
|
||||||
|
.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_pendingTransfer() throws Exception {
|
public void testSuccess_pendingTransfer() throws Exception {
|
||||||
setClientIdForFlow("TheRegistrar");
|
setClientIdForFlow("TheRegistrar");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue