mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Fix missing LRP token during LRP period behavior
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137321673
This commit is contained in:
parent
1ac0832c79
commit
21c0b43af0
4 changed files with 23 additions and 29 deletions
|
@ -239,13 +239,10 @@ public final class DomainApplicationCreateFlow extends LoggedInFlow implements T
|
||||||
DomainApplicationIndex.createUpdatedInstance(newApplication),
|
DomainApplicationIndex.createUpdatedInstance(newApplication),
|
||||||
EppResourceIndex.create(Key.create(newApplication)));
|
EppResourceIndex.create(Key.create(newApplication)));
|
||||||
// Anchor tenant registrations override LRP, and landrush applications can skip it.
|
// Anchor tenant registrations override LRP, and landrush applications can skip it.
|
||||||
|
// If a token is passed in outside of an LRP phase, it is simply ignored (i.e. never redeemed).
|
||||||
if (registry.getLrpPeriod().contains(now) && !isAnchorTenant) {
|
if (registry.getLrpPeriod().contains(now) && !isAnchorTenant) {
|
||||||
// TODO(b/32059212): This is a bug: empty tokens should still fail. Preserving to fix in a
|
entitiesToSave.add(
|
||||||
// separate targeted change.
|
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
||||||
if (!authInfo.getPw().getValue().isEmpty()) {
|
|
||||||
entitiesToSave.add(
|
|
||||||
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ofy().save().entities(entitiesToSave.build());
|
ofy().save().entities(entitiesToSave.build());
|
||||||
return createOutput(
|
return createOutput(
|
||||||
|
|
|
@ -267,15 +267,12 @@ public class DomainCreateFlow extends LoggedInFlow implements TransactionalFlow
|
||||||
newDomain,
|
newDomain,
|
||||||
ForeignKeyIndex.create(newDomain, newDomain.getDeletionTime()),
|
ForeignKeyIndex.create(newDomain, newDomain.getDeletionTime()),
|
||||||
EppResourceIndex.create(Key.create(newDomain)));
|
EppResourceIndex.create(Key.create(newDomain)));
|
||||||
|
|
||||||
// Anchor tenant registrations override LRP, and landrush applications can skip it.
|
// Anchor tenant registrations override LRP, and landrush applications can skip it.
|
||||||
// If a token is passed in outside of an LRP phase, it is simply ignored (i.e. never redeemed).
|
// If a token is passed in outside of an LRP phase, it is simply ignored (i.e. never redeemed).
|
||||||
if (hasLrpToken(registry, isAnchorTenant)) {
|
if (isLrpCreate(registry, isAnchorTenant)) {
|
||||||
// TODO(b/32059212): This is a bug: empty tokens should still fail. Preserving to fix in a
|
entitiesToSave.add(
|
||||||
// separate targeted change.
|
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
||||||
if (!authInfo.getPw().getValue().isEmpty()) {
|
|
||||||
entitiesToSave.add(
|
|
||||||
prepareMarkedLrpTokenEntity(authInfo.getPw().getValue(), domainName, historyEntry));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
enqueueTasks(hasSignedMarks, hasClaimsNotice, newDomain);
|
enqueueTasks(hasSignedMarks, hasClaimsNotice, newDomain);
|
||||||
ofy().save().entities(entitiesToSave.build());
|
ofy().save().entities(entitiesToSave.build());
|
||||||
|
@ -386,7 +383,7 @@ public class DomainCreateFlow extends LoggedInFlow implements TransactionalFlow
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasLrpToken(Registry registry, boolean isAnchorTenant) {
|
private boolean isLrpCreate(Registry registry, boolean isAnchorTenant) {
|
||||||
return registry.getLrpPeriod().contains(now) && !isAnchorTenant;
|
return registry.getLrpPeriod().contains(now) && !isAnchorTenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,12 +278,11 @@ public final class TldSpecificLogicProxy {
|
||||||
// domain-name-to-assignee match.
|
// domain-name-to-assignee match.
|
||||||
if (!lrpToken.isEmpty()) {
|
if (!lrpToken.isEmpty()) {
|
||||||
LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.class, lrpToken)).now();
|
LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.class, lrpToken)).now();
|
||||||
if (token != null) {
|
if (token != null
|
||||||
if (token.getAssignee().equalsIgnoreCase(domainName.toString())
|
&& token.getAssignee().equalsIgnoreCase(domainName.toString())
|
||||||
&& token.getRedemptionHistoryEntry() == null
|
&& token.getRedemptionHistoryEntry() == null
|
||||||
&& token.getValidTlds().contains(domainName.parent().toString())) {
|
&& token.getValidTlds().contains(domainName.parent().toString())) {
|
||||||
return Optional.of(token);
|
return Optional.of(token);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.<LrpTokenEntity>absent();
|
return Optional.<LrpTokenEntity>absent();
|
||||||
|
|
|
@ -893,18 +893,6 @@ public class DomainApplicationCreateFlowTest
|
||||||
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
|
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSuccess_landrush_duringLrpWithMissingToken() throws Exception {
|
|
||||||
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();
|
|
||||||
doSuccessfulTest("domain_create_landrush_response.xml", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_landrushLrpApplication_superuser() throws Exception {
|
public void testSuccess_landrushLrpApplication_superuser() throws Exception {
|
||||||
// Using an LRP token as superuser should still mark the token as redeemed (i.e. same effect
|
// Using an LRP token as superuser should still mark the token as redeemed (i.e. same effect
|
||||||
|
@ -1028,6 +1016,19 @@ public class DomainApplicationCreateFlowTest
|
||||||
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
|
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_landrush_duringLrpWithMissingToken() throws Exception {
|
||||||
|
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();
|
||||||
|
thrown.expect(InvalidLrpTokenException.class);
|
||||||
|
runFlow();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_landrushWithPeriodInMonths() throws Exception {
|
public void testFailure_landrushWithPeriodInMonths() throws Exception {
|
||||||
createTld("tld", TldState.LANDRUSH);
|
createTld("tld", TldState.LANDRUSH);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue