@Test
public void testServiceToken() throws CryptoException {

    String testKeyVersionK1 = "1";
    PrincipalToken serviceTokenToValidate = createServiceToken(testKeyVersionK1);
    // Validate all input data
    assertEquals(serviceTokenToValidate.getVersion(), svcVersion);
    assertEquals(serviceTokenToValidate.getDomain(), svcDomain);
    assertEquals(serviceTokenToValidate.getName(), svcName);
    assertEquals(serviceTokenToValidate.getHost(), host);
    assertEquals(serviceTokenToValidate.getSalt(), salt);
    assertEquals(serviceTokenToValidate.getKeyId(), testKeyVersionK1);
    // Validate the signature and that expiration time had not elapsed
    assertTrue(serviceTokenToValidate.validate(servicePublicKeyStringK1, 300, false));
    // Create ServiceToken with null keyVersion which should default to 0
    serviceTokenToValidate = createServiceToken();
    assertEquals(serviceTokenToValidate.getKeyId(), "0");
    // Validate the signature using key(k0) and that expiration time had not elapsed
    assertTrue(serviceTokenToValidate.validate(servicePublicKeyStringK0, 300, false));
    PrincipalToken svcToken2 = new PrincipalToken(serviceTokenToValidate.getSignedToken());
    assertEquals(svcToken2.getSignedToken(), serviceTokenToValidate.getSignedToken());
}