mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 20:23:24 +02:00
Add SQL schema for DelegationSignerData (#713)
* Add SQL schema for DelegationSignerData * Remove join table * Rebased on HEAD * Rebase on head
This commit is contained in:
parent
17a1387184
commit
b05f6b4ba3
11 changed files with 242 additions and 30 deletions
|
@ -821,10 +821,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
setEppInput("domain_create_dsdata_no_maxsiglife.xml");
|
||||
persistContactsAndHosts("tld"); // For some reason this sample uses "tld".
|
||||
doSuccessfulTest("tld");
|
||||
DomainBase domain = reloadResourceByForeignKey();
|
||||
assertAboutDomains()
|
||||
.that(reloadResourceByForeignKey())
|
||||
.that(domain)
|
||||
.hasExactlyDsData(
|
||||
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")));
|
||||
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))
|
||||
.cloneWithDomainRepoId(domain.getRepoId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
@ -470,7 +471,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
|||
.that(resource)
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_UPDATE);
|
||||
assertThat(resource.getDsData()).isEqualTo(expectedDsData);
|
||||
assertThat(resource.getDsData())
|
||||
.isEqualTo(
|
||||
expectedDsData.stream()
|
||||
.map(ds -> ds.cloneWithDomainRepoId(resource.getRepoId()))
|
||||
.collect(toImmutableSet()));
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
|
@ -342,6 +343,50 @@ public class DomainBaseSqlTest {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModifyDsData_addThenRemoveSuccessfully() {
|
||||
persistDomain();
|
||||
DelegationSignerData extraDsData =
|
||||
DelegationSignerData.create(2, 2, 3, new byte[] {0, 1, 2}, "4-COM");
|
||||
ImmutableSet<DelegationSignerData> unionDsData =
|
||||
Sets.union(domain.getDsData(), ImmutableSet.of(extraDsData)).immutableCopy();
|
||||
|
||||
// Add an extra DelegationSignerData to dsData set.
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
DomainBase persisted = jpaTm().load(domain.createVKey());
|
||||
assertThat(persisted.getDsData()).containsExactlyElementsIn(domain.getDsData());
|
||||
DomainBase modified = persisted.asBuilder().setDsData(unionDsData).build();
|
||||
jpaTm().put(modified);
|
||||
});
|
||||
|
||||
// Verify that the persisted domain entity contains both DelegationSignerData records.
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
DomainBase persisted = jpaTm().load(domain.createVKey());
|
||||
assertThat(persisted.getDsData()).containsExactlyElementsIn(unionDsData);
|
||||
assertEqualDomainExcept(persisted, "dsData");
|
||||
});
|
||||
|
||||
// Remove the extra DelegationSignerData record from dsData set.
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
DomainBase persisted = jpaTm().load(domain.createVKey());
|
||||
jpaTm().put(persisted.asBuilder().setDsData(domain.getDsData()).build());
|
||||
});
|
||||
|
||||
// Verify that the persisted domain is equal to the original domain.
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
DomainBase persisted = jpaTm().load(domain.createVKey());
|
||||
assertEqualDomainExcept(persisted);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdates() {
|
||||
jpaTm()
|
||||
|
@ -358,16 +403,6 @@ public class DomainBaseSqlTest {
|
|||
.transact(
|
||||
() -> {
|
||||
DomainBase result = jpaTm().load(domain.createVKey());
|
||||
|
||||
// Fix DS data, since we can't persist that yet.
|
||||
result =
|
||||
result
|
||||
.asBuilder()
|
||||
.setDsData(
|
||||
ImmutableSet.of(
|
||||
DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build();
|
||||
|
||||
assertAboutImmutableObjects()
|
||||
.that(result)
|
||||
.isEqualExceptFields(domain, "updateTimestamp", "creationTime");
|
||||
|
@ -572,13 +607,6 @@ public class DomainBaseSqlTest {
|
|||
}
|
||||
|
||||
private void assertEqualDomainExcept(DomainBase thatDomain, String... excepts) {
|
||||
// Fix DS data, since we can't persist it yet.
|
||||
thatDomain =
|
||||
thatDomain
|
||||
.asBuilder()
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build();
|
||||
|
||||
// Fix the original creation timestamp (this gets initialized on first write)
|
||||
DomainBase org = domain.asBuilder().setCreationTime(thatDomain.getCreationTime()).build();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue