@Test
public void testGetJWSDomain() throws JsonProcessingException {

    final String domainName = "jws-domain";
    // create multiple top level domains
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName,
            "Test Domain1", "testOrg", adminUser);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    JWSDomain jwsDomain = zms.getJWSDomain(mockDomRsrcCtx, domainName);
    assertNotNull(jwsDomain);
    final Base64.Decoder decoder = Base64.getUrlDecoder();
    final String payload = jwsDomain.getPayload();
    final String protectedHeader = jwsDomain.getProtectedHeader();
    assertEquals(new String(decoder.decode(protectedHeader.getBytes(StandardCharsets.UTF_8))), "{\"alg\":\"RS256\"}");
    final String data = protectedHeader + "." + payload;
    final byte[] sig = decoder.decode(jwsDomain.getSignature().getBytes(StandardCharsets.UTF_8));
    // verify the signature
    assertTrue(Crypto.verify(data.getBytes(StandardCharsets.UTF_8),
            Crypto.extractPublicKey(zms.privateKey.getKey()), sig, Crypto.SHA256));
    final String jsonDomain = new String(decoder.decode(payload));
    DomainData domainData = zms.jsonMapper.readValue(jsonDomain, DomainData.class);
    assertNotNull(domainData);
    assertEquals(domainData.getName(), "jws-domain");
    Map<String, String> header = jwsDomain.getHeader();
    assertEquals(header.get("keyid"), "0");
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}