mirror of
https://github.com/google/nomulus.git
synced 2025-05-21 19:59:34 +02:00
Add valid TLD check to LrpToken validation
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131438274
This commit is contained in:
parent
1b3f77a468
commit
942dc58251
3 changed files with 32 additions and 4 deletions
|
@ -192,7 +192,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
||||||
&& !command.getAuthInfo().getPw().getValue().isEmpty()
|
&& !command.getAuthInfo().getPw().getValue().isEmpty()
|
||||||
&& !isAnchorTenantViaReservation;
|
&& !isAnchorTenantViaReservation;
|
||||||
lrpToken = isLrpApplication
|
lrpToken = isLrpApplication
|
||||||
? TldSpecificLogicProxy.getMatchingLrpToken(command)
|
? TldSpecificLogicProxy.getMatchingLrpToken(command, tld)
|
||||||
: Optional.<LrpToken>absent();
|
: Optional.<LrpToken>absent();
|
||||||
// Superusers can create reserved domains, force creations on domains that require a claims
|
// Superusers can create reserved domains, force creations on domains that require a claims
|
||||||
// notice without specifying a claims key, and override blocks on registering premium domains.
|
// notice without specifying a claims key, and override blocks on registering premium domains.
|
||||||
|
|
|
@ -159,14 +159,15 @@ public final class TldSpecificLogicProxy {
|
||||||
* token) has already been checked against the reserved list for QLP (anchor tenant), as auth
|
* token) has already been checked against the reserved list for QLP (anchor tenant), as auth
|
||||||
* codes are used for both types of registrations.
|
* codes are used for both types of registrations.
|
||||||
*/
|
*/
|
||||||
public static Optional<LrpToken> getMatchingLrpToken(Create createCommand) {
|
public static Optional<LrpToken> getMatchingLrpToken(Create createCommand, String tld) {
|
||||||
// Note that until the actual per-TLD logic is built out, what's being done here is a basic
|
// Note that until the actual per-TLD logic is built out, what's being done here is a basic
|
||||||
// domain-name-to-assignee match.
|
// domain-name-to-assignee match.
|
||||||
String lrpToken = createCommand.getAuthInfo().getPw().getValue();
|
String lrpToken = createCommand.getAuthInfo().getPw().getValue();
|
||||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, lrpToken)).now();
|
LrpToken token = ofy().load().key(Key.create(LrpToken.class, lrpToken)).now();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
if (token.getAssignee().equalsIgnoreCase(createCommand.getFullyQualifiedDomainName())
|
if (token.getAssignee().equalsIgnoreCase(createCommand.getFullyQualifiedDomainName())
|
||||||
&& token.getRedemptionHistoryEntry() == null) {
|
&& token.getRedemptionHistoryEntry() == null
|
||||||
|
&& token.getValidTlds().contains(tld)) {
|
||||||
return Optional.of(token);
|
return Optional.of(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -879,6 +879,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpToken token = persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
|
@ -910,6 +911,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpToken token = persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
|
@ -920,7 +922,6 @@ public class DomainApplicationCreateFlowTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_landrushLrpApplication_badToken() throws Exception {
|
public void testFailure_landrushLrpApplication_badToken() throws Exception {
|
||||||
thrown.expect(BadAuthInfoForResourceException.class);
|
|
||||||
createTld("tld", TldState.LANDRUSH);
|
createTld("tld", TldState.LANDRUSH);
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
|
@ -928,10 +929,33 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(new LrpToken.Builder()
|
persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest2")
|
.setToken("lrptokentest2")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
thrown.expect(BadAuthInfoForResourceException.class);
|
||||||
|
runFlow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_landrushLrpApplication_tokenForWrongTld() throws Exception {
|
||||||
|
createTld("tld", TldState.LANDRUSH);
|
||||||
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
|
.build());
|
||||||
|
persistResource(new LrpToken.Builder()
|
||||||
|
.setToken("lrptokentest")
|
||||||
|
// The below assignee doesn't really make sense here, but as of right now the validation
|
||||||
|
// in TldSpecificLogicProxy 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();
|
||||||
|
thrown.expect(BadAuthInfoForResourceException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,6 +969,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(new LrpToken.Builder()
|
persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, "1")) // as long as it's not null
|
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, "1")) // as long as it's not null
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
|
@ -959,6 +984,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpToken token = persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
|
@ -981,6 +1007,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpToken token = persistResource(new LrpToken.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.build());
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue