mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,133 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.tools.server;
|
||||
|
||||
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.newDomainResource;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.newHostResource;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
|
||||
import static com.google.domain.registry.testing.GcsTestingUtils.readGcsFile;
|
||||
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.appengine.tools.cloudstorage.GcsService;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.domain.registry.mapreduce.MapreduceRunner;
|
||||
import com.google.domain.registry.model.domain.ReferenceUnion;
|
||||
import com.google.domain.registry.model.domain.secdns.DelegationSignerData;
|
||||
import com.google.domain.registry.model.host.HostResource;
|
||||
import com.google.domain.registry.testing.FakeClock;
|
||||
import com.google.domain.registry.testing.mapreduce.MapreduceTestCase;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Map;
|
||||
|
||||
/** Tests for {@link GenerateZoneFilesAction}.*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAction> {
|
||||
|
||||
private final GcsService gcsService = createGcsService();
|
||||
|
||||
@Test
|
||||
public void testGenerate() throws Exception {
|
||||
DateTime now = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay();
|
||||
|
||||
createTld("tld");
|
||||
createTld("com");
|
||||
|
||||
ImmutableSet<InetAddress> ips =
|
||||
ImmutableSet.of(InetAddress.getByName("127.0.0.1"), InetAddress.getByName("::1"));
|
||||
HostResource host1 =
|
||||
persistResource(newHostResource("ns.foo.tld").asBuilder().addInetAddresses(ips).build());
|
||||
HostResource host2 =
|
||||
persistResource(newHostResource("ns.bar.tld").asBuilder().addInetAddresses(ips).build());
|
||||
|
||||
ImmutableSet<ReferenceUnion<HostResource>> nameservers =
|
||||
ImmutableSet.of(
|
||||
ReferenceUnion.<HostResource>create(host1),
|
||||
ReferenceUnion.<HostResource>create(host2));
|
||||
persistResource(newDomainResource("ns-and-ds.tld").asBuilder()
|
||||
.addNameservers(nameservers)
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build());
|
||||
persistResource(newDomainResource("ns-only.tld").asBuilder()
|
||||
.addNameservers(nameservers)
|
||||
.build());
|
||||
persistResource(newDomainResource("ds-only.tld").asBuilder()
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build());
|
||||
|
||||
// These should be ignored; contact and applications aren't in DNS, hosts need to be from the
|
||||
// same tld and have ip addresses, and domains need to be from the same tld and have hosts.
|
||||
persistActiveContact("ignored_contact");
|
||||
persistActiveDomainApplication("ignored_application.tld");
|
||||
persistActiveHost("ignored.host.tld"); // No ips.
|
||||
persistActiveDomain("ignored_domain.tld"); // No hosts or DS data.
|
||||
persistResource(newHostResource("ignored.foo.com").asBuilder().addInetAddresses(ips).build());
|
||||
persistResource(newDomainResource("ignored.com")
|
||||
.asBuilder()
|
||||
.addNameservers(nameservers)
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build());
|
||||
|
||||
GenerateZoneFilesAction action = new GenerateZoneFilesAction();
|
||||
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
|
||||
action.bucket = "zonefiles-bucket";
|
||||
action.gcsBufferSize = 123;
|
||||
action.datastoreRetention = standardDays(29);
|
||||
action.clock = new FakeClock(now.plusMinutes(2)); // Move past the actions' 2 minute check.
|
||||
|
||||
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.<String, Object>of(
|
||||
"tlds", ImmutableList.of("tld"),
|
||||
"exportTime", now));
|
||||
assertThat(response).containsEntry(
|
||||
"filenames",
|
||||
ImmutableList.of("gs://zonefiles-bucket/tld-" + now + ".zone"));
|
||||
|
||||
executeTasksUntilEmpty("mapreduce");
|
||||
|
||||
GcsFilename gcsFilename =
|
||||
new GcsFilename("zonefiles-bucket", String.format("tld-%s.zone", now));
|
||||
String generatedFile = new String(readGcsFile(gcsService, gcsFilename), UTF_8);
|
||||
// The generated file contains spaces and tabs, but the golden file contains only spaces, as
|
||||
// files with literal tabs irritate our build tools.
|
||||
Splitter splitter = Splitter.on('\n').omitEmptyStrings();
|
||||
Iterable<String> generatedFileLines = splitter.split(generatedFile.replaceAll("\t", " "));
|
||||
Iterable<String> goldenFileLines =
|
||||
splitter.split(readResourceUtf8(getClass(), "testdata/tld.zone"));
|
||||
// The first line needs to be the same as the golden file.
|
||||
assertThat(generatedFileLines.iterator().next()).isEqualTo(goldenFileLines.iterator().next());
|
||||
// The remaining lines can be in any order.
|
||||
assertThat(generatedFileLines).containsExactlyElementsIn(goldenFileLines);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue