mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
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.
167 lines
6.5 KiB
Java
167 lines
6.5 KiB
Java
// 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;
|
|
|
|
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
|
|
import static com.google.domain.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
|
import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
|
|
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
|
|
import static org.joda.time.DateTimeZone.UTC;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.domain.registry.model.domain.DomainApplication;
|
|
import com.google.domain.registry.model.domain.launch.LaunchNotice;
|
|
import com.google.domain.registry.model.domain.launch.LaunchNotice.InvalidChecksumException;
|
|
import com.google.domain.registry.model.reporting.HistoryEntry;
|
|
import com.google.domain.registry.model.smd.EncodedSignedMark;
|
|
|
|
import org.joda.time.DateTime;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
/** Unit tests for {@link UpdateClaimsNoticeCommandTest}. */
|
|
public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsNoticeCommand> {
|
|
|
|
DomainApplication domainApplication;
|
|
|
|
@Before
|
|
public void init() {
|
|
createTld("xn--q9jyb4c");
|
|
domainApplication = persistResource(newDomainApplication("example-one.xn--q9jyb4c")
|
|
.asBuilder()
|
|
.setCurrentSponsorClientId("TheRegistrar")
|
|
.build());
|
|
}
|
|
|
|
private DomainApplication reloadDomainApplication() {
|
|
return ofy().load().entity(domainApplication).now();
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_noLaunchNotice() throws Exception {
|
|
DateTime before = new DateTime(UTC);
|
|
assertAboutApplications().that(domainApplication).hasLaunchNotice(null);
|
|
|
|
runCommand(
|
|
"--id=2-Q9JYB4C",
|
|
"--tcn_id=370d0b7c9223372036854775807",
|
|
"--expiration_time=2010-08-16T09:00:00.0Z",
|
|
"--accepted_time=2009-08-16T09:00:00.0Z");
|
|
|
|
assertAboutApplications().that(reloadDomainApplication())
|
|
.hasLaunchNotice(LaunchNotice.create(
|
|
"370d0b7c9223372036854775807",
|
|
"tmch",
|
|
DateTime.parse("2010-08-16T09:00:00.0Z"),
|
|
DateTime.parse("2009-08-16T09:00:00.0Z"))).and()
|
|
.hasLastEppUpdateTimeAtLeast(before).and()
|
|
.hasLastEppUpdateClientId("TheRegistrar").and()
|
|
.hasOnlyOneHistoryEntryWhich()
|
|
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
|
|
.hasClientId("TheRegistrar");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_paddedChecksum() throws Exception {
|
|
DateTime before = new DateTime(UTC);
|
|
domainApplication = persistResource(newDomainApplication("imdb.xn--q9jyb4c"));
|
|
|
|
runCommand(
|
|
"--id=4-Q9JYB4C",
|
|
"--tcn_id=0a07ec6e0000000000010995975",
|
|
"--expiration_time=2014-02-28T12:00:00.0Z",
|
|
"--accepted_time=2014-02-26T12:00:00.0Z");
|
|
|
|
assertAboutApplications().that(reloadDomainApplication())
|
|
.hasLaunchNotice(LaunchNotice.create(
|
|
"0a07ec6e0000000000010995975",
|
|
"tmch",
|
|
DateTime.parse("2014-02-28T12:00:00.0Z"),
|
|
DateTime.parse("2014-02-26T12:00:00.0Z"))).and()
|
|
.hasLastEppUpdateTimeAtLeast(before).and()
|
|
.hasLastEppUpdateClientId("TheRegistrar").and()
|
|
.hasOnlyOneHistoryEntryWhich()
|
|
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
|
|
.hasClientId("TheRegistrar");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_replaceExistingLaunchNotice() throws Exception {
|
|
DateTime before = new DateTime(UTC);
|
|
|
|
// Set a launch notice which should get overwritten.
|
|
domainApplication = persistResource(domainApplication.asBuilder()
|
|
.setLaunchNotice(LaunchNotice.create("foobar", "tmch", END_OF_TIME, START_OF_TIME))
|
|
.build());
|
|
|
|
runCommand(
|
|
"--id=2-Q9JYB4C",
|
|
"--tcn_id=370d0b7c9223372036854775807",
|
|
"--expiration_time=2010-08-16T09:00:00.0Z",
|
|
"--accepted_time=2009-08-16T09:00:00.0Z");
|
|
|
|
assertAboutApplications().that(reloadDomainApplication())
|
|
.hasLaunchNotice(LaunchNotice.create(
|
|
"370d0b7c9223372036854775807",
|
|
"tmch",
|
|
DateTime.parse("2010-08-16T09:00:00.0Z"),
|
|
DateTime.parse("2009-08-16T09:00:00.0Z"))).and()
|
|
.hasLastEppUpdateTimeAtLeast(before).and()
|
|
.hasLastEppUpdateClientId("TheRegistrar").and()
|
|
.hasOnlyOneHistoryEntryWhich()
|
|
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
|
|
.hasClientId("TheRegistrar");
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_badClaimsNotice() throws Exception {
|
|
thrown.expect(IllegalArgumentException.class);
|
|
runCommand(
|
|
"--id=1-Q9JYB4C",
|
|
"--tcn_id=foobarbaz",
|
|
"--expiration_time=2010-08-16T09:00:00.0Z",
|
|
"--accepted_time=2009-08-16T09:00:00.0Z");
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_claimsNoticeForWrongLabel() throws Exception {
|
|
thrown.expectRootCause(InvalidChecksumException.class);
|
|
domainApplication = persistResource(newDomainApplication("bad-label.xn--q9jyb4c"));
|
|
runCommand(
|
|
"--id=4-Q9JYB4C",
|
|
"--tcn_id=370d0b7c9223372036854775807",
|
|
"--expiration_time=2010-08-16T09:00:00.0Z",
|
|
"--accepted_time=2009-08-16T09:00:00.0Z");
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_sunriseApplication() throws Exception {
|
|
thrown.expect(IllegalArgumentException.class);
|
|
|
|
// Add an encoded signed mark to the application to make it a sunrise application.
|
|
domainApplication = persistResource(domainApplication.asBuilder()
|
|
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "AAAAA")))
|
|
.build());
|
|
|
|
runCommand(
|
|
"--id=1-Q9JYB4C",
|
|
"--tcn_id=370d0b7c9223372036854775807",
|
|
"--expiration_time=2010-08-16T09:00:00.0Z",
|
|
"--accepted_time=2009-08-16T09:00:00.0Z");
|
|
}
|
|
}
|