mirror of
https://github.com/google/nomulus.git
synced 2025-05-30 01:10:14 +02:00
Increase default allocation token length to 16
16 is consistent with how we've generated codes for anchor tenants in the past. Also gets rid of a space in the output so that it's a fully valid CSV. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208106631
This commit is contained in:
parent
32ed197103
commit
e5b407cab4
2 changed files with 13 additions and 12 deletions
|
@ -71,9 +71,9 @@ public class GenerateAllocationTokensCommand implements RemoteApiCommand {
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"-l", "--length"},
|
names = {"-l", "--length"},
|
||||||
description = "The length of each token, exclusive of the prefix (if specified); defaults to 12"
|
description = "The length of each token, exclusive of the prefix (if specified); defaults to 16"
|
||||||
)
|
)
|
||||||
private int tokenLength = 12;
|
private int tokenLength = 16;
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"--dry_run"},
|
names = {"--dry_run"},
|
||||||
|
@ -84,7 +84,7 @@ public class GenerateAllocationTokensCommand implements RemoteApiCommand {
|
||||||
@Inject Retrier retrier;
|
@Inject Retrier retrier;
|
||||||
|
|
||||||
private static final int BATCH_SIZE = 20;
|
private static final int BATCH_SIZE = 20;
|
||||||
private static final Joiner SKIP_NULLS = Joiner.on(", ").skipNulls();
|
private static final Joiner SKIP_NULLS = Joiner.on(',').skipNulls();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class GenerateAllocationTokensCommandTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_defaults() throws Exception {
|
public void testSuccess_defaults() throws Exception {
|
||||||
runCommand("--number", "1");
|
runCommand("--number", "1");
|
||||||
assertAllocationTokens(createToken("123456789ABC", null, null));
|
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||||
assertInStdout("123456789ABC");
|
assertInStdout("123456789ABCDEFG");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -87,15 +87,15 @@ public class GenerateAllocationTokensCommandTest
|
||||||
.when(spyCommand)
|
.when(spyCommand)
|
||||||
.saveTokens(Mockito.any());
|
.saveTokens(Mockito.any());
|
||||||
runCommand("--number", "1");
|
runCommand("--number", "1");
|
||||||
assertAllocationTokens(createToken("123456789ABC", null, null));
|
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||||
assertInStdout("123456789ABC");
|
assertInStdout("123456789ABCDEFG");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_tokenCollision() throws Exception {
|
public void testSuccess_tokenCollision() throws Exception {
|
||||||
AllocationToken existingToken =
|
AllocationToken existingToken =
|
||||||
persistResource(new AllocationToken.Builder().setToken("DEADBEEF123456789ABC").build());
|
persistResource(new AllocationToken.Builder().setToken("DEADBEEF123456789ABC").build());
|
||||||
runCommand("--number", "1", "--prefix", "DEADBEEF");
|
runCommand("--number", "1", "--prefix", "DEADBEEF", "--length", "12");
|
||||||
assertAllocationTokens(existingToken, createToken("DEADBEEFDEFGHJKLMNPQ", null, null));
|
assertAllocationTokens(existingToken, createToken("DEADBEEFDEFGHJKLMNPQ", null, null));
|
||||||
assertInStdout("DEADBEEFDEFGHJKLMNPQ");
|
assertInStdout("DEADBEEFDEFGHJKLMNPQ");
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,11 @@ public class GenerateAllocationTokensCommandTest
|
||||||
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nbaz9.tld\n");
|
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nbaz9.tld\n");
|
||||||
runCommand("--domain_names_file", domainNamesFile.getPath());
|
runCommand("--domain_names_file", domainNamesFile.getPath());
|
||||||
assertAllocationTokens(
|
assertAllocationTokens(
|
||||||
createToken("123456789ABC", null, "foo1.tld"),
|
createToken("123456789ABCDEFG", null, "foo1.tld"),
|
||||||
createToken("DEFGHJKLMNPQ", null, "boo2.tld"),
|
createToken("HJKLMNPQRSTUVWXY", null, "boo2.tld"),
|
||||||
createToken("RSTUVWXYZabc", null, "baz9.tld"));
|
createToken("Zabcdefghijkmnop", null, "baz9.tld"));
|
||||||
assertInStdout("foo1.tld, 123456789ABC\nboo2.tld, DEFGHJKLMNPQ\nbaz9.tld, RSTUVWXYZabc");
|
assertInStdout(
|
||||||
|
"foo1.tld,123456789ABCDEFG\nboo2.tld,HJKLMNPQRSTUVWXY\nbaz9.tld,Zabcdefghijkmnop");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue