mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 19:48:32 +02:00
Remove TmchCrl singleton from Datastore (#1419)
This commit is contained in:
parent
573f14514a
commit
09271977c3
6 changed files with 16 additions and 48 deletions
|
@ -43,7 +43,6 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import google.registry.model.server.Lock;
|
||||
import google.registry.model.server.ServerSecret;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tmch.TmchCrl;
|
||||
|
||||
/** Sets of classes of the Objectify-registered entities in use throughout the model. */
|
||||
public final class EntityClasses {
|
||||
|
@ -85,8 +84,7 @@ public final class EntityClasses {
|
|||
Registrar.class,
|
||||
RegistrarContact.class,
|
||||
Registry.class,
|
||||
ServerSecret.class,
|
||||
TmchCrl.class);
|
||||
ServerSecret.class);
|
||||
|
||||
private EntityClasses() {}
|
||||
}
|
||||
|
|
|
@ -16,25 +16,18 @@ package google.registry.model.tmch;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import google.registry.model.annotations.NotBackedUp;
|
||||
import google.registry.model.annotations.NotBackedUp.Reason;
|
||||
import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.model.replay.NonReplicatedEntity;
|
||||
import google.registry.model.replay.SqlOnlyEntity;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.persistence.Column;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Datastore singleton for ICANN's TMCH CA certificate revocation list (CRL). */
|
||||
@Entity
|
||||
/** Singleton for ICANN's TMCH CA certificate revocation list (CRL). */
|
||||
@javax.persistence.Entity
|
||||
@Immutable
|
||||
@NotBackedUp(reason = Reason.EXTERNALLY_SOURCED)
|
||||
public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEntity {
|
||||
public final class TmchCrl extends CrossTldSingleton implements SqlOnlyEntity {
|
||||
|
||||
@Column(name = "certificateRevocations", nullable = false)
|
||||
String crl;
|
||||
|
@ -47,25 +40,23 @@ public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEnt
|
|||
|
||||
/** Returns the singleton instance of this entity, without memoization. */
|
||||
public static Optional<TmchCrl> get() {
|
||||
return tm().transact(() -> tm().loadSingleton(TmchCrl.class));
|
||||
return jpaTm().transact(() -> jpaTm().loadSingleton(TmchCrl.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the Datastore singleton to a new ASCII-armored X.509 CRL.
|
||||
* Change the singleton to a new ASCII-armored X.509 CRL.
|
||||
*
|
||||
* <p>Please do not call this function unless your CRL is properly formatted, signed by the root,
|
||||
* and actually newer than the one currently in Datastore.
|
||||
*
|
||||
* <p>During the dual-write period, we write to both Datastore and SQL
|
||||
*/
|
||||
public static void set(final String crl, final String url) {
|
||||
tm().transact(
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
TmchCrl tmchCrl = new TmchCrl();
|
||||
tmchCrl.updated = tm().getTransactionTime();
|
||||
tmchCrl.updated = jpaTm().getTransactionTime();
|
||||
tmchCrl.crl = checkNotNull(crl, "crl");
|
||||
tmchCrl.url = checkNotNull(url, "url");
|
||||
ofyTm().transactNew(() -> ofyTm().putWithoutBackup(tmchCrl));
|
||||
jpaTm().transactNew(() -> jpaTm().putWithoutBackup(tmchCrl));
|
||||
});
|
||||
}
|
||||
|
@ -80,7 +71,7 @@ public final class TmchCrl extends CrossTldSingleton implements NonReplicatedEnt
|
|||
return crl;
|
||||
}
|
||||
|
||||
/** Time we last updated the Datastore with a newer ICANN CRL. */
|
||||
/** Time we last updated the Database with a newer ICANN CRL. */
|
||||
public final DateTime getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ import google.registry.model.replay.SqlReplayCheckpoint;
|
|||
import google.registry.model.server.Lock;
|
||||
import google.registry.model.tld.label.PremiumList;
|
||||
import google.registry.model.tld.label.PremiumList.PremiumEntry;
|
||||
import google.registry.model.tmch.TmchCrl;
|
||||
import google.registry.model.translators.VKeyTranslatorFactory;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.persistence.transaction.JpaTransactionManager;
|
||||
|
@ -482,7 +481,8 @@ public class ReplayCommitLogsToSqlActionTest {
|
|||
|
||||
jpaTm().transact(() -> SqlReplayCheckpoint.set(now.minusMinutes(1).minusMillis(1)));
|
||||
// Save a couple deletes that aren't propagated to SQL (the objects deleted are irrelevant)
|
||||
Key<TmchCrl> tmchCrlKey = Key.create(TmchCrl.class, 1L);
|
||||
Key<CommitLogManifest> manifestKey =
|
||||
CommitLogManifest.createKey(getBucketKey(1), now.minusMinutes(1));
|
||||
saveDiffFile(
|
||||
gcsUtils,
|
||||
createCheckpoint(now.minusMinutes(1)),
|
||||
|
@ -490,7 +490,7 @@ public class ReplayCommitLogsToSqlActionTest {
|
|||
getBucketKey(1),
|
||||
now.minusMinutes(1),
|
||||
// one object only exists in Datastore, one is dually-written (so isn't replicated)
|
||||
ImmutableSet.of(getCrossTldKey(), tmchCrlKey)));
|
||||
ImmutableSet.of(getCrossTldKey(), manifestKey)));
|
||||
|
||||
runAndAssertSuccess(now.minusMinutes(1), 1, 1);
|
||||
verify(spy, times(0)).delete(any(VKey.class));
|
||||
|
|
|
@ -15,39 +15,26 @@
|
|||
package google.registry.model.tmch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.testing.DualDatabaseTest;
|
||||
import google.registry.testing.TestOfyAndSql;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link TmchCrl}. */
|
||||
@DualDatabaseTest
|
||||
public class TmchCrlTest extends EntityTestCase {
|
||||
|
||||
TmchCrlTest() {
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testSuccess() {
|
||||
assertThat(TmchCrl.get()).isEqualTo(Optional.empty());
|
||||
TmchCrl.set("lolcat", "https://lol.cat");
|
||||
assertThat(TmchCrl.get().get().getCrl()).isEqualTo("lolcat");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testDualWrite() {
|
||||
TmchCrl expected = new TmchCrl();
|
||||
expected.crl = "lolcat";
|
||||
expected.url = "https://lol.cat";
|
||||
expected.updated = fakeClock.nowUtc();
|
||||
TmchCrl.set("lolcat", "https://lol.cat");
|
||||
assertThat(loadByEntity(new TmchCrl())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@Test
|
||||
void testMultipleWrites() {
|
||||
TmchCrl.set("first", "https://first.cat");
|
||||
assertThat(TmchCrl.get().get().getCrl()).isEqualTo("first");
|
||||
|
|
|
@ -3,4 +3,3 @@ Registrar
|
|||
RegistrarContact
|
||||
Registry
|
||||
ServerSecret
|
||||
TmchCrl
|
||||
|
|
|
@ -789,13 +789,6 @@ enum google.registry.model.tld.Registry$TldType {
|
|||
REAL;
|
||||
TEST;
|
||||
}
|
||||
class google.registry.model.tmch.TmchCrl {
|
||||
@Id long id;
|
||||
@Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent;
|
||||
java.lang.String crl;
|
||||
java.lang.String url;
|
||||
org.joda.time.DateTime updated;
|
||||
}
|
||||
class google.registry.model.transfer.ContactTransferData {
|
||||
google.registry.model.eppcommon.Trid transferRequestTrid;
|
||||
google.registry.model.transfer.TransferStatus transferStatus;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue