Add basic AllocationToken validation/redemption for domain creates

The next step is to add them for domain checks as well (which is simpler
because it doesn't involve validation).

This requires the addition of a TrimWhitespaceAdapter for XML JAXB objects,
which will prove useful for other @XmlValue attributes in the future.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=181526726
This commit is contained in:
mcilwain 2018-01-10 15:27:07 -08:00 committed by Ben McIlwain
parent 646dcecd7e
commit e07d011bc6
11 changed files with 246 additions and 16 deletions

View file

@ -72,4 +72,12 @@ public class AllocationTokenTest extends EntityTestCase {
() -> builder.setCreationTime(DateTime.parse("2010-11-13T05:00:00Z")));
assertThat(thrown).hasMessageThat().isEqualTo("creationTime can only be set once");
}
@Test
public void testSetToken_cantCallMoreThanOnce() throws Exception {
AllocationToken.Builder builder = new AllocationToken.Builder().setToken("foobar");
IllegalStateException thrown =
expectThrows(IllegalStateException.class, () -> builder.setToken("barfoo"));
assertThat(thrown).hasMessageThat().isEqualTo("token can only be set once");
}
}