mirror of
https://github.com/google/nomulus
synced 2026-06-09 16:33:02 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 022f397cd9 | |||
| 5dc058ec99 | |||
| 0fd7cf29b5 | |||
| bc7f3546c7 | |||
| 658f61bd8f | |||
| 8ca8fff387 | |||
| 8bcfb1802e | |||
| a259dee986 |
+4
-7
@@ -119,14 +119,10 @@ task stage {
|
||||
|
||||
def environments = ['production', 'sandbox', 'alpha', 'crash']
|
||||
|
||||
// TODO(mmuller): Move this into internal specialization code.
|
||||
def projects = ['production': 'domain-registry',
|
||||
'sandbox' : 'domain-registry-sandbox',
|
||||
'alpha' : 'domain-registry-alpha',
|
||||
'crash' : 'domain-registry-crash']
|
||||
|
||||
def gcpProject = null
|
||||
|
||||
apply from: "${rootDir.path}/projects.gradle"
|
||||
|
||||
if (environment == '') {
|
||||
// Keep the project null, this will prevent deployment. Set the
|
||||
// environment to "alpha" because other code needs this property to
|
||||
@@ -135,7 +131,8 @@ if (environment == '') {
|
||||
} else if (environment != 'production' && environment != 'sandbox') {
|
||||
gcpProject = projects[environment]
|
||||
if (gcpProject == null) {
|
||||
throw new GradleException("-Penvironment must be one of ${environments}.")
|
||||
throw new GradleException("-Penvironment must be one of " +
|
||||
"${projects.keySet()}.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<cron>
|
||||
<url><![CDATA[/_dr/cron/fanout?queue=retryable-cron-tasks&endpoint=/_dr/task/exportDomainLists&runInEmpty]]></url>
|
||||
<description>
|
||||
This job exports lists of all active domain names to Google Cloud Storage.
|
||||
This job exports lists of all active domain names to Google Drive and Google Cloud Storage.
|
||||
</description>
|
||||
<schedule>every 12 hours synchronized</schedule>
|
||||
<target>backend</target>
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<cron>
|
||||
<url><![CDATA[/_dr/cron/fanout?queue=retryable-cron-tasks&endpoint=/_dr/task/exportDomainLists&runInEmpty]]></url>
|
||||
<description>
|
||||
This job exports lists of all active domain names to Google Cloud Storage.
|
||||
This job exports lists of all active domain names to Google Drive and Google Cloud Storage.
|
||||
</description>
|
||||
<schedule>every 12 hours synchronized</schedule>
|
||||
<target>backend</target>
|
||||
|
||||
@@ -56,7 +56,7 @@ import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* A mapreduce that exports the list of active domains on all real TLDs to Google Cloud Storage.
|
||||
* A mapreduce that exports the list of active domains on all real TLDs to Google Drive and GCS.
|
||||
*
|
||||
* <p>Each TLD's active domain names are exported as a newline-delimited flat text file with the
|
||||
* name TLD.txt into the domain-lists bucket. Note that this overwrites the files in place.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2019 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.registry;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
|
||||
import google.registry.schema.domain.RegistryLock;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
/** Data access object for {@link google.registry.schema.domain.RegistryLock}. */
|
||||
public final class RegistryLockDao {
|
||||
|
||||
/**
|
||||
* Returns the most recent version of the {@link RegistryLock} referred to by the verification
|
||||
* code (there may be two instances of the same code in the database--one after lock object
|
||||
* creation and one after verification.
|
||||
*/
|
||||
public static RegistryLock getByVerificationCode(String verificationCode) {
|
||||
return jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
EntityManager em = jpaTm().getEntityManager();
|
||||
Long revisionId =
|
||||
em.createQuery(
|
||||
"SELECT MAX(revisionId) FROM RegistryLock WHERE verificationCode ="
|
||||
+ " :verificationCode",
|
||||
Long.class)
|
||||
.setParameter("verificationCode", verificationCode)
|
||||
.getSingleResult();
|
||||
checkNotNull(revisionId, "No registry lock with this code");
|
||||
return em.find(RegistryLock.class, revisionId);
|
||||
});
|
||||
}
|
||||
|
||||
public static void save(RegistryLock registryLock) {
|
||||
checkNotNull(registryLock, "Null registry lock cannot be saved");
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(registryLock));
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,12 @@ public class TransactionManagerFactory {
|
||||
// PostgreSQL tables in production, ensure that all of the test environments are set up
|
||||
// correctly and restore the code that creates a JpaTransactionManager when
|
||||
// RegistryEnvironment.get() != UNITTEST.
|
||||
//
|
||||
// We removed the original code because it didn't work in sandbox (due to the absence of the
|
||||
// persistence.xml file, which has since been added), and then (after adding this) didn't work
|
||||
// in crash because the postgresql password hadn't been set up. Prior to restoring, we'll need
|
||||
// to do setup in all environments, and we probably only want to do this once we're actually
|
||||
// using Cloud SQL for one of the new tables.
|
||||
return DummyJpaTransactionManager.create();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,13 @@ import javax.persistence.Converter;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** JPA converter to for storing/retrieving CreateAutoTimestamp objects. */
|
||||
@Converter
|
||||
@Converter(autoApply = true)
|
||||
public class CreateAutoTimestampConverter
|
||||
implements AttributeConverter<CreateAutoTimestamp, Timestamp> {
|
||||
|
||||
@Override
|
||||
public Timestamp convertToDatabaseColumn(CreateAutoTimestamp entity) {
|
||||
DateTime dateTime =
|
||||
firstNonNull(((CreateAutoTimestamp) entity).getTimestamp(), jpaTm().getTransactionTime());
|
||||
DateTime dateTime = firstNonNull(entity.getTimestamp(), jpaTm().getTransactionTime());
|
||||
return Timestamp.from(DateTimeUtils.toZonedDateTime(dateTime).toInstant());
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ public class PersistenceModule {
|
||||
// SessionFactory is created. Setting it to 'none' to turn off the feature.
|
||||
properties.put(Environment.HBM2DDL_AUTO, "none");
|
||||
|
||||
// Hibernate converts any date to this timezone when writing to the database.
|
||||
properties.put(Environment.JDBC_TIME_ZONE, "UTC");
|
||||
properties.put(
|
||||
Environment.PHYSICAL_NAMING_STRATEGY, NomulusNamingStrategy.class.getCanonicalName());
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
/** JPA converter for storing/retrieving UpdateAutoTimestamp objects. */
|
||||
@Converter
|
||||
@Converter(autoApply = true)
|
||||
public class UpdateAutoTimestampConverter
|
||||
implements AttributeConverter<UpdateAutoTimestamp, Timestamp> {
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2019 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.persistence;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
/**
|
||||
* JPA converter to for storing/retrieving {@link ZonedDateTime} objects.
|
||||
*
|
||||
* <p>Hibernate provides a default converter for {@link ZonedDateTime}, but it converts timestamp to
|
||||
* a non-normalized format, e.g., 2019-09-01T01:01:01Z will be converted to
|
||||
* 2019-09-01T01:01:01Z[UTC]. This converter solves that problem by explicitly calling {@link
|
||||
* ZoneId#normalized()} to normalize the zone id.
|
||||
*/
|
||||
@Converter(autoApply = true)
|
||||
public class ZonedDateTimeConverter implements AttributeConverter<ZonedDateTime, Timestamp> {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Timestamp convertToDatabaseColumn(@Nullable ZonedDateTime attribute) {
|
||||
return attribute == null ? null : Timestamp.from(attribute.toInstant());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ZonedDateTime convertToEntityAttribute(@Nullable Timestamp dbData) {
|
||||
return dbData == null
|
||||
? null
|
||||
: ZonedDateTime.ofInstant(dbData.toInstant(), ZoneId.of("UTC").normalized());
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@
|
||||
package google.registry.schema.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.util.DateTimeUtils.toJodaDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toZonedDateTime;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.CreateAutoTimestamp;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.util.DateTimeUtils;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -56,14 +56,17 @@ import org.joda.time.DateTime;
|
||||
* Unique constraint to get around Hibernate's failure to handle auto-increment field in
|
||||
* composite primary key.
|
||||
*
|
||||
* <p>Note: because of this index, physical columns must be declared in the {@link Column}
|
||||
* annotations for {@link RegistryLock#revisionId} and {@link RegistryLock#repoId} fields.
|
||||
* <p>Note: indexes use the camelCase version of the field names because the {@link
|
||||
* google.registry.persistence.NomulusNamingStrategy} does not translate the field name into the
|
||||
* snake_case column name until the write itself.
|
||||
*/
|
||||
indexes =
|
||||
@Index(
|
||||
name = "idx_registry_lock_repo_id_revision_id",
|
||||
columnList = "repo_id, revision_id",
|
||||
unique = true))
|
||||
indexes = {
|
||||
@Index(
|
||||
name = "idx_registry_lock_repo_id_revision_id",
|
||||
columnList = "repoId, revisionId",
|
||||
unique = true),
|
||||
@Index(name = "idx_registry_lock_verification_code", columnList = "verificationCode")
|
||||
})
|
||||
public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
|
||||
/** Describes the action taken by the user. */
|
||||
@@ -74,11 +77,11 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "revision_id", nullable = false)
|
||||
@Column(nullable = false)
|
||||
private Long revisionId;
|
||||
|
||||
/** EPP repo ID of the domain in question. */
|
||||
@Column(name = "repo_id", nullable = false)
|
||||
@Column(nullable = false)
|
||||
private String repoId;
|
||||
|
||||
// TODO (b/140568328): remove this when everything is in Cloud SQL and we can join on "domain"
|
||||
@@ -104,7 +107,7 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
|
||||
/** Creation timestamp is when the lock/unlock is first requested. */
|
||||
@Column(nullable = false)
|
||||
private ZonedDateTime creationTimestamp;
|
||||
private CreateAutoTimestamp creationTimestamp = CreateAutoTimestamp.create(null);
|
||||
|
||||
/**
|
||||
* Completion timestamp is when the user has verified the lock/unlock, when this object de facto
|
||||
@@ -148,7 +151,7 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
}
|
||||
|
||||
public DateTime getCreationTimestamp() {
|
||||
return toJodaDateTime(creationTimestamp);
|
||||
return creationTimestamp.getTimestamp();
|
||||
}
|
||||
|
||||
/** Returns the completion timestamp, or empty if this lock has not been completed yet. */
|
||||
@@ -168,9 +171,16 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
return revisionId;
|
||||
}
|
||||
|
||||
public void setCompletionTimestamp(DateTime dateTime) {
|
||||
this.completionTimestamp = toZonedDateTime(dateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder asBuilder() {
|
||||
return new Builder(clone(this));
|
||||
RegistryLock clone = clone(this);
|
||||
// Revision ID should be different for every object
|
||||
clone.revisionId = null;
|
||||
return new Builder(clone);
|
||||
}
|
||||
|
||||
/** Builder for {@link google.registry.schema.domain.RegistryLock}. */
|
||||
@@ -187,7 +197,6 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
checkArgumentNotNull(getInstance().domainName, "Domain name cannot be null");
|
||||
checkArgumentNotNull(getInstance().registrarId, "Registrar ID cannot be null");
|
||||
checkArgumentNotNull(getInstance().action, "Action cannot be null");
|
||||
checkArgumentNotNull(getInstance().creationTimestamp, "Creation timestamp cannot be null");
|
||||
checkArgumentNotNull(getInstance().verificationCode, "Verification codecannot be null");
|
||||
checkArgument(
|
||||
getInstance().registrarPocId != null || getInstance().isSuperuser,
|
||||
@@ -220,8 +229,8 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCreationTimestamp(DateTime creationTimestamp) {
|
||||
getInstance().creationTimestamp = toZonedDateTime(creationTimestamp);
|
||||
public Builder setCreationTimestamp(CreateAutoTimestamp creationTimestamp) {
|
||||
getInstance().creationTimestamp = creationTimestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ package google.registry.schema.tld;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import google.registry.model.CreateAutoTimestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
@@ -26,10 +26,12 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.MapKeyColumn;
|
||||
import javax.persistence.Table;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* A list of premium prices for domain names.
|
||||
@@ -40,33 +42,34 @@ import org.joda.money.CurrencyUnit;
|
||||
* This is fine though, because we only use the list with the highest revisionId.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "PremiumList")
|
||||
@Table(indexes = {@Index(columnList = "name", name = "premiumlist_name_idx")})
|
||||
public class PremiumList {
|
||||
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "revision_id")
|
||||
@Column(nullable = false)
|
||||
private Long revisionId;
|
||||
|
||||
@Column(name = "creation_timestamp", nullable = false)
|
||||
private ZonedDateTime creationTimestamp;
|
||||
@Column(nullable = false)
|
||||
private CreateAutoTimestamp creationTimestamp = CreateAutoTimestamp.create(null);
|
||||
|
||||
@Column(name = "currency", nullable = false)
|
||||
@Column(nullable = false)
|
||||
private CurrencyUnit currency;
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(
|
||||
name = "PremiumEntry",
|
||||
joinColumns = @JoinColumn(name = "revision_id", referencedColumnName = "revision_id"))
|
||||
@MapKeyColumn(name = "domain_label")
|
||||
joinColumns = @JoinColumn(name = "revisionId", referencedColumnName = "revisionId"))
|
||||
@MapKeyColumn(name = "domainLabel")
|
||||
@Column(name = "price", nullable = false)
|
||||
private Map<String, BigDecimal> labelsToPrices;
|
||||
|
||||
private PremiumList(
|
||||
ZonedDateTime creationTimestamp,
|
||||
CurrencyUnit currency,
|
||||
Map<String, BigDecimal> labelsToPrices) {
|
||||
this.creationTimestamp = creationTimestamp;
|
||||
private PremiumList(String name, CurrencyUnit currency, Map<String, BigDecimal> labelsToPrices) {
|
||||
// TODO(mcilwain): Generate the Bloom filter and set it here.
|
||||
this.name = name;
|
||||
this.currency = currency;
|
||||
this.labelsToPrices = labelsToPrices;
|
||||
}
|
||||
@@ -74,13 +77,15 @@ public class PremiumList {
|
||||
// Hibernate requires this default constructor.
|
||||
private PremiumList() {}
|
||||
|
||||
// TODO(mcilwain): Change creationTimestamp to Joda DateTime.
|
||||
/** Constructs a {@link PremiumList} object. */
|
||||
public static PremiumList create(
|
||||
ZonedDateTime creationTimestamp,
|
||||
CurrencyUnit currency,
|
||||
Map<String, BigDecimal> labelsToPrices) {
|
||||
return new PremiumList(creationTimestamp, currency, labelsToPrices);
|
||||
String name, CurrencyUnit currency, Map<String, BigDecimal> labelsToPrices) {
|
||||
return new PremiumList(name, currency, labelsToPrices);
|
||||
}
|
||||
|
||||
/** Returns the name of the premium list, which is usually also a TLD string. */
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/** Returns the ID of this revision, or throws if null. */
|
||||
@@ -91,8 +96,8 @@ public class PremiumList {
|
||||
}
|
||||
|
||||
/** Returns the creation time of this revision of the premium list. */
|
||||
public ZonedDateTime getCreationTimestamp() {
|
||||
return creationTimestamp;
|
||||
public DateTime getCreationTimestamp() {
|
||||
return creationTimestamp.getTimestamp();
|
||||
}
|
||||
|
||||
/** Returns a {@link Map} of domain labels to prices. */
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2019 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.schema.tld;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
|
||||
/** Data access object class for {@link PremiumList}. */
|
||||
public class PremiumListDao {
|
||||
|
||||
/** Persist a new premium list to Cloud SQL. */
|
||||
public static void saveNew(PremiumList premiumList) {
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
checkArgument(
|
||||
!checkExists(premiumList.getName()),
|
||||
"A premium list of this name already exists: %s.",
|
||||
premiumList.getName());
|
||||
jpaTm().getEntityManager().persist(premiumList);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the premium list of the given name exists.
|
||||
*
|
||||
* <p>This means that at least one premium list revision must exist for the given name.
|
||||
*/
|
||||
public static boolean checkExists(String premiumListName) {
|
||||
return jpaTm()
|
||||
.transact(
|
||||
() ->
|
||||
jpaTm()
|
||||
.getEntityManager()
|
||||
.createQuery("SELECT 1 FROM PremiumList WHERE name = :name", Integer.class)
|
||||
.setParameter("name", premiumListName)
|
||||
.setMaxResults(1)
|
||||
.getResultList()
|
||||
.size()
|
||||
> 0);
|
||||
}
|
||||
|
||||
private PremiumListDao() {}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ package google.registry.tools;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static google.registry.security.JsonHttp.JSON_SAFETY_PREFIX;
|
||||
import static google.registry.tools.server.CreateOrUpdatePremiumListAction.ALSO_CLOUD_SQL_PARAM;
|
||||
import static google.registry.tools.server.CreateOrUpdatePremiumListAction.INPUT_PARAM;
|
||||
import static google.registry.tools.server.CreateOrUpdatePremiumListAction.NAME_PARAM;
|
||||
import static google.registry.util.ListNamingUtils.convertFilePathToName;
|
||||
@@ -57,6 +58,12 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
||||
required = true)
|
||||
Path inputFile;
|
||||
|
||||
@Parameter(
|
||||
names = {"--also_cloud_sql"},
|
||||
description =
|
||||
"Persist premium list to Cloud SQL in addition to Datastore; defaults to false.")
|
||||
boolean alsoCloudSql;
|
||||
|
||||
protected AppEngineConnection connection;
|
||||
protected int inputLineCount;
|
||||
|
||||
@@ -67,7 +74,7 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
||||
|
||||
abstract String getCommandPath();
|
||||
|
||||
ImmutableMap<String, ?> getParameterMap() {
|
||||
ImmutableMap<String, String> getParameterMap() {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
@@ -88,14 +95,15 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
ImmutableMap.Builder<String, Object> params = new ImmutableMap.Builder<>();
|
||||
ImmutableMap.Builder<String, String> params = new ImmutableMap.Builder<>();
|
||||
params.put(NAME_PARAM, name);
|
||||
params.put(ALSO_CLOUD_SQL_PARAM, Boolean.toString(alsoCloudSql));
|
||||
String inputFileContents = new String(Files.readAllBytes(inputFile), UTF_8);
|
||||
String requestBody =
|
||||
Joiner.on('&').withKeyValueSeparator("=").join(
|
||||
ImmutableMap.of(INPUT_PARAM, URLEncoder.encode(inputFileContents, UTF_8.toString())));
|
||||
|
||||
ImmutableMap<String, ?> extraParams = getParameterMap();
|
||||
ImmutableMap<String, String> extraParams = getParameterMap();
|
||||
if (extraParams != null) {
|
||||
params.putAll(extraParams);
|
||||
}
|
||||
@@ -110,7 +118,7 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
||||
|
||||
// TODO(user): refactor this behavior into a better general-purpose
|
||||
// response validation that can be re-used across the new client/server commands.
|
||||
String extractServerResponse(String response) {
|
||||
private String extractServerResponse(String response) {
|
||||
Map<String, Object> responseMap = toMap(JSONValue.parse(stripJsonPrefix(response)));
|
||||
|
||||
// TODO(user): consider using jart's FormField Framework.
|
||||
@@ -127,7 +135,7 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
||||
}
|
||||
|
||||
// TODO(user): figure out better place to put this method to make it re-usable
|
||||
static String stripJsonPrefix(String json) {
|
||||
private static String stripJsonPrefix(String json) {
|
||||
Verify.verify(json.startsWith(JSON_SAFETY_PREFIX));
|
||||
return json.substring(JSON_SAFETY_PREFIX.length());
|
||||
}
|
||||
|
||||
@@ -36,12 +36,11 @@ public class CreatePremiumListCommand extends CreateOrUpdatePremiumListCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
ImmutableMap<String, ?> getParameterMap() {
|
||||
ImmutableMap<String, String> getParameterMap() {
|
||||
if (override) {
|
||||
return ImmutableMap.of("override", override);
|
||||
return ImmutableMap.of("override", "true");
|
||||
} else {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,11 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.transfer.BaseTransferObject;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.persistence.CreateAutoTimestampConverter;
|
||||
import google.registry.persistence.NomulusNamingStrategy;
|
||||
import google.registry.persistence.NomulusPostgreSQLDialect;
|
||||
import google.registry.persistence.UpdateAutoTimestampConverter;
|
||||
import google.registry.persistence.ZonedDateTimeConverter;
|
||||
import google.registry.schema.domain.RegistryLock;
|
||||
import google.registry.schema.tld.PremiumList;
|
||||
import google.registry.schema.tmch.ClaimsList;
|
||||
@@ -62,6 +65,7 @@ public class GenerateSqlSchemaCommand implements Command {
|
||||
ImmutableSet.of(
|
||||
BaseTransferObject.class,
|
||||
ClaimsList.class,
|
||||
CreateAutoTimestampConverter.class,
|
||||
DelegationSignerData.class,
|
||||
DesignatedContact.class,
|
||||
DomainBase.class,
|
||||
@@ -70,7 +74,9 @@ public class GenerateSqlSchemaCommand implements Command {
|
||||
PremiumList.class,
|
||||
RegistryLock.class,
|
||||
TransferData.class,
|
||||
Trid.class);
|
||||
Trid.class,
|
||||
UpdateAutoTimestampConverter.class,
|
||||
ZonedDateTimeConverter.class);
|
||||
|
||||
@VisibleForTesting
|
||||
public static final String DB_OPTIONS_CLASH =
|
||||
|
||||
+69
-9
@@ -14,17 +14,28 @@
|
||||
|
||||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.flogger.LazyArgs.lazy;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.model.registry.label.PremiumList.PremiumListEntry;
|
||||
import google.registry.request.JsonResponse;
|
||||
import google.registry.request.Parameter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
|
||||
/**
|
||||
* Abstract base class for actions that update premium lists.
|
||||
*/
|
||||
/** Abstract base class for actions that update premium lists. */
|
||||
public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
@@ -33,24 +44,70 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||
|
||||
public static final String NAME_PARAM = "name";
|
||||
public static final String INPUT_PARAM = "inputData";
|
||||
public static final String ALSO_CLOUD_SQL_PARAM = "alsoCloudSql";
|
||||
|
||||
@Inject JsonResponse response;
|
||||
@Inject @Parameter("premiumListName") String name;
|
||||
@Inject @Parameter(INPUT_PARAM) String inputData;
|
||||
|
||||
@Inject
|
||||
@Parameter("premiumListName")
|
||||
String name;
|
||||
|
||||
@Inject
|
||||
@Parameter(INPUT_PARAM)
|
||||
String inputData;
|
||||
|
||||
@Inject
|
||||
@Parameter(ALSO_CLOUD_SQL_PARAM)
|
||||
boolean alsoCloudSql;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
savePremiumList();
|
||||
saveToDatastore();
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.atInfo().withCause(e).log(
|
||||
"Usage error in attempting to save premium list from nomulus tool command");
|
||||
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Unexpected error saving premium list from nomulus tool command");
|
||||
"Unexpected error saving premium list to Datastore from nomulus tool command");
|
||||
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (alsoCloudSql) {
|
||||
try {
|
||||
saveToCloudSql();
|
||||
} catch (Throwable e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Unexpected error saving premium list to Cloud SQL from nomulus tool command");
|
||||
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
google.registry.schema.tld.PremiumList parseInputToPremiumList() {
|
||||
List<String> inputDataPreProcessed =
|
||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||
|
||||
ImmutableMap<String, PremiumListEntry> prices =
|
||||
new PremiumList.Builder().setName(name).build().parse(inputDataPreProcessed);
|
||||
ImmutableSet<CurrencyUnit> currencies =
|
||||
prices.values().stream()
|
||||
.map(e -> e.getValue().getCurrencyUnit())
|
||||
.distinct()
|
||||
.collect(toImmutableSet());
|
||||
checkArgument(
|
||||
currencies.size() == 1,
|
||||
"The Cloud SQL schema requires exactly one currency, but got: %s",
|
||||
ImmutableSortedSet.copyOf(currencies));
|
||||
CurrencyUnit currency = Iterables.getOnlyElement(currencies);
|
||||
|
||||
Map<String, BigDecimal> priceAmounts =
|
||||
Maps.transformValues(prices, ple -> ple.getValue().getAmount());
|
||||
return google.registry.schema.tld.PremiumList.create(name, currency, priceAmounts);
|
||||
}
|
||||
|
||||
/** Logs the premium list data at INFO, truncated if too long. */
|
||||
@@ -64,6 +121,9 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>")));
|
||||
}
|
||||
|
||||
/** Creates a new premium list or updates an existing one. */
|
||||
protected abstract void savePremiumList();
|
||||
/** Saves the premium list to Datastore. */
|
||||
protected abstract void saveToDatastore();
|
||||
|
||||
/** Saves the premium list to Cloud SQL. */
|
||||
protected abstract void saveToCloudSql();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.schema.tld.PremiumListDao;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -50,7 +51,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
@Inject CreatePremiumListAction() {}
|
||||
|
||||
@Override
|
||||
protected void savePremiumList() {
|
||||
protected void saveToDatastore() {
|
||||
checkArgument(
|
||||
!doesPremiumListExist(name), "A premium list of this name already exists: %s.", name);
|
||||
if (!override) {
|
||||
@@ -71,4 +72,22 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToCloudSql() {
|
||||
if (!override) {
|
||||
assertTldExists(name);
|
||||
}
|
||||
logger.atInfo().log("Saving premium list to Cloud SQL for TLD %s", name);
|
||||
// TODO(mcilwain): Call logInputData() here once Datastore persistence is removed.
|
||||
|
||||
google.registry.schema.tld.PremiumList premiumList = parseInputToPremiumList();
|
||||
PremiumListDao.saveNew(premiumList);
|
||||
|
||||
String message =
|
||||
String.format(
|
||||
"Saved premium list %s with %d entries", name, premiumList.getLabelsToPrices().size());
|
||||
logger.atInfo().log(message);
|
||||
// TODO(mcilwain): Call response.setPayload(...) here once Datastore persistence is removed.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ public class ToolsServerModule {
|
||||
return extractRequiredParameter(req, CreatePremiumListAction.INPUT_PARAM);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("alsoCloudSql")
|
||||
static boolean provideAlsoCloudSql(HttpServletRequest req) {
|
||||
return extractBooleanParameter(req, CreatePremiumListAction.ALSO_CLOUD_SQL_PARAM);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("premiumListName")
|
||||
static String provideName(HttpServletRequest req) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
@Inject UpdatePremiumListAction() {}
|
||||
|
||||
@Override
|
||||
protected void savePremiumList() {
|
||||
protected void saveToDatastore() {
|
||||
Optional<PremiumList> existingPremiumList = PremiumList.getUncached(name);
|
||||
checkArgument(
|
||||
existingPremiumList.isPresent(),
|
||||
@@ -67,4 +67,11 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
||||
}
|
||||
|
||||
// TODO(mcilwain): Implement this in a subsequent PR.
|
||||
@Override
|
||||
protected void saveToCloudSql() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Updating of premium lists in Cloud SQL is not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
<class>google.registry.model.transfer.TransferData</class>
|
||||
<class>google.registry.model.eppcommon.Trid</class>
|
||||
|
||||
<!-- Customized type converters -->
|
||||
<class>google.registry.persistence.CreateAutoTimestampConverter</class>
|
||||
<class>google.registry.persistence.UpdateAutoTimestampConverter</class>
|
||||
<class>google.registry.persistence.ZonedDateTimeConverter</class>
|
||||
|
||||
<!-- TODO(weiminyu): check out application-layer validation. -->
|
||||
<validation-mode>NONE</validation-mode>
|
||||
</persistence-unit>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright 2019 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.registry;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import google.registry.model.transaction.JpaTransactionManagerRule;
|
||||
import google.registry.persistence.CreateAutoTimestampConverter;
|
||||
import google.registry.schema.domain.RegistryLock;
|
||||
import google.registry.schema.domain.RegistryLock.Action;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import java.util.UUID;
|
||||
import javax.persistence.PersistenceException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link RegistryLockDao}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public final class RegistryLockDaoTest {
|
||||
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
|
||||
@Rule
|
||||
public final JpaTransactionManagerRule jpaTmRule =
|
||||
new JpaTransactionManagerRule.Builder()
|
||||
.withEntityClass(RegistryLock.class, CreateAutoTimestampConverter.class)
|
||||
.build();
|
||||
|
||||
@Test
|
||||
public void testSaveAndLoad_success() {
|
||||
RegistryLock lock = createLock();
|
||||
RegistryLockDao.save(lock);
|
||||
RegistryLock fromDatabase = RegistryLockDao.getByVerificationCode(lock.getVerificationCode());
|
||||
assertThat(fromDatabase.getDomainName()).isEqualTo(lock.getDomainName());
|
||||
assertThat(fromDatabase.getVerificationCode()).isEqualTo(lock.getVerificationCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveAndLoad_failure_differentCode() {
|
||||
RegistryLock lock = createLock();
|
||||
RegistryLockDao.save(lock);
|
||||
PersistenceException exception =
|
||||
assertThrows(
|
||||
PersistenceException.class,
|
||||
() -> RegistryLockDao.getByVerificationCode(UUID.randomUUID().toString()));
|
||||
assertThat(exception)
|
||||
.hasCauseThat()
|
||||
.hasMessageThat()
|
||||
.isEqualTo("No registry lock with this code");
|
||||
assertThat(exception).hasCauseThat().isInstanceOf(NullPointerException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveTwiceAndLoad_returnsLatest() {
|
||||
RegistryLock lock = createLock();
|
||||
jpaTm().transact(() -> RegistryLockDao.save(lock));
|
||||
jpaTmRule.getTxnClock().advanceOneMilli();
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
RegistryLock secondLock =
|
||||
RegistryLockDao.getByVerificationCode(lock.getVerificationCode());
|
||||
secondLock.setCompletionTimestamp(jpaTmRule.getTxnClock().nowUtc());
|
||||
RegistryLockDao.save(secondLock);
|
||||
});
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
RegistryLock fromDatabase =
|
||||
RegistryLockDao.getByVerificationCode(lock.getVerificationCode());
|
||||
assertThat(fromDatabase.getCompletionTimestamp().get())
|
||||
.isEqualTo(jpaTmRule.getTxnClock().nowUtc());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_saveNull() {
|
||||
assertThrows(NullPointerException.class, () -> RegistryLockDao.save(null));
|
||||
}
|
||||
|
||||
private RegistryLock createLock() {
|
||||
return new RegistryLock.Builder()
|
||||
.setRepoId("repoId")
|
||||
.setDomainName("example.test")
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setAction(Action.LOCK)
|
||||
.setVerificationCode(UUID.randomUUID().toString())
|
||||
.isSuperuser(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import google.registry.persistence.PersistenceModule;
|
||||
import google.registry.testing.FakeClock;
|
||||
@@ -145,9 +146,9 @@ public class JpaTransactionManagerRule extends ExternalResource {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Adds an annotated class to the known entities for the database. */
|
||||
public Builder withEntityClass(Class clazz) {
|
||||
this.extraEntityClasses.add(clazz);
|
||||
/** Adds annotated class(es) to the known entities for the database. */
|
||||
public Builder withEntityClass(Class... classes) {
|
||||
this.extraEntityClasses.addAll(ImmutableSet.copyOf(classes));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -19,7 +19,6 @@ import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
import google.registry.model.CreateAutoTimestamp;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.transaction.JpaTransactionManagerRule;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.hibernate.cfg.Environment;
|
||||
@@ -44,7 +43,7 @@ public class CreateAutoTimestampConverterTest {
|
||||
@Rule
|
||||
public final JpaTransactionManagerRule jpaTmRule =
|
||||
new JpaTransactionManagerRule.Builder()
|
||||
.withEntityClass(TestEntity.class)
|
||||
.withEntityClass(TestEntity.class, CreateAutoTimestampConverter.class)
|
||||
.withProperty(Environment.HBM2DDL_AUTO, "update")
|
||||
.build();
|
||||
|
||||
@@ -78,7 +77,6 @@ public class CreateAutoTimestampConverterTest {
|
||||
|
||||
@Id String name;
|
||||
|
||||
@Convert(converter = CreateAutoTimestampConverter.class)
|
||||
CreateAutoTimestamp cat;
|
||||
|
||||
public TestEntity() {}
|
||||
|
||||
+1
-3
@@ -19,7 +19,6 @@ import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.UpdateAutoTimestamp;
|
||||
import google.registry.model.transaction.JpaTransactionManagerRule;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.hibernate.cfg.Environment;
|
||||
@@ -43,7 +42,7 @@ public class UpdateAutoTimestampConverterTest {
|
||||
@Rule
|
||||
public final JpaTransactionManagerRule jpaTmRule =
|
||||
new JpaTransactionManagerRule.Builder()
|
||||
.withEntityClass(TestEntity.class)
|
||||
.withEntityClass(TestEntity.class, UpdateAutoTimestampConverter.class)
|
||||
.withProperty(Environment.HBM2DDL_AUTO, "update")
|
||||
.build();
|
||||
|
||||
@@ -89,7 +88,6 @@ public class UpdateAutoTimestampConverterTest {
|
||||
|
||||
@Id String name;
|
||||
|
||||
@Convert(converter = UpdateAutoTimestampConverter.class)
|
||||
UpdateAutoTimestamp uat;
|
||||
|
||||
public TestEntity() {}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright 2019 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.persistence;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.transaction.JpaTransactionManagerRule;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link ZonedDateTimeConverter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ZonedDateTimeConverterTest {
|
||||
|
||||
@Rule
|
||||
public final JpaTransactionManagerRule jpaTmRule =
|
||||
new JpaTransactionManagerRule.Builder()
|
||||
.withEntityClass(TestEntity.class, ZonedDateTimeConverter.class)
|
||||
.withProperty(Environment.HBM2DDL_AUTO, "update")
|
||||
.build();
|
||||
|
||||
private final ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
|
||||
|
||||
@Test
|
||||
public void convertToDatabaseColumn_returnsNullIfInputIsNull() {
|
||||
assertThat(converter.convertToDatabaseColumn(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToDatabaseColumn_convertsCorrectly() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2019-09-01T01:01:01Z");
|
||||
assertThat(converter.convertToDatabaseColumn(zonedDateTime).toInstant())
|
||||
.isEqualTo(zonedDateTime.toInstant());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToEntityAttribute_returnsNullIfInputIsNull() {
|
||||
assertThat(converter.convertToEntityAttribute(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToEntityAttribute_convertsCorrectly() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2019-09-01T01:01:01Z");
|
||||
Instant instant = zonedDateTime.toInstant();
|
||||
assertThat(converter.convertToEntityAttribute(Timestamp.from(instant)))
|
||||
.isEqualTo(zonedDateTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void converter_generatesTimestampWithNormalizedZone() {
|
||||
ZonedDateTime zdt = ZonedDateTime.parse("2019-09-01T01:01:01Z");
|
||||
TestEntity entity = new TestEntity("normalized_utc_time", zdt);
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(entity));
|
||||
TestEntity retrievedEntity =
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> jpaTm().getEntityManager().find(TestEntity.class, "normalized_utc_time"));
|
||||
assertThat(retrievedEntity.zdt.toString()).isEqualTo("2019-09-01T01:01:01Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void converter_convertsNonNormalizedZoneCorrectly() {
|
||||
ZonedDateTime zdt = ZonedDateTime.parse("2019-09-01T01:01:01Z[UTC]");
|
||||
TestEntity entity = new TestEntity("non_normalized_utc_time", zdt);
|
||||
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(entity));
|
||||
TestEntity retrievedEntity =
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> jpaTm().getEntityManager().find(TestEntity.class, "non_normalized_utc_time"));
|
||||
assertThat(retrievedEntity.zdt.toString()).isEqualTo("2019-09-01T01:01:01Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void converter_convertsNonUtcZoneCorrectly() {
|
||||
ZonedDateTime zdt = ZonedDateTime.parse("2019-09-01T01:01:01+05:00");
|
||||
TestEntity entity = new TestEntity("new_york_time", zdt);
|
||||
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(entity));
|
||||
TestEntity retrievedEntity =
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().find(TestEntity.class, "new_york_time"));
|
||||
assertThat(retrievedEntity.zdt.toString()).isEqualTo("2019-08-31T20:01:01Z");
|
||||
}
|
||||
|
||||
@Entity(name = "TestEntity") // Override entity name to avoid the nested class reference.
|
||||
private static class TestEntity extends ImmutableObject {
|
||||
|
||||
@Id String name;
|
||||
|
||||
ZonedDateTime zdt;
|
||||
|
||||
public TestEntity() {}
|
||||
|
||||
public TestEntity(String name, ZonedDateTime zdt) {
|
||||
this.name = name;
|
||||
this.zdt = zdt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeLockHandler;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -54,9 +55,11 @@ public class EscrowTaskRunnerTest {
|
||||
private final EscrowTask task = mock(EscrowTask.class);
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
||||
|
||||
private DateTimeZone previousDateTimeZone;
|
||||
private EscrowTaskRunner runner;
|
||||
private Registry registry;
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
createTld("lol");
|
||||
@@ -64,9 +67,15 @@ public class EscrowTaskRunnerTest {
|
||||
runner = new EscrowTaskRunner();
|
||||
runner.clock = clock;
|
||||
runner.lockHandler = new FakeLockHandler(true);
|
||||
previousDateTimeZone = DateTimeZone.getDefault();
|
||||
DateTimeZone.setDefault(DateTimeZone.forID("America/New_York")); // Make sure UTC stuff works.
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
DateTimeZone.setDefault(previousDateTimeZone);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
|
||||
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
// Copyright 2019 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.schema.tld;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.transaction.JpaTransactionManagerRule;
|
||||
import google.registry.persistence.CreateAutoTimestampConverter;
|
||||
import java.math.BigDecimal;
|
||||
import javax.persistence.PersistenceException;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link PremiumListDao}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class PremiumListDaoTest {
|
||||
|
||||
@Rule
|
||||
public final JpaTransactionManagerRule jpaTmRule =
|
||||
new JpaTransactionManagerRule.Builder()
|
||||
.withEntityClass(PremiumList.class, CreateAutoTimestampConverter.class)
|
||||
.build();
|
||||
|
||||
private static final ImmutableMap<String, BigDecimal> TEST_PRICES =
|
||||
ImmutableMap.of(
|
||||
"silver",
|
||||
BigDecimal.valueOf(10.23),
|
||||
"gold",
|
||||
BigDecimal.valueOf(1305.47),
|
||||
"palladium",
|
||||
BigDecimal.valueOf(1552.78));
|
||||
|
||||
@Test
|
||||
public void saveNew_worksSuccessfully() {
|
||||
PremiumList premiumList = PremiumList.create("testname", CurrencyUnit.USD, TEST_PRICES);
|
||||
PremiumListDao.saveNew(premiumList);
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
PremiumList persistedList =
|
||||
jpaTm()
|
||||
.getEntityManager()
|
||||
.createQuery(
|
||||
"SELECT pl FROM PremiumList pl WHERE pl.name = :name", PremiumList.class)
|
||||
.setParameter("name", "testname")
|
||||
.getSingleResult();
|
||||
assertThat(persistedList.getLabelsToPrices()).containsExactlyEntriesIn(TEST_PRICES);
|
||||
assertThat(persistedList.getCreationTimestamp())
|
||||
.isEqualTo(jpaTmRule.getTxnClock().nowUtc());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveNew_throwsWhenPremiumListAlreadyExists() {
|
||||
PremiumListDao.saveNew(PremiumList.create("testlist", CurrencyUnit.USD, TEST_PRICES));
|
||||
PersistenceException thrown =
|
||||
assertThrows(
|
||||
PersistenceException.class,
|
||||
() ->
|
||||
PremiumListDao.saveNew(
|
||||
PremiumList.create("testlist", CurrencyUnit.USD, TEST_PRICES)));
|
||||
assertThat(thrown)
|
||||
.hasCauseThat()
|
||||
.hasMessageThat()
|
||||
.contains("A premium list of this name already exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkExists_worksSuccessfully() {
|
||||
assertThat(PremiumListDao.checkExists("testlist")).isFalse();
|
||||
PremiumListDao.saveNew(PremiumList.create("testlist", CurrencyUnit.USD, TEST_PRICES));
|
||||
assertThat(PremiumListDao.checkExists("testlist")).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,13 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||
verifySentParams(
|
||||
connection,
|
||||
servletPath,
|
||||
ImmutableMap.of("name", "foo", "inputData", generateInputData(premiumTermsPath)));
|
||||
ImmutableMap.of(
|
||||
"name",
|
||||
"foo",
|
||||
"inputData",
|
||||
generateInputData(premiumTermsPath),
|
||||
"alsoCloudSql",
|
||||
"false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +84,28 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||
connection,
|
||||
servletPath,
|
||||
ImmutableMap.of(
|
||||
"name", "example_premium_terms", "inputData", generateInputData(premiumTermsPath)));
|
||||
"name",
|
||||
"example_premium_terms",
|
||||
"inputData",
|
||||
generateInputData(premiumTermsPath),
|
||||
"alsoCloudSql",
|
||||
"false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_alsoCloudSql() throws Exception {
|
||||
runCommandForced("-i=" + premiumTermsPath, "-n=foo", "--also_cloud_sql");
|
||||
assertInStdout("Successfully");
|
||||
verifySentParams(
|
||||
connection,
|
||||
servletPath,
|
||||
ImmutableMap.of(
|
||||
"name",
|
||||
"foo",
|
||||
"inputData",
|
||||
generateInputData(premiumTermsPath),
|
||||
"alsoCloudSql",
|
||||
"true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -57,7 +57,13 @@ public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||
verifySentParams(
|
||||
connection,
|
||||
servletPath,
|
||||
ImmutableMap.of("name", "foo", "inputData", generateInputData(premiumTermsPath)));
|
||||
ImmutableMap.of(
|
||||
"name",
|
||||
"foo",
|
||||
"inputData",
|
||||
generateInputData(premiumTermsPath),
|
||||
"alsoCloudSql",
|
||||
"false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,6 +74,11 @@ public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||
connection,
|
||||
servletPath,
|
||||
ImmutableMap.of(
|
||||
"name", "example_premium_terms", "inputData", generateInputData(premiumTermsPath)));
|
||||
"name",
|
||||
"example_premium_terms",
|
||||
"inputData",
|
||||
generateInputData(premiumTermsPath),
|
||||
"alsoCloudSql",
|
||||
"false"));
|
||||
}
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
// 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.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import google.registry.schema.tld.PremiumList;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeJsonResponse;
|
||||
import java.math.BigDecimal;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link CreateOrUpdatePremiumListAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CreateOrUpdatePremiumListActionTest {
|
||||
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
|
||||
private CreatePremiumListAction action;
|
||||
private FakeJsonResponse response;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
action = new CreatePremiumListAction();
|
||||
response = new FakeJsonResponse();
|
||||
action.response = response;
|
||||
action.name = "testlist";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseInputToPremiumList_works() {
|
||||
action.inputData = "foo,USD 99.50\n" + "bar,USD 30\n" + "baz,USD 10\n";
|
||||
PremiumList premiumList = action.parseInputToPremiumList();
|
||||
assertThat(premiumList.getName()).isEqualTo("testlist");
|
||||
assertThat(premiumList.getLabelsToPrices())
|
||||
.containsExactly("foo", twoDigits(99.50), "bar", twoDigits(30), "baz", twoDigits(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseInputToPremiumList_throwsOnInconsistentCurrencies() {
|
||||
action.inputData = "foo,USD 99.50\n" + "bar,USD 30\n" + "baz,JPY 990\n";
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, () -> action.parseInputToPremiumList());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("The Cloud SQL schema requires exactly one currency, but got: [JPY, USD]");
|
||||
}
|
||||
|
||||
private static BigDecimal twoDigits(double num) {
|
||||
return BigDecimal.valueOf((long) (num * 100.0), 2);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -12,18 +12,18 @@ changes not yet deployed are pushed.
|
||||
|
||||
Below are the steps to submit a schema change:
|
||||
|
||||
* Define the incremental DDL script that would update the existing schema to
|
||||
the new one.
|
||||
* Add the script to the src/main/resource/flyway folder. Its name should
|
||||
follow the V{id}__{description text}.sql, where {id} is a number that is
|
||||
higher than all existing scripts in that folder. Also note that it is a
|
||||
1. Write the incremental DDL script that makes your changes to the existing
|
||||
schema. It should be stored in a new file in the
|
||||
`db/src/main/resources/sql/flyway` folder using the naming pattern
|
||||
`V{id}__{description text}.sql`, where `{id}` is the next highest number
|
||||
following the existing scripts in that folder. Also note that it is a
|
||||
**double** underscore in the naming pattern.
|
||||
* Run the `:db:test` task from the Gradle root project. The SchemaTest will
|
||||
2. Run the `:db:test` task from the Gradle root project. The SchemaTest will
|
||||
fail because the new schema does not match the golden file.
|
||||
* Copy db/build/resources/test/testcontainer/mount/dump.txt to the golden file
|
||||
3. Copy db/build/resources/test/testcontainer/mount/dump.txt to the golden file
|
||||
(db/src/main/resources/sql/schema/nomulus.golden.sql). Diff it against the
|
||||
old version and verify that all changes are expected.
|
||||
* Rerun the `:db:test` task. This time all tests should pass.
|
||||
4. Rerun the `:db:test` task. This time all tests should pass.
|
||||
|
||||
Relevant files (under db/src/main/resources/sql/schema/):
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
-- Copyright 2019 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.
|
||||
|
||||
create index if not exists idx_registry_lock_verification_code ON "RegistryLock"
|
||||
using btree (verification_code);
|
||||
+2
-15
@@ -12,19 +12,6 @@
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
|
||||
CREATE TABLE "RegistryLock" (
|
||||
revision_id BIGSERIAL NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
completion_timestamp TIMESTAMPTZ,
|
||||
creation_timestamp TIMESTAMPTZ NOT NULL,
|
||||
domain_name TEXT NOT NULL,
|
||||
is_superuser BOOLEAN NOT NULL,
|
||||
registrar_id TEXT NOT NULL,
|
||||
registrar_poc_id TEXT,
|
||||
repo_id TEXT NOT NULL,
|
||||
verification_code TEXT NOT NULL,
|
||||
PRIMARY KEY (revision_id)
|
||||
);
|
||||
alter table "PremiumList" add column if not exists name text not null;
|
||||
|
||||
ALTER TABLE IF EXISTS "RegistryLock"
|
||||
ADD CONSTRAINT idx_registry_lock_repo_id_revision_id UNIQUE (repo_id, revision_id);
|
||||
create index if not exists premiumlist_name_idx ON "PremiumList" (name);
|
||||
@@ -132,6 +132,7 @@
|
||||
revision_id bigserial not null,
|
||||
creation_timestamp timestamptz not null,
|
||||
currency bytea not null,
|
||||
name text not null,
|
||||
primary key (revision_id)
|
||||
);
|
||||
|
||||
@@ -157,6 +158,7 @@
|
||||
|
||||
alter table if exists "Domain_GracePeriod"
|
||||
add constraint UK_4ps2u4y8i5r91wu2n1x2xea28 unique (grace_periods_id);
|
||||
create index premiumlist_name_idx on "PremiumList" (name);
|
||||
|
||||
alter table if exists "RegistryLock"
|
||||
add constraint idx_registry_lock_repo_id_revision_id unique (repo_id, revision_id);
|
||||
|
||||
@@ -91,7 +91,8 @@ CREATE TABLE public."PremiumEntry" (
|
||||
CREATE TABLE public."PremiumList" (
|
||||
revision_id bigint NOT NULL,
|
||||
creation_timestamp timestamp with time zone NOT NULL,
|
||||
currency bytea NOT NULL
|
||||
currency bytea NOT NULL,
|
||||
name text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -220,6 +221,20 @@ ALTER TABLE ONLY public."RegistryLock"
|
||||
ADD CONSTRAINT idx_registry_lock_repo_id_revision_id UNIQUE (repo_id, revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_registry_lock_verification_code; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idx_registry_lock_verification_code ON public."RegistryLock" USING btree (verification_code);
|
||||
|
||||
|
||||
--
|
||||
-- Name: premiumlist_name_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX premiumlist_name_idx ON public."PremiumList" USING btree (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ClaimsEntry fk6sc6at5hedffc0nhdcab6ivuq; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
// Mapping from environment names to GCP projects.
|
||||
// Replace the values with the names of your deployment environments.
|
||||
|
||||
rootProject.ext.projects = ['production': 'your-production-project',
|
||||
'sandbox' : 'your-sandbox-project',
|
||||
'alpha' : 'your-alpha-project',
|
||||
'crash' : 'your-crash-project']
|
||||
Reference in New Issue
Block a user