mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Rename LrpToken to LrpTokenEntity
This is to better distinguish between an LRP "token" (the string passed along in EPP) and the datastore entity that contains the token and all metadata. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135943480
This commit is contained in:
parent
1a9f91ed9e
commit
dd9137fbd1
14 changed files with 104 additions and 97 deletions
|
@ -34,7 +34,7 @@ import google.registry.model.billing.RegistrarCredit;
|
||||||
import google.registry.model.billing.RegistrarCreditBalance;
|
import google.registry.model.billing.RegistrarCreditBalance;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.index.DomainApplicationIndex;
|
import google.registry.model.index.DomainApplicationIndex;
|
||||||
import google.registry.model.index.EppResourceIndex;
|
import google.registry.model.index.EppResourceIndex;
|
||||||
|
@ -53,7 +53,7 @@ public final class ExportConstants {
|
||||||
|
|
||||||
/** Set of entity classes to export into BigQuery for reporting purposes. */
|
/** Set of entity classes to export into BigQuery for reporting purposes. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@SuppressWarnings("unchecked") // varargs
|
@SuppressWarnings("unchecked") // varargs
|
||||||
static final ImmutableSet<Class<? extends ImmutableObject>> REPORTING_ENTITY_CLASSES =
|
static final ImmutableSet<Class<? extends ImmutableObject>> REPORTING_ENTITY_CLASSES =
|
||||||
ImmutableSet.of(
|
ImmutableSet.of(
|
||||||
Cancellation.class,
|
Cancellation.class,
|
||||||
|
@ -66,7 +66,7 @@ public final class ExportConstants {
|
||||||
ForeignKeyHostIndex.class,
|
ForeignKeyHostIndex.class,
|
||||||
HistoryEntry.class,
|
HistoryEntry.class,
|
||||||
HostResource.class,
|
HostResource.class,
|
||||||
LrpToken.class,
|
LrpTokenEntity.class,
|
||||||
Modification.class,
|
Modification.class,
|
||||||
OneTime.class,
|
OneTime.class,
|
||||||
PremiumList.class,
|
PremiumList.class,
|
||||||
|
|
|
@ -57,7 +57,7 @@ import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.domain.DomainBase.Builder;
|
import google.registry.model.domain.DomainBase.Builder;
|
||||||
import google.registry.model.domain.DomainCommand.Create;
|
import google.registry.model.domain.DomainCommand.Create;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||||
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
|
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
|
||||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||||
|
@ -94,7 +94,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
||||||
protected SignedMark signedMark;
|
protected SignedMark signedMark;
|
||||||
protected boolean isAnchorTenantViaReservation;
|
protected boolean isAnchorTenantViaReservation;
|
||||||
protected TldState tldState;
|
protected TldState tldState;
|
||||||
protected Optional<LrpToken> lrpToken;
|
protected Optional<LrpTokenEntity> lrpToken;
|
||||||
|
|
||||||
protected Optional<RegistryExtraFlowLogic> extraFlowLogic;
|
protected Optional<RegistryExtraFlowLogic> extraFlowLogic;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
||||||
&& !isAnchorTenantViaReservation;
|
&& !isAnchorTenantViaReservation;
|
||||||
lrpToken = isLrpApplication
|
lrpToken = isLrpApplication
|
||||||
? TldSpecificLogicProxy.getMatchingLrpToken(command, tld)
|
? TldSpecificLogicProxy.getMatchingLrpToken(command, tld)
|
||||||
: Optional.<LrpToken>absent();
|
: Optional.<LrpTokenEntity>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.
|
||||||
if (!isSuperuser) {
|
if (!isSuperuser) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.domain.DomainCommand.Create;
|
import google.registry.model.domain.DomainCommand.Create;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.domain.fee.BaseFee;
|
import google.registry.model.domain.fee.BaseFee;
|
||||||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
import google.registry.model.domain.fee.BaseFee.FeeType;
|
||||||
import google.registry.model.domain.fee.Credit;
|
import google.registry.model.domain.fee.Credit;
|
||||||
|
@ -266,18 +266,18 @@ public final class TldSpecificLogicProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a {@link Create} command has a valid {@link LrpToken} for a particular TLD, and
|
* Checks whether a {@link Create} command has a valid {@link LrpTokenEntity} for a particular
|
||||||
* return that token (wrapped in an {@link Optional}) if one exists.
|
* TLD, and return that token (wrapped in an {@link Optional}) if one exists.
|
||||||
*
|
*
|
||||||
* <p>This method has no knowledge of whether or not an auth code (interpreted here as an LRP
|
* <p>This method has no knowledge of whether or not an auth code (interpreted here as an LRP
|
||||||
* 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, String tld) {
|
public static Optional<LrpTokenEntity> 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();
|
LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.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
|
||||||
|
@ -285,6 +285,6 @@ public final class TldSpecificLogicProxy {
|
||||||
return Optional.of(token);
|
return Optional.of(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.<LrpToken>absent();
|
return Optional.<LrpTokenEntity>absent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.export.LogsExportCursor;
|
import google.registry.model.export.LogsExportCursor;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.index.DomainApplicationIndex;
|
import google.registry.model.index.DomainApplicationIndex;
|
||||||
|
@ -60,7 +60,7 @@ import google.registry.model.tmch.TmchCrl;
|
||||||
public final class EntityClasses {
|
public final class EntityClasses {
|
||||||
|
|
||||||
/** Set of entity classes. */
|
/** Set of entity classes. */
|
||||||
@SuppressWarnings("unchecked") // varargs
|
@SuppressWarnings("unchecked") // varargs
|
||||||
public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES =
|
public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES =
|
||||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||||
BillingEvent.Cancellation.class,
|
BillingEvent.Cancellation.class,
|
||||||
|
@ -92,7 +92,7 @@ public final class EntityClasses {
|
||||||
HostResource.class,
|
HostResource.class,
|
||||||
Lock.class,
|
Lock.class,
|
||||||
LogsExportCursor.class,
|
LogsExportCursor.class,
|
||||||
LrpToken.class,
|
LrpTokenEntity.class,
|
||||||
PollMessage.class,
|
PollMessage.class,
|
||||||
PollMessage.Autorenew.class,
|
PollMessage.Autorenew.class,
|
||||||
PollMessage.OneTime.class,
|
PollMessage.OneTime.class,
|
||||||
|
|
|
@ -28,11 +28,9 @@ import google.registry.model.reporting.HistoryEntry;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/** An entity representing a token distributed to eligible LRP registrants. */
|
||||||
* An entity representing a token distributed to eligible LRP registrants.
|
|
||||||
*/
|
|
||||||
@Entity
|
@Entity
|
||||||
public class LrpToken extends BackupGroupRoot implements Buildable {
|
public class LrpTokenEntity extends BackupGroupRoot implements Buildable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The secret token assigned to a registrant for the purposes of LRP registration.
|
* The secret token assigned to a registrant for the purposes of LRP registration.
|
||||||
|
@ -94,11 +92,11 @@ public class LrpToken extends BackupGroupRoot implements Buildable {
|
||||||
return new Builder(clone(this));
|
return new Builder(clone(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A builder for constructing {@link LrpToken} objects, since they are immutable. */
|
/** A builder for constructing {@link LrpTokenEntity} objects, since they are immutable. */
|
||||||
public static class Builder extends Buildable.Builder<LrpToken> {
|
public static class Builder extends Buildable.Builder<LrpTokenEntity> {
|
||||||
public Builder() {}
|
public Builder() {}
|
||||||
|
|
||||||
private Builder(LrpToken instance) {
|
private Builder(LrpTokenEntity instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.google.common.io.Files;
|
||||||
import com.google.common.io.LineReader;
|
import com.google.common.io.LineReader;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Work;
|
import com.googlecode.objectify.Work;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.tools.Command.RemoteApiCommand;
|
import google.registry.tools.Command.RemoteApiCommand;
|
||||||
import google.registry.tools.params.PathParameter;
|
import google.registry.tools.params.PathParameter;
|
||||||
import google.registry.util.StringGenerator;
|
import google.registry.util.StringGenerator;
|
||||||
|
@ -92,11 +92,11 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
||||||
|
|
||||||
String line = null;
|
String line = null;
|
||||||
do {
|
do {
|
||||||
ImmutableSet.Builder<LrpToken> tokensToSave = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<LrpTokenEntity> tokensToSave = new ImmutableSet.Builder<>();
|
||||||
for (String token : generateTokens(BATCH_SIZE)) {
|
for (String token : generateTokens(BATCH_SIZE)) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
if (!isNullOrEmpty(line)) {
|
if (!isNullOrEmpty(line)) {
|
||||||
tokensToSave.add(new LrpToken.Builder()
|
tokensToSave.add(new LrpTokenEntity.Builder()
|
||||||
.setAssignee(line)
|
.setAssignee(line)
|
||||||
.setToken(token)
|
.setToken(token)
|
||||||
.setValidTlds(validTlds)
|
.setValidTlds(validTlds)
|
||||||
|
@ -107,13 +107,14 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
||||||
} while (line != null);
|
} while (line != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveTokens(final ImmutableSet<LrpToken> tokens) {
|
private void saveTokens(final ImmutableSet<LrpTokenEntity> tokens) {
|
||||||
Collection<LrpToken> savedTokens = ofy().transact(new Work<Collection<LrpToken>>() {
|
Collection<LrpTokenEntity> savedTokens =
|
||||||
@Override
|
ofy().transact(new Work<Collection<LrpTokenEntity>>() {
|
||||||
public Collection<LrpToken> run() {
|
@Override
|
||||||
return ofy().save().entities(tokens).now().values();
|
public Collection<LrpTokenEntity> run() {
|
||||||
}});
|
return ofy().save().entities(tokens).now().values();
|
||||||
for (LrpToken token : savedTokens) {
|
}});
|
||||||
|
for (LrpTokenEntity token : savedTokens) {
|
||||||
System.out.printf("%s,%s%n", token.getAssignee(), token.getToken());
|
System.out.printf("%s,%s%n", token.getAssignee(), token.getToken());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,18 +129,18 @@ public final class CreateLrpTokensCommand implements RemoteApiCommand {
|
||||||
private ImmutableSet<String> generateTokens(int count) {
|
private ImmutableSet<String> generateTokens(int count) {
|
||||||
final ImmutableSet<String> candidates =
|
final ImmutableSet<String> candidates =
|
||||||
ImmutableSet.copyOf(TokenUtils.createTokens(LRP, stringGenerator, count));
|
ImmutableSet.copyOf(TokenUtils.createTokens(LRP, stringGenerator, count));
|
||||||
ImmutableSet<Key<LrpToken>> existingTokenKeys = FluentIterable.from(candidates)
|
ImmutableSet<Key<LrpTokenEntity>> existingTokenKeys = FluentIterable.from(candidates)
|
||||||
.transform(new Function<String, Key<LrpToken>>() {
|
.transform(new Function<String, Key<LrpTokenEntity>>() {
|
||||||
@Override
|
@Override
|
||||||
public Key<LrpToken> apply(String input) {
|
public Key<LrpTokenEntity> apply(String input) {
|
||||||
return Key.create(LrpToken.class, input);
|
return Key.create(LrpTokenEntity.class, input);
|
||||||
}})
|
}})
|
||||||
.toSet();
|
.toSet();
|
||||||
ImmutableSet<String> existingTokenStrings = FluentIterable
|
ImmutableSet<String> existingTokenStrings = FluentIterable
|
||||||
.from(ofy().load().keys(existingTokenKeys).values())
|
.from(ofy().load().keys(existingTokenKeys).values())
|
||||||
.transform(new Function<LrpToken, String>() {
|
.transform(new Function<LrpTokenEntity, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(LrpToken input) {
|
public String apply(LrpTokenEntity input) {
|
||||||
return input.getToken();
|
return input.getToken();
|
||||||
}})
|
}})
|
||||||
.toSet();
|
.toSet();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.tools.Command.RemoteApiCommand;
|
import google.registry.tools.Command.RemoteApiCommand;
|
||||||
|
|
||||||
/** Command to show token information for LRP participants. */
|
/** Command to show token information for LRP participants. */
|
||||||
|
@ -51,19 +51,20 @@ public final class GetLrpTokenCommand implements RemoteApiCommand {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
(tokenString == null) == (assignee != null),
|
(tokenString == null) == (assignee != null),
|
||||||
"Exactly one of either token or assignee must be specified.");
|
"Exactly one of either token or assignee must be specified.");
|
||||||
ImmutableSet.Builder<LrpToken> tokensBuilder = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<LrpTokenEntity> tokensBuilder = new ImmutableSet.Builder<>();
|
||||||
if (tokenString != null) {
|
if (tokenString != null) {
|
||||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, tokenString)).now();
|
LrpTokenEntity token =
|
||||||
|
ofy().load().key(Key.create(LrpTokenEntity.class, tokenString)).now();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
tokensBuilder.add(token);
|
tokensBuilder.add(token);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tokensBuilder.addAll(ofy().load().type(LrpToken.class).filter("assignee", assignee));
|
tokensBuilder.addAll(ofy().load().type(LrpTokenEntity.class).filter("assignee", assignee));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableSet<LrpToken> tokens = tokensBuilder.build();
|
ImmutableSet<LrpTokenEntity> tokens = tokensBuilder.build();
|
||||||
if (!tokens.isEmpty()) {
|
if (!tokens.isEmpty()) {
|
||||||
for (LrpToken token : tokens) {
|
for (LrpTokenEntity token : tokens) {
|
||||||
System.out.println(token);
|
System.out.println(token);
|
||||||
if (includeHistory && token.getRedemptionHistoryEntry() != null) {
|
if (includeHistory && token.getRedemptionHistoryEntry() != null) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
|
|
|
@ -12,7 +12,7 @@ ForeignKeyHostIndex
|
||||||
HistoryEntry
|
HistoryEntry
|
||||||
HostResource
|
HostResource
|
||||||
LogsExportCursor
|
LogsExportCursor
|
||||||
LrpToken
|
LrpTokenEntity
|
||||||
Modification
|
Modification
|
||||||
OneTime
|
OneTime
|
||||||
PollMessage
|
PollMessage
|
||||||
|
|
|
@ -104,7 +104,7 @@ import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
|
||||||
import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeException;
|
import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeException;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
import google.registry.model.domain.launch.LaunchPhase;
|
import google.registry.model.domain.launch.LaunchPhase;
|
||||||
|
@ -878,11 +878,12 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpTokenEntity token = persistResource(
|
||||||
.setToken("lrptokentest")
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("test-validate.tld")
|
.setToken("lrptokentest")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setAssignee("test-validate.tld")
|
||||||
.build());
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -910,11 +911,12 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpTokenEntity token = persistResource(
|
||||||
.setToken("lrptokentest")
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("test-validate.tld")
|
.setToken("lrptokentest")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setAssignee("test-validate.tld")
|
||||||
.build());
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -928,7 +930,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
persistResource(new LrpToken.Builder()
|
persistResource(new LrpTokenEntity.Builder()
|
||||||
.setToken("lrptokentest2")
|
.setToken("lrptokentest2")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
@ -946,7 +948,7 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
persistResource(new LrpToken.Builder()
|
persistResource(new LrpTokenEntity.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
// The below assignee doesn't really make sense here, but as of right now the validation
|
// 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
|
// in TldSpecificLogicProxy is just a match on the domain name, so this test ensures that
|
||||||
|
@ -967,11 +969,12 @@ public class DomainApplicationCreateFlowTest
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(Registry.get("tld").asBuilder()
|
||||||
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
.setLrpTldStates(ImmutableSet.of(TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
persistResource(new LrpToken.Builder()
|
persistResource(new LrpTokenEntity.Builder()
|
||||||
.setToken("lrptokentest")
|
.setToken("lrptokentest")
|
||||||
.setAssignee("test-validate.tld")
|
.setAssignee("test-validate.tld")
|
||||||
.setValidTlds(ImmutableSet.of("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");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
|
@ -983,11 +986,13 @@ public class DomainApplicationCreateFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_landrushApplicationWithLrpToken_notInLrp() throws Exception {
|
public void testSuccess_landrushApplicationWithLrpToken_notInLrp() throws Exception {
|
||||||
createTld("tld", TldState.LANDRUSH);
|
createTld("tld", TldState.LANDRUSH);
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpTokenEntity token =
|
||||||
.setToken("lrptokentest")
|
persistResource(
|
||||||
.setAssignee("test-validate.tld")
|
new LrpTokenEntity.Builder()
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setToken("lrptokentest")
|
||||||
.build());
|
.setAssignee("test-validate.tld")
|
||||||
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -1006,11 +1011,12 @@ public class DomainApplicationCreateFlowTest
|
||||||
START_OF_TIME, TldState.SUNRISE,
|
START_OF_TIME, TldState.SUNRISE,
|
||||||
clock.nowUtc(), TldState.LANDRUSH))
|
clock.nowUtc(), TldState.LANDRUSH))
|
||||||
.build());
|
.build());
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpTokenEntity token = persistResource(
|
||||||
.setToken("lrptokentest")
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("test-validate.tld")
|
.setToken("lrptokentest")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setAssignee("test-validate.tld")
|
||||||
.build());
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
setEppInput("domain_create_landrush_lrp.xml");
|
setEppInput("domain_create_landrush_lrp.xml");
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
|
|
@ -103,7 +103,7 @@ 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.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.domain.TestExtraLogicManager;
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
|
@ -823,7 +823,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
"tld-reserved",
|
"tld-reserved",
|
||||||
"anchor,RESERVED_FOR_ANCHOR_TENANT,2fooBAR"))
|
"anchor,RESERVED_FOR_ANCHOR_TENANT,2fooBAR"))
|
||||||
.build());
|
.build());
|
||||||
LrpToken token = persistResource(new LrpToken.Builder()
|
LrpTokenEntity token = persistResource(new LrpTokenEntity.Builder()
|
||||||
.setToken("2fooBAR")
|
.setToken("2fooBAR")
|
||||||
.setAssignee("anchor.tld")
|
.setAssignee("anchor.tld")
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -30,11 +30,11 @@ import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link LrpToken}. */
|
/** Unit tests for {@link LrpTokenEntity}. */
|
||||||
public class LrpTokenTest extends EntityTestCase {
|
public class LrpTokenEntityTest extends EntityTestCase {
|
||||||
|
|
||||||
LrpToken unredeemedToken;
|
LrpTokenEntity unredeemedToken;
|
||||||
LrpToken redeemedToken;
|
LrpTokenEntity redeemedToken;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final ExceptionRule thrown = new ExceptionRule();
|
public final ExceptionRule thrown = new ExceptionRule();
|
||||||
|
@ -48,18 +48,17 @@ public class LrpTokenTest extends EntityTestCase {
|
||||||
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
|
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
|
||||||
.build());
|
.build());
|
||||||
unredeemedToken = persistResource(
|
unredeemedToken = persistResource(
|
||||||
new LrpToken.Builder()
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("1:1020304")
|
.setAssignee("1:1020304")
|
||||||
.setToken("a0b1c2d3e4f5g6")
|
.setToken("a0b1c2d3e4f5g6")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.setMetadata(ImmutableMap.of("foo", "bar"))
|
.setMetadata(ImmutableMap.of("foo", "bar"))
|
||||||
.build());
|
.build());
|
||||||
redeemedToken = persistResource(
|
redeemedToken = persistResource(
|
||||||
new LrpToken.Builder()
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("2:org.testdomain")
|
.setAssignee("2:org.testdomain")
|
||||||
.setToken("h0i1j2k3l4m")
|
.setToken("h0i1j2k3l4m")
|
||||||
.setRedemptionHistoryEntry(
|
.setRedemptionHistoryEntry(Key.create(applicationCreateHistoryEntry))
|
||||||
Key.create(applicationCreateHistoryEntry))
|
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
.setMetadata(ImmutableMap.of("bar", "foo"))
|
.setMetadata(ImmutableMap.of("bar", "foo"))
|
||||||
.build());
|
.build());
|
||||||
|
@ -72,13 +71,14 @@ public class LrpTokenTest extends EntityTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_loadByToken() throws Exception {
|
public void testSuccess_loadByToken() throws Exception {
|
||||||
assertThat(ofy().load().key(Key.create(LrpToken.class, "a0b1c2d3e4f5g6")).now())
|
assertThat(ofy().load().key(Key.create(LrpTokenEntity.class, "a0b1c2d3e4f5g6")).now())
|
||||||
.isEqualTo(unredeemedToken);
|
.isEqualTo(unredeemedToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_loadByAssignee() throws Exception {
|
public void testSuccess_loadByAssignee() throws Exception {
|
||||||
assertThat(ofy().load().type(LrpToken.class).filter("assignee", "1:1020304").first().now())
|
assertThat(
|
||||||
|
ofy().load().type(LrpTokenEntity.class).filter("assignee", "1:1020304").first().now())
|
||||||
.isEqualTo(unredeemedToken);
|
.isEqualTo(unredeemedToken);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
|
@ -286,7 +286,7 @@ class google.registry.model.domain.GracePeriod {
|
||||||
java.lang.String clientId;
|
java.lang.String clientId;
|
||||||
org.joda.time.DateTime expirationTime;
|
org.joda.time.DateTime expirationTime;
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.LrpToken {
|
class google.registry.model.domain.LrpTokenEntity {
|
||||||
@Id java.lang.String token;
|
@Id java.lang.String token;
|
||||||
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.testing.DeterministicStringGenerator;
|
import google.registry.testing.DeterministicStringGenerator;
|
||||||
import google.registry.testing.DeterministicStringGenerator.Rule;
|
import google.registry.testing.DeterministicStringGenerator.Rule;
|
||||||
|
@ -61,7 +61,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneAssignee_tokenCollision() throws Exception {
|
public void testSuccess_oneAssignee_tokenCollision() throws Exception {
|
||||||
LrpToken existingToken = persistResource(new LrpToken.Builder()
|
LrpTokenEntity existingToken = persistResource(new LrpTokenEntity.Builder()
|
||||||
.setToken("LRP_abcdefghijklmnop")
|
.setToken("LRP_abcdefghijklmnop")
|
||||||
.setAssignee("otherdomain.tld")
|
.setAssignee("otherdomain.tld")
|
||||||
.setValidTlds(ImmutableSet.of("tld"))
|
.setValidTlds(ImmutableSet.of("tld"))
|
||||||
|
@ -120,7 +120,7 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_largeFile() throws Exception {
|
public void testSuccess_largeFile() throws Exception {
|
||||||
int numberOfTokens = 67;
|
int numberOfTokens = 67;
|
||||||
LrpToken[] expectedTokens = new LrpToken[numberOfTokens];
|
LrpTokenEntity[] expectedTokens = new LrpTokenEntity[numberOfTokens];
|
||||||
// Prepend a counter to avoid collisions, 16-char alphabet will always generate the same string.
|
// Prepend a counter to avoid collisions, 16-char alphabet will always generate the same string.
|
||||||
stringGenerator =
|
stringGenerator =
|
||||||
new DeterministicStringGenerator("abcdefghijklmnop", Rule.PREPEND_COUNTER);
|
new DeterministicStringGenerator("abcdefghijklmnop", Rule.PREPEND_COUNTER);
|
||||||
|
@ -165,18 +165,19 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
runCommand("--assignee=domain.tld", "--tlds=foo");
|
runCommand("--assignee=domain.tld", "--tlds=foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertLrpTokens(LrpToken... expected) throws Exception {
|
private void assertLrpTokens(LrpTokenEntity... expected) throws Exception {
|
||||||
// Using ImmutableObject comparison here is tricky because updateTimestamp is not set on the
|
// Using ImmutableObject comparison here is tricky because updateTimestamp is not set on the
|
||||||
// expected LrpToken objects and will cause the assert to fail.
|
// expected LrpToken objects and will cause the assert to fail.
|
||||||
Iterable<LrpToken> actual = ofy().load().type(LrpToken.class);
|
Iterable<LrpTokenEntity> actual = ofy().load().type(LrpTokenEntity.class);
|
||||||
ImmutableMap.Builder<String, LrpToken> actualTokenMapBuilder = new ImmutableMap.Builder<>();
|
ImmutableMap.Builder<String, LrpTokenEntity> actualTokenMapBuilder =
|
||||||
for (LrpToken token : actual) {
|
new ImmutableMap.Builder<>();
|
||||||
|
for (LrpTokenEntity token : actual) {
|
||||||
actualTokenMapBuilder.put(token.getToken(), token);
|
actualTokenMapBuilder.put(token.getToken(), token);
|
||||||
}
|
}
|
||||||
ImmutableMap<String, LrpToken> actualTokenMap = actualTokenMapBuilder.build();
|
ImmutableMap<String, LrpTokenEntity> actualTokenMap = actualTokenMapBuilder.build();
|
||||||
assertThat(actualTokenMap).hasSize(expected.length);
|
assertThat(actualTokenMap).hasSize(expected.length);
|
||||||
for (LrpToken expectedToken : expected) {
|
for (LrpTokenEntity expectedToken : expected) {
|
||||||
LrpToken match = actualTokenMap.get(expectedToken.getToken());
|
LrpTokenEntity match = actualTokenMap.get(expectedToken.getToken());
|
||||||
assertThat(match).isNotNull();
|
assertThat(match).isNotNull();
|
||||||
assertThat(match.getAssignee()).isEqualTo(expectedToken.getAssignee());
|
assertThat(match.getAssignee()).isEqualTo(expectedToken.getAssignee());
|
||||||
assertThat(match.getValidTlds()).containsExactlyElementsIn(expectedToken.getValidTlds());
|
assertThat(match.getValidTlds()).containsExactlyElementsIn(expectedToken.getValidTlds());
|
||||||
|
@ -185,12 +186,12 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LrpToken createToken(
|
private LrpTokenEntity createToken(
|
||||||
String token,
|
String token,
|
||||||
String assignee,
|
String assignee,
|
||||||
Set<String> validTlds,
|
Set<String> validTlds,
|
||||||
@Nullable Key<HistoryEntry> redemptionHistoryEntry) {
|
@Nullable Key<HistoryEntry> redemptionHistoryEntry) {
|
||||||
LrpToken.Builder tokenBuilder = new LrpToken.Builder()
|
LrpTokenEntity.Builder tokenBuilder = new LrpTokenEntity.Builder()
|
||||||
.setAssignee(assignee)
|
.setAssignee(assignee)
|
||||||
.setValidTlds(validTlds)
|
.setValidTlds(validTlds)
|
||||||
.setToken(token);
|
.setToken(token);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.LrpToken;
|
import google.registry.model.domain.LrpTokenEntity;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -37,7 +37,7 @@ public class GetLrpTokenCommandTest extends CommandTestCase<GetLrpTokenCommand>
|
||||||
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
|
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
|
||||||
.build());
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
new LrpToken.Builder()
|
new LrpTokenEntity.Builder()
|
||||||
.setAssignee("domain.tld")
|
.setAssignee("domain.tld")
|
||||||
.setToken("domain_token")
|
.setToken("domain_token")
|
||||||
.setRedemptionHistoryEntry(Key.create(applicationCreateHistoryEntry))
|
.setRedemptionHistoryEntry(Key.create(applicationCreateHistoryEntry))
|
||||||
|
|
Loading…
Add table
Reference in a new issue