Class JdkTokenValidatorTest

java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.JdkTokenValidatorTest

@TestInstance(PER_CLASS) @TestMethodOrder(org.junit.jupiter.api.MethodOrderer.OrderAnnotation.class) @ExtendWith(io.vertx.junit5.VertxExtension.class) public class JdkTokenValidatorTest extends Object
Required tests:
  • Invalid structure (not three dots)
  • Invalid structure (first part not base64)
  • Invalid structure (second part not base64)
  • Invalid structure (third part not base64)
  • Invalid structure (first part not JSON)
  • Invalid structure (second part not JSON)
  • Algorithm none
  • Algorithm not in acceptable list (RS256, RS384, RS512) but token otherwise valid
  • Signature invalid
  • Key not in jwks output
  • Token exp value in the past - measure acceptable leeway over < 1 hour
  • Token nbf claim in the future - measure acceptable leeway over < 1 hour
  • Token bad iss accepted - not matching preconfigured values
  • Token bad aud accepted
  • Token aud not accepted when single value despite being the aud for the service
  • Token aud not accepted when single element array despite being the aud for the service
  • Token aud not accepted when first element of array despite being the aud for the service
  • Token aud not accepted when last element of array despite being the aud for the service
  • Token sub not present
Author:
njt
  • Constructor Details

    • JdkTokenValidatorTest

      public JdkTokenValidatorTest(io.vertx.core.Vertx vertx)
  • Method Details

    • init

      @BeforeAll public void init() throws IOException
      Throws:
      IOException
    • shutdown

      @AfterAll public void shutdown() throws IOException
      Throws:
      IOException
    • testValid

      @Test @Order(1) public void testValid(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testInvalidStructureNotThreeParts

      @Test @Order(2) public void testInvalidStructureNotThreeParts(io.vertx.junit5.VertxTestContext testContext)
    • testInvalidStructureFirstPartNotBase64

      @Test @Order(3) public void testInvalidStructureFirstPartNotBase64(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testInvalidStructureSecondPartNotBase64

      @Test @Order(4) public void testInvalidStructureSecondPartNotBase64(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testInvalidStructureThirdPartNotBase64

      @Test @Order(5) public void testInvalidStructureThirdPartNotBase64(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testInvalidStructureFirstPartNotJson

      @Test @Order(6) public void testInvalidStructureFirstPartNotJson(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testInvalidStructureSecondPartNotJson

      @Test @Order(7) public void testInvalidStructureSecondPartNotJson(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testAlgorithmNone

      @Test @Order(8) public void testAlgorithmNone(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testAlgorithmNotRSA

      @Test @Order(9) public void testAlgorithmNotRSA(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testInvalidSignature

      @Test @Order(10) public void testInvalidSignature(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testKeyNotInJwksOutput

      @Test @Order(11) public void testKeyNotInJwksOutput(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testNoExpPermitted

      @Test @Order(13) public void testNoExpPermitted(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testNoExpRejected

      @Test @Order(14) public void testNoExpRejected(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testExpInThePast

      @Test @Order(12) public void testExpInThePast() throws Throwable
      Throws:
      Throwable
    • testNoNbfPermitted

      @Test @Order(13) public void testNoNbfPermitted(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testNoNbfRejected

      @Test @Order(14) public void testNoNbfRejected(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testNbfInTheFuture

      @Test @Order(13) public void testNbfInTheFuture() throws Throwable
      Throws:
      Throwable
    • testBadIssAccepted

      @Test @Order(14) public void testBadIssAccepted(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testBadAudAccepted

      @Test @Order(15) public void testBadAudAccepted(io.vertx.junit5.VertxTestContext testContext) throws Exception
      Throws:
      Exception
    • testAudAcceptedAsSingleElementArray

      @Test @Order(16) public void testAudAcceptedAsSingleElementArray(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testAudAcceptedAsSingleValue

      @Test @Order(17) public void testAudAcceptedAsSingleValue(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testAudAcceptedAsFirstElementOfArray

      @Test @Order(18) public void testAudAcceptedAsFirstElementOfArray(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testAudAcceptedAsLastElementOfArray

      @Test @Order(19) public void testAudAcceptedAsLastElementOfArray(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testNoSubAccepted

      @Test @Order(20) public void testNoSubAccepted(io.vertx.junit5.VertxTestContext testContext) throws Throwable
      Throws:
      Throwable
    • testNoAcceptableIssuers

      @Test @Order(20) public void testNoAcceptableIssuers() throws Throwable
      Throws:
      Throwable