mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Translate multi-part TLD zone names
Convert periods to hyphens in multi-part TLDs when using them as a zone name (cloud-dns doesn't allow periods in zone names). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=172007089
This commit is contained in:
parent
7e85ae9964
commit
bf818a0139
2 changed files with 19 additions and 4 deletions
|
@ -99,7 +99,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
||||||
Retrier retrier) {
|
Retrier retrier) {
|
||||||
this.dnsConnection = dnsConnection;
|
this.dnsConnection = dnsConnection;
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
this.zoneName = zoneName;
|
this.zoneName = zoneName.replace('.', '-');
|
||||||
this.defaultATtl = defaultATtl;
|
this.defaultATtl = defaultATtl;
|
||||||
this.defaultNsTtl = defaultNsTtl;
|
this.defaultNsTtl = defaultNsTtl;
|
||||||
this.defaultDsTtl = defaultDsTtl;
|
this.defaultDsTtl = defaultDsTtl;
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.dns.writer.clouddns;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.io.BaseEncoding.base16;
|
import static com.google.common.io.BaseEncoding.base16;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.newHostResource;
|
import static google.registry.testing.DatastoreHelper.newHostResource;
|
||||||
|
@ -86,6 +85,7 @@ public class CloudDnsWriterTest {
|
||||||
@Mock private Dns.Changes.Create createChangeRequest;
|
@Mock private Dns.Changes.Create createChangeRequest;
|
||||||
@Mock private Callable<Void> mutateZoneCallable;
|
@Mock private Callable<Void> mutateZoneCallable;
|
||||||
@Captor ArgumentCaptor<String> recordNameCaptor;
|
@Captor ArgumentCaptor<String> recordNameCaptor;
|
||||||
|
@Captor ArgumentCaptor<String> zoneNameCaptor;
|
||||||
@Captor ArgumentCaptor<Change> changeCaptor;
|
@Captor ArgumentCaptor<Change> changeCaptor;
|
||||||
private CloudDnsWriter writer;
|
private CloudDnsWriter writer;
|
||||||
private ImmutableSet<ResourceRecordSet> stubZone;
|
private ImmutableSet<ResourceRecordSet> stubZone;
|
||||||
|
@ -101,7 +101,7 @@ public class CloudDnsWriterTest {
|
||||||
new CloudDnsWriter(
|
new CloudDnsWriter(
|
||||||
dnsConnection,
|
dnsConnection,
|
||||||
"projectId",
|
"projectId",
|
||||||
"zoneName",
|
"triple.secret.tld", // used by testInvalidZoneNames()
|
||||||
DEFAULT_A_TTL,
|
DEFAULT_A_TTL,
|
||||||
DEFAULT_NS_TTL,
|
DEFAULT_NS_TTL,
|
||||||
DEFAULT_DS_TTL,
|
DEFAULT_DS_TTL,
|
||||||
|
@ -142,7 +142,7 @@ public class CloudDnsWriterTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
when(changes.create(anyString(), anyString(), changeCaptor.capture()))
|
when(changes.create(anyString(), zoneNameCaptor.capture(), changeCaptor.capture()))
|
||||||
.thenReturn(createChangeRequest);
|
.thenReturn(createChangeRequest);
|
||||||
// Change our stub zone when a request to change the records is executed
|
// Change our stub zone when a request to change the records is executed
|
||||||
when(createChangeRequest.execute())
|
when(createChangeRequest.execute())
|
||||||
|
@ -485,4 +485,19 @@ public class CloudDnsWriterTest {
|
||||||
|
|
||||||
verifyZone(fakeDomainRecords("example.tld", 1, 0, 0, 0));
|
verifyZone(fakeDomainRecords("example.tld", 1, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvalidZoneNames() {
|
||||||
|
createTld("triple.secret.tld");
|
||||||
|
persistResource(
|
||||||
|
fakeDomain(
|
||||||
|
"example.triple.secret.tld",
|
||||||
|
ImmutableSet.of(persistResource(fakeHost("0.ip4.example.tld", IPv4))),
|
||||||
|
0)
|
||||||
|
.asBuilder()
|
||||||
|
.build());
|
||||||
|
writer.publishDomain("example.triple.secret.tld");
|
||||||
|
writer.commit();
|
||||||
|
assertThat(zoneNameCaptor.getValue()).isEqualTo("triple-secret-tld");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue