mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Display created domain name in get_allocation_token command
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240212479
This commit is contained in:
parent
64edf25fbe
commit
4fb0021b14
2 changed files with 82 additions and 16 deletions
|
@ -14,12 +14,17 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.DatastoreHelper.createHistoryEntryForEppResource;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistSimpleResources;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
@ -33,20 +38,43 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
|||
persistResource(
|
||||
new AllocationToken.Builder().setToken("foo").setDomainName("foo.bar").build());
|
||||
runCommand("foo");
|
||||
assertInStdout(token.toHydratedString());
|
||||
assertInStdout(token.toString(), "Token foo was not redeemed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipleTokens() throws Exception {
|
||||
ImmutableList<AllocationToken> tokens = persistSimpleResources(
|
||||
ImmutableList.of(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("fee")
|
||||
.setCreationTimeForTest(DateTime.parse("2015-04-07T22:19:17.044Z"))
|
||||
.build(),
|
||||
new AllocationToken.Builder().setToken("fii").setDomainName("bar.baz").build()));
|
||||
ImmutableList<AllocationToken> tokens =
|
||||
persistSimpleResources(
|
||||
ImmutableList.of(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("fee")
|
||||
.setCreationTimeForTest(DateTime.parse("2015-04-07T22:19:17.044Z"))
|
||||
.build(),
|
||||
new AllocationToken.Builder().setToken("fii").setDomainName("bar.baz").build()));
|
||||
runCommand("fee", "fii");
|
||||
assertInStdout(tokens.get(0).toHydratedString(), tokens.get(1).toHydratedString());
|
||||
assertInStdout(
|
||||
tokens.get(0).toString(),
|
||||
"Token fee was not redeemed.",
|
||||
tokens.get(1).toString(),
|
||||
"Token fii was not redeemed.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_redeemedToken() throws Exception {
|
||||
createTld("tld");
|
||||
DomainBase domain =
|
||||
persistActiveDomain("fqqdn.tld", DateTime.parse("2016-04-07T22:19:17.044Z"));
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("foo")
|
||||
.setDomainName("fqqdn.tld")
|
||||
.setRedemptionHistoryEntry(Key.create(createHistoryEntryForEppResource(domain)))
|
||||
.build());
|
||||
runCommand("foo");
|
||||
assertInStdout(
|
||||
token.toString(),
|
||||
"Token foo was redeemed to create domain fqqdn.tld at 2016-04-07T22:19:17.044Z.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -55,7 +83,10 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
|||
persistResource(
|
||||
new AllocationToken.Builder().setToken("foo").setDomainName("foo.bar").build());
|
||||
runCommand("foo", "bar");
|
||||
assertInStdout(token.toHydratedString(), "Token bar does not exist.");
|
||||
assertInStdout(
|
||||
token.toString(),
|
||||
"Token foo was not redeemed.",
|
||||
"ERROR: Token bar does not exist.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue