@Test
public void signAndValidatePublicPlainKey() {

  synchronized (TestTicketRsaKeyFileProvider.class) {
    TestTicketRsaKeyFileProvider.clean();
    TestTicketRsaKeyFileProvider.files.add(PRIVATE_PLAIN);
    TestTicketRsaKeyFileProvider.isFilesWithPrivateKeyAreRequired = true;
    startNewContext();
    // GIVEN
    Ticket t = new Ticket();
    t.setClaim(new TicketClaim());
    t.getClaim().setTicketId(RUuidUtil.toRUuid(UUID.randomUUID()));
    t.getClaim().setUsername("abc");
    t.getClaim().setValidUntil(123);
    t.getClaim().setIsSuperUser(false);
    ticketSignatureService.signTicket(t);
    // WHEN
    TestTicketRsaKeyFileProvider.clean();
    TestTicketRsaKeyFileProvider.files.add(PUBLIC_PLAIN);
    TestTicketRsaKeyFileProvider.isFilesWithPrivateKeyAreRequired = false;
    startNewContext();
    boolean isValid = isValid(t);
    // THEN
    Assert.assertTrue(isValid, "Ticket should be valid.");
  }
}