Delete all Limited Release Program (LRP) code

We never used it and don't have any plans to use it going forward. All
conceivable parts of its functionality that we might use going forward have
already been subsumed into allocation tokens, which are a simpler way of
handling the same use case that are also standards-compliant.

Also gets rid of the hideous ANCHOR_ prefix on anchor tenant EPP authcodes
that was only ever necessary because of overloading the authcode for
anchor tenant creation. Going forward it'll be based on allocation tokens,
so there's no risk of conflicts.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209418194
This commit is contained in:
mcilwain 2018-08-20 08:03:41 -07:00 committed by jianglai
parent f7bc17fbe8
commit 7b87ba41c7
34 changed files with 12 additions and 1601 deletions

View file

@ -13,7 +13,6 @@ HistoryEntry
HostResource
KmsSecret
KmsSecretRevision
LrpTokenEntity
Modification
OneTime
PollMessage

View file

@ -11,7 +11,6 @@ HistoryEntry
HostResource
KmsSecret
KmsSecretRevision
LrpTokenEntity
Modification
OneTime
PremiumList

View file

@ -42,7 +42,6 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException;
import google.registry.flows.EppException.UnimplementedExtensionException;
import google.registry.flows.ResourceFlowTestCase;
@ -84,7 +83,6 @@ import google.registry.flows.domain.DomainFlowUtils.ExpiredClaimException;
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForPremiumNameException;
import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException;
import google.registry.flows.domain.DomainFlowUtils.InvalidLrpTokenException;
import google.registry.flows.domain.DomainFlowUtils.InvalidPunycodeException;
import google.registry.flows.domain.DomainFlowUtils.InvalidTcnIdChecksumException;
import google.registry.flows.domain.DomainFlowUtils.InvalidTrademarkValidatorException;
@ -112,7 +110,6 @@ import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeExcep
import google.registry.flows.domain.DomainFlowUtils.UnsupportedMarkTypeException;
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchPhase;
@ -130,7 +127,6 @@ import java.util.List;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.junit.Before;
import org.junit.Test;
@ -930,181 +926,6 @@ public class DomainApplicationCreateFlowTest
doSuccessfulTest("domain_create_landrush_response.xml", false, 2);
}
@Test
public void testSuccess_landrushLrpApplication() throws Exception {
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
doSuccessfulTest("domain_create_landrush_response.xml", false);
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
}
@Test
public void testSuccess_landrushLrpApplication_superuser() throws Exception {
// Using an LRP token as superuser should still mark the token as redeemed (i.e. same effect
// as non-superuser).
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
runSuperuserFlow("domain_create_landrush_response.xml");
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
}
@Test
public void testFailure_landrushLrpApplication_badToken() {
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest2")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
EppException thrown = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_landrushLrpApplication_tokenForWrongTld() {
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
// The below assignee doesn't really make sense here, but as of right now the validation
// in DomainPricingLogic is just a match on the domain name, so this test ensures that
// the registration fails due to invalid TLDs even if everything else otherwise matches.
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("other"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
EppException thrown = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_landrushLrpApplication_usedToken() {
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.setRedemptionHistoryEntry(
Key.create(HistoryEntry.class, "1")) // as long as it's not null
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
EppException thrown = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_landrushApplicationWithLrpToken_notInLrp() throws Exception {
createTld("tld", TldState.LANDRUSH);
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
// Application should continue as normal, since the LRP token will just be ignored
doSuccessfulTest("domain_create_landrush_response.xml", false);
// Token should not be marked as used, since this isn't an LRP state
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@Test
public void testSuccess_landrushApplicationWithLrpToken_noLongerLrp() throws Exception {
createTld("tld");
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1)))
.setTldStateTransitions(
ImmutableSortedMap.of(
START_OF_TIME, TldState.SUNRISE, clock.nowUtc(), TldState.LANDRUSH))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("test-validate.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
// Application should continue as normal, since the LRP token will just be ignored
doSuccessfulTest("domain_create_landrush_response.xml", false);
// Token should not be marked as used, since this isn't an LRP state
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@Test
public void testFailure_landrush_duringLrpWithMissingToken() {
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
setEppInput("domain_create_landrush.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
EppException thrown = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_landrushWithPeriodInMonths() {
createTld("tld", TldState.LANDRUSH);

View file

@ -101,7 +101,6 @@ import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredDuringEarlyAccessProgramException;
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForPremiumNameException;
import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException;
import google.registry.flows.domain.DomainFlowUtils.InvalidLrpTokenException;
import google.registry.flows.domain.DomainFlowUtils.InvalidPunycodeException;
import google.registry.flows.domain.DomainFlowUtils.InvalidTcnIdChecksumException;
import google.registry.flows.domain.DomainFlowUtils.InvalidTrademarkValidatorException;
@ -139,7 +138,6 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus;
@ -163,7 +161,6 @@ import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Interval;
import org.junit.Before;
import org.junit.Test;
@ -485,66 +482,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertNoLordn();
}
@Test
public void testSuccess_lrp() throws Exception {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("example.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
assertSuccessfulCreate("tld", ImmutableSet.of());
assertNoLordn();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
}
@Test
public void testSuccess_withLrpToken_outsideOfLrp() throws Exception {
// If a valid LRP token is passed in even though the TLD is not currently in an LRP phase,
// just ignore the token and proceed with normal GA registration (i.e. LRP token should
// remain unredeemed).
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1)))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("lrptokentest")
.setAssignee("example.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
assertSuccessfulCreate("tld", ImmutableSet.of());
assertNoLordn();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@Test
public void testSuccess_outsideOfLrp() throws Exception {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1)))
.build());
persistContactsAndHosts();
doSuccessfulTest();
}
@Test
public void testFailure_generalAvailability_withEncodedSignedMark() {
createTld("tld", GENERAL_AVAILABILITY);
@ -715,39 +652,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_lrp_badToken() {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder()
.setToken("otherlrptoken")
.setAssignee("example.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
Exception e = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertThat(e).hasMessageThat().isEqualTo("Invalid limited registration period token");
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@Test
public void testFailure_lrp_noToken() {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistContactsAndHosts();
InvalidLrpTokenException thrown = assertThrows(InvalidLrpTokenException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("Invalid limited registration period token");
}
@Test
public void testSuccess_premium() throws Exception {
createTld("example");
@ -1084,31 +988,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_anchorTenant_viaAuthCode_matchingLrpToken() throws Exception {
// This is definitely a corner case, as (without superuser) anchor tenants may only register
// via auth code during GA. We're running this as superuser to bypass the state checks, though
// anchor tenant code checks and LRP token redemption still happen regardless.
createTld("tld", TldState.LANDRUSH);
persistResource(
Registry.get("tld")
.asBuilder()
.setReservedLists(
persistReservedList("tld-reserved", "anchor,RESERVED_FOR_ANCHOR_TENANT"))
.build());
LrpTokenEntity token =
persistResource(
new LrpTokenEntity.Builder().setToken("2fooBAR").setAssignee("anchor.tld").build());
setEppInput("domain_create_anchor_authcode.xml");
persistContactsAndHosts();
runFlowAssertResponse(
CommitMode.LIVE, SUPERUSER, loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT));
// Token should not be marked as used, since interpreting the authcode as anchor tenant should
// take precedence.
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@Test
public void testSuccess_anchorTenant_viaAuthCode() throws Exception {
setEppInput("domain_create_anchor_authcode.xml");
@ -1132,36 +1011,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.isEqualTo(Key.create(getHistoryEntries(reloadResourceByForeignKey()).get(0)));
}
@Test
public void testSuccess_anchorTenant_viaAuthCode_duringLrp() throws Exception {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
setEppInput("domain_create_anchor_authcode.xml");
persistContactsAndHosts();
runFlowAssertResponse(loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT));
assertNoLordn();
}
@Test
public void testSuccess_anchorTenant_viaExtension_duringLrp() throws Exception {
persistResource(
Registry.get("tld")
.asBuilder()
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_create_anchor_tenant.xml");
persistContactsAndHosts();
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT));
assertNoLordn();
}
@Test
public void testSuccess_anchorTenant_viaAuthCode_withClaims() throws Exception {
persistResource(

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>test-validate.tld</domain:name>
<domain:ns>
<domain:hostObj>ns1.example.net</domain:hostObj>
<domain:hostObj>ns2.example.net</domain:hostObj>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:authInfo>
<domain:pw>lrptokentest</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<launch:create
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
<launch:phase>landrush</launch:phase>
</launch:create>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,22 +0,0 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:period unit="y">2</domain:period>
<domain:ns>
<domain:hostObj>ns1.example.net</domain:hostObj>
<domain:hostObj>ns2.example.net</domain:hostObj>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:authInfo>
<domain:pw>lrptokentest</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -1,89 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.model.domain;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.model.EntityTestCase;
import google.registry.model.reporting.HistoryEntry;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link LrpTokenEntity}. */
public class LrpTokenEntityTest extends EntityTestCase {
LrpTokenEntity unredeemedToken;
LrpTokenEntity redeemedToken;
@Before
public void setUp() {
createTld("tld");
DomainApplication lrpApplication = persistActiveDomainApplication("domain.tld");
HistoryEntry applicationCreateHistoryEntry = persistResource(new HistoryEntry.Builder()
.setParent(lrpApplication)
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
.build());
unredeemedToken = persistResource(
new LrpTokenEntity.Builder()
.setAssignee("1:1020304")
.setToken("a0b1c2d3e4f5g6")
.setValidTlds(ImmutableSet.of("tld"))
.setMetadata(ImmutableMap.of("foo", "bar"))
.build());
redeemedToken = persistResource(
new LrpTokenEntity.Builder()
.setAssignee("2:org.testdomain")
.setToken("h0i1j2k3l4m")
.setRedemptionHistoryEntry(Key.create(applicationCreateHistoryEntry))
.setValidTlds(ImmutableSet.of("tld"))
.setMetadata(ImmutableMap.of("bar", "foo"))
.build());
}
@Test
public void testPersistence() {
assertThat(ofy().load().entity(redeemedToken).now()).isEqualTo(redeemedToken);
}
@Test
public void testSuccess_loadByToken() {
assertThat(ofy().load().key(Key.create(LrpTokenEntity.class, "a0b1c2d3e4f5g6")).now())
.isEqualTo(unredeemedToken);
}
@Test
public void testSuccess_loadByAssignee() {
assertThat(
ofy().load().type(LrpTokenEntity.class).filter("assignee", "1:1020304").first().now())
.isEqualTo(unredeemedToken);
}
@Test
public void testSuccess_isRedeemed() {
assertThat(redeemedToken.isRedeemed()).isTrue();
assertThat(unredeemedToken.isRedeemed()).isFalse();
}
@Test
public void testIndexing() throws Exception {
verifyIndexing(redeemedToken, "assignee", "token");
}
}

View file

@ -243,14 +243,6 @@ class google.registry.model.domain.GracePeriod {
java.lang.String clientId;
org.joda.time.DateTime expirationTime;
}
class google.registry.model.domain.LrpTokenEntity {
@Id java.lang.String token;
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
google.registry.model.UpdateAutoTimestamp updateTimestamp;
java.lang.String assignee;
java.util.Map<java.lang.String, java.lang.String> metadata;
java.util.Set<java.lang.String> validTlds;
}
class google.registry.model.domain.Period {
google.registry.model.domain.Period$Unit unit;
java.lang.Integer value;
@ -663,8 +655,6 @@ class google.registry.model.registry.Registry {
org.joda.money.Money restoreBillingCost;
org.joda.money.Money serverStatusChangeBillingCost;
org.joda.time.DateTime claimsPeriodEnd;
org.joda.time.DateTime lrpPeriodEnd;
org.joda.time.DateTime lrpPeriodStart;
org.joda.time.Duration addGracePeriodLength;
org.joda.time.Duration anchorTenantAddGracePeriodLength;
org.joda.time.Duration autoRenewGracePeriodLength;

View file

@ -1,335 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import com.google.appengine.tools.remoteapi.RemoteApiException;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Files;
import com.googlecode.objectify.Key;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.DeterministicStringGenerator;
import google.registry.testing.DeterministicStringGenerator.Rule;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeSleeper;
import google.registry.util.Retrier;
import java.io.File;
import java.io.IOException;
import java.util.Set;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
/** Unit tests for {@link CreateLrpTokensCommand}. */
public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensCommand> {
DeterministicStringGenerator stringGenerator =
new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
File assigneeFile;
String assigneeFilePath;
@Before
public void init() throws IOException {
assigneeFile = tmpDir.newFile("lrp_assignees.txt");
assigneeFilePath = assigneeFile.getPath();
command.stringGenerator = stringGenerator;
command.retrier =
new Retrier(new FakeSleeper(new FakeClock(DateTime.parse("2000-01-01TZ"))), 3);
createTld("tld");
}
@Test
public void testSuccess_oneAssignee() throws Exception {
runCommand("--assignee=domain.tld", "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_retry() throws Exception {
CreateLrpTokensCommand spyCommand = spy(command);
RemoteApiException fakeException = new RemoteApiException("foo", "foo", "foo", new Exception());
doThrow(fakeException)
.doThrow(fakeException)
.doCallRealMethod()
.when(spyCommand)
.saveTokens(Mockito.any());
runCommand("--assignee=domain.tld", "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_withMetadata() throws Exception {
runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata=key=foo,key2=bar");
assertLrpTokens(
createToken(
"LRP_abcdefghijklmnop",
"domain.tld",
ImmutableSet.of("tld"),
null,
ImmutableMap.of("key", "foo", "key2", "bar")));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_tokenCollision() throws Exception {
LrpTokenEntity existingToken = persistResource(new LrpTokenEntity.Builder()
.setToken("LRP_abcdefghijklmnop")
.setAssignee("otherdomain.tld")
.setValidTlds(ImmutableSet.of("tld"))
.build());
runCommand("--assignee=domain.tld", "--tlds=tld");
assertLrpTokens(
existingToken,
createToken("LRP_qrstuvwxyzabcdef", "domain.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain.tld,LRP_qrstuvwxyzabcdef");
}
@Test
public void testSuccess_oneAssignee_byFile() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld");
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_byFile_withMetadata() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo,bar");
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
assertLrpTokens(
createToken(
"LRP_abcdefghijklmnop",
"domain.tld",
ImmutableSet.of("tld"),
null,
ImmutableMap.of("key", "foo", "key2", "bar")));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_byFile_withMetadata_quotedString() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,\"foo,foo\",bar");
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
assertLrpTokens(
createToken(
"LRP_abcdefghijklmnop",
"domain.tld",
ImmutableSet.of("tld"),
null,
ImmutableMap.of("key", "foo,foo", "key2", "bar")));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_oneAssignee_byFile_withMetadata_twoQuotedStrings() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,\"foo,foo\",\"bar,bar\"");
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
assertLrpTokens(
createToken(
"LRP_abcdefghijklmnop",
"domain.tld",
ImmutableSet.of("tld"),
null,
ImmutableMap.of("key", "foo,foo", "key2", "bar,bar")));
assertInStdout("domain.tld,LRP_abcdefghijklmnop");
}
@Test
public void testSuccess_emptyFile() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("");
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
assertLrpTokens(); // no tokens exist
assertThat(getStdoutAsString()).isEmpty();
}
@Test
public void testSuccess_multipleAssignees_byFile() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain1.tld\ndomain2.tld\ndomain3.tld");
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain1.tld", ImmutableSet.of("tld"), null, null),
createToken("LRP_qrstuvwxyzabcdef", "domain2.tld", ImmutableSet.of("tld"), null, null),
createToken("LRP_ghijklmnopqrstuv", "domain3.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain1.tld,LRP_abcdefghijklmnop");
assertInStdout("domain2.tld,LRP_qrstuvwxyzabcdef");
assertInStdout("domain3.tld,LRP_ghijklmnopqrstuv");
}
@Test
public void testSuccess_multipleAssignees_byFile_ignoreBlankLine() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain1.tld\n\ndomain2.tld");
runCommand("--input=" + assigneeFilePath, "--tlds=tld");
assertLrpTokens(
createToken("LRP_abcdefghijklmnop", "domain1.tld", ImmutableSet.of("tld"), null, null),
// Second deterministic token (LRP_qrstuvwxyzabcdef) still consumed but not assigned
createToken("LRP_ghijklmnopqrstuv", "domain2.tld", ImmutableSet.of("tld"), null, null));
assertInStdout("domain1.tld,LRP_abcdefghijklmnop");
assertInStdout("domain2.tld,LRP_ghijklmnopqrstuv");
}
@Test
public void testSuccess_largeFile_withMetadata() throws Exception {
int numberOfTokens = 67;
LrpTokenEntity[] expectedTokens = new LrpTokenEntity[numberOfTokens];
// Prepend a counter to avoid collisions, 16-char alphabet will always generate the same string.
stringGenerator =
new DeterministicStringGenerator("abcdefghijklmnop", Rule.PREPEND_COUNTER);
command.stringGenerator = stringGenerator;
StringBuilder assigneeFileBuilder = new StringBuilder();
for (int i = 0; i < numberOfTokens; i++) {
assigneeFileBuilder.append(String.format("domain%d.tld,%d,%d\n", i, i * 2, i * 3));
expectedTokens[i] =
createToken(
String.format("LRP_%04d_abcdefghijklmnop", i),
String.format("domain%d.tld", i),
ImmutableSet.of("tld"),
null,
ImmutableMap.of("key", Integer.toString(i * 2), "key2", Integer.toString(i * 3)));
}
Files.asCharSink(assigneeFile, UTF_8).write(assigneeFileBuilder);
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
assertLrpTokens(expectedTokens);
for (int i = 0; i < numberOfTokens; i++) {
assertInStdout(String.format("domain%d.tld,LRP_%04d_abcdefghijklmnop", i, i));
}
}
@Test
public void testFailure_missingAssigneeOrFile() {
IllegalArgumentException thrown =
assertThrows(IllegalArgumentException.class, () -> runCommand("--tlds=tld"));
assertThat(thrown)
.hasMessageThat()
.contains("Exactly one of either assignee or filename must be specified.");
}
@Test
public void testFailure_bothAssigneeAndFile() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath));
assertThat(thrown)
.hasMessageThat()
.contains("Exactly one of either assignee or filename must be specified.");
}
@Test
public void testFailure_bothMetadataAndFile() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo"));
assertThat(thrown)
.hasMessageThat()
.contains("Metadata cannot be specified along with a filename.");
}
@Test
public void testFailure_bothAssigneeAndMetadataColumns() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1"));
assertThat(thrown)
.hasMessageThat()
.contains("Metadata columns cannot be specified along with an assignee.");
}
@Test
public void testFailure_badTld() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> runCommand("--assignee=domain.tld", "--tlds=foo"));
assertThat(thrown).hasMessageThat().contains("TLDs do not exist: foo");
}
@Test
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo");
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() ->
runCommand(
"--input=" + assigneeFilePath,
"--tlds=tld",
"--metadata_columns=key=1,key2=2"));
assertThat(thrown)
.hasMessageThat()
.contains("Entry for domain.tld does not have a value for key2 (index 2)");
}
private void assertLrpTokens(LrpTokenEntity... expected) {
// Using ImmutableObject comparison here is tricky because updateTimestamp is not set on the
// expected LrpToken objects and will cause the assert to fail.
Iterable<LrpTokenEntity> actual = ofy().load().type(LrpTokenEntity.class);
ImmutableMap.Builder<String, LrpTokenEntity> actualTokenMapBuilder =
new ImmutableMap.Builder<>();
for (LrpTokenEntity token : actual) {
actualTokenMapBuilder.put(token.getToken(), token);
}
ImmutableMap<String, LrpTokenEntity> actualTokenMap = actualTokenMapBuilder.build();
assertThat(actualTokenMap).hasSize(expected.length);
for (LrpTokenEntity expectedToken : expected) {
LrpTokenEntity match = actualTokenMap.get(expectedToken.getToken());
assertThat(match).isNotNull();
assertThat(match.getAssignee()).isEqualTo(expectedToken.getAssignee());
assertThat(match.getValidTlds()).containsExactlyElementsIn(expectedToken.getValidTlds());
assertThat(match.getRedemptionHistoryEntry())
.isEqualTo(expectedToken.getRedemptionHistoryEntry());
assertThat(match.getMetadata()).containsExactlyEntriesIn(expectedToken.getMetadata());
}
}
private LrpTokenEntity createToken(
String token,
String assignee,
Set<String> validTlds,
@Nullable Key<HistoryEntry> redemptionHistoryEntry,
@Nullable ImmutableMap<String, String> metadata) {
LrpTokenEntity.Builder tokenBuilder = new LrpTokenEntity.Builder()
.setAssignee(assignee)
.setValidTlds(validTlds)
.setToken(token);
if (redemptionHistoryEntry != null) {
tokenBuilder.setRedemptionHistoryEntry(redemptionHistoryEntry);
}
if (metadata != null) {
tokenBuilder.setMetadata(metadata);
}
return tokenBuilder.build();
}
}

View file

@ -39,7 +39,6 @@ import java.math.BigDecimal;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Interval;
import org.junit.Before;
import org.junit.Test;
@ -287,18 +286,6 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
.containsExactly("xn--q9jyb4c_abuse", "common_abuse");
}
@Test
public void testSuccess_addLrpPeriod() throws Exception {
runCommandForced(
"--lrp_period=2004-06-09T12:30:00Z/2004-07-10T13:30:00Z",
"--roid_suffix=Q9JYB4C",
"--dns_writers=VoidDnsWriter",
"xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod()).isEqualTo(
new Interval(
DateTime.parse("2004-06-09T12:30:00Z"), DateTime.parse("2004-07-10T13:30:00Z")));
}
@Test
public void testSuccess_setPremiumPriceAckRequired() throws Exception {
runCommandForced(
@ -611,37 +598,6 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist");
}
@Test
public void testFailure_addLrpPeriod_backwardsInterval() {
ParameterException thrown =
assertThrows(
ParameterException.class,
() ->
runCommandForced(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z",
"--roid_suffix=Q9JYB4C",
"--dns_writers=VoidDnsWriter",
"xn--q9jyb4c"));
assertThat(thrown)
.hasMessageThat()
.contains(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
}
@Test
public void testFailure_addLrpPeriod_badInterval() {
ParameterException thrown =
assertThrows(
ParameterException.class,
() ->
runCommandForced(
"--lrp_period=foobar",
"--roid_suffix=Q9JYB4C",
"--dns_writers=VoidDnsWriter",
"xn--q9jyb4c"));
assertThat(thrown).hasMessageThat().contains("--lrp_period=foobar not an ISO-8601 interval");
}
@Test
public void testFailure_specifiedDnsWriters_dontExist() {
IllegalArgumentException thrown =

View file

@ -1,90 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.reporting.HistoryEntry;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetLrpTokenCommand}. */
public class GetLrpTokenCommandTest extends CommandTestCase<GetLrpTokenCommand> {
@Before
public void before() {
createTld("tld");
DomainApplication lrpApplication = persistActiveDomainApplication("domain.tld");
HistoryEntry applicationCreateHistoryEntry = persistResource(new HistoryEntry.Builder()
.setParent(lrpApplication)
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
.build());
persistResource(
new LrpTokenEntity.Builder()
.setAssignee("domain.tld")
.setToken("domain_token")
.setRedemptionHistoryEntry(Key.create(applicationCreateHistoryEntry))
.build());
}
@Test
public void testSuccess_byAssignee() throws Exception {
runCommand("--assignee=domain.tld");
assertInStdout("domain_token");
}
@Test
public void testSuccess_byToken() throws Exception {
runCommand("--token=domain_token");
assertInStdout("domain.tld");
assertNotInStdout("fullyQualifiedDomainName=domain.tld"); // history param should be false
}
@Test
public void testSuccess_iosByToken_withHistory() throws Exception {
runCommand("--token=domain_token", "--history");
assertInStdout("domain.tld");
assertInStdout("fullyQualifiedDomainName=domain.tld");
assertInStdout("type=DOMAIN_APPLICATION_CREATE");
}
@Test
public void testSuccess_unknownAssignee() throws Exception {
runCommand("--assignee=nobody");
assertInStdout("Token not found");
}
@Test
public void testSuccess_unknownToken() throws Exception {
runCommand("--token=bogus_token");
assertInStdout("Token not found");
}
@Test
public void testFailure_noArgs() {
IllegalArgumentException thrown =
assertThrows(IllegalArgumentException.class, this::runCommand);
assertThat(thrown)
.hasMessageThat()
.contains("Exactly one of either token or assignee must be specified.");
}
}

View file

@ -41,7 +41,6 @@ import java.io.PrintStream;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.Interval;
import org.junit.Before;
import org.junit.Test;
@ -450,18 +449,6 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
assertThat(Registry.get("xn--q9jyb4c").getDomainCreateRestricted()).isTrue();
}
@Test
public void testSuccess_removeLrpPeriod() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setLrpPeriod(new Interval(
DateTime.parse("2004-06-09T12:30:00Z"), DateTime.parse("2004-07-10T13:30:00Z")))
.build());
runCommandForced("--lrp_period=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod())
.isEqualTo(new Interval(START_OF_TIME, Duration.ZERO));
}
@Test
public void testFailure_invalidAddGracePeriod() {
IllegalArgumentException thrown =
@ -1009,36 +996,6 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist");
}
@Test
public void testSuccess_updateLrpPeriod() throws Exception {
runCommandForced("--lrp_period=2004-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod()).isEqualTo(
new Interval(
DateTime.parse("2004-06-09T12:30:00Z"), DateTime.parse("2004-07-10T13:30:00Z")));
}
@Test
public void testFailure_updateLrpPeriod_backwardsInterval() {
ParameterException thrown =
assertThrows(
ParameterException.class,
() ->
runCommandForced(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c"));
assertThat(thrown)
.hasMessageThat()
.contains(
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
}
@Test
public void testFailure_updateLrpPeriod_badInterval() {
ParameterException thrown =
assertThrows(
ParameterException.class, () -> runCommandForced("--lrp_period=foobar", "xn--q9jyb4c"));
assertThat(thrown).hasMessageThat().contains("--lrp_period=foobar not an ISO-8601 interval");
}
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
}

View file

@ -9,7 +9,7 @@
<domain:contact type="admin">jd1234</domain:contact>
<domain:contact type="tech">jd1234</domain:contact>
<domain:authInfo>
<domain:pw>ANCHOR_abcdefghijklmnop</domain:pw>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>

View file

@ -9,7 +9,7 @@
<domain:contact type="admin">jd1234</domain:contact>
<domain:contact type="tech">jd1234</domain:contact>
<domain:authInfo>
<domain:pw>ANCHOR_abcdefghijklmnop</domain:pw>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>

View file

@ -9,7 +9,7 @@
<domain:contact type="admin">jd1234</domain:contact>
<domain:contact type="tech">jd1234</domain:contact>
<domain:authInfo>
<domain:pw>ANCHOR_abcdefghijklmnop</domain:pw>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>

View file

@ -9,7 +9,7 @@
<domain:contact type="admin">jd1234</domain:contact>
<domain:contact type="tech">jd1234</domain:contact>
<domain:authInfo>
<domain:pw>ANCHOR_abcdefghijklmnop</domain:pw>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>

View file

@ -9,7 +9,7 @@
<domain:contact type="admin">jd1234</domain:contact>
<domain:contact type="tech">jd1234</domain:contact>
<domain:authInfo>
<domain:pw>ANCHOR_abcdefghijklmnop</domain:pw>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>