### Question:
JsonWebTokenConfig implements AuthenticationConfig { @Override public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) { final byte[] decodedSecretKey = Base64.getDecoder().decode(secretKey); final Key secretKeyKey = new SecretKeySpec(decodedSecretKey, 0, decodedSecretKey.length, this.getSignatureAlgorithm().toString()); return new JsonWebTokenAuthFilter.Builder<>() .setAuthenticator(new JsonWebTokenAuthenticator(secretKeyKey, this.getSignatureAlgorithm())) .setAuthorizer(new PermitAllAuthorizer()) .buildAuthFilter(); } JsonWebTokenConfig();  JsonWebTokenConfig(String secretKey); String getSecretKey(); SignatureAlgorithm getSignatureAlgorithm(); @Override AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap);  }### Answer:
@Test public void testCreateAuthFilterReturnsAnAuthFilter() { final String secretKey = TestHelpers.generateBase64SecretKey(); final JsonWebTokenConfig jwtConfig = new JsonWebTokenConfig(secretKey); final AuthenticationBootstrap authBootstrap = TestHelpers.createTypicalAuthBootstrap(); final AuthFilter ret = jwtConfig.createAuthFilter(authBootstrap); assertThat(ret).isNotNull(); }
@Test public void testTheReturnedAuthFilterAppliesASecurityContextToAValidRequest() throws IOException { final String secretKey = TestHelpers.generateBase64SecretKey(); final String username = TestHelpers.generateRandomString(); final JsonWebTokenConfig jwtConfig = new JsonWebTokenConfig(secretKey); final AuthenticationBootstrap authBootstrap = TestHelpers.createTypicalAuthBootstrap(); final AuthFilter filter = jwtConfig.createAuthFilter(authBootstrap); final ContainerRequestContext ctx = mock(ContainerRequestContext.class); final String jwt = createJWT(secretKey, username); when(ctx.getHeaderString("Authorization")).thenReturn(String.format("Bearer %s", jwt)); final ArgumentCaptor<SecurityContext> captor = ArgumentCaptor.forClass(SecurityContext.class); filter.filter(ctx); verify(ctx).setSecurityContext(captor.capture()); final SecurityContext capture = captor.getValue(); assertThat(capture.getUserPrincipal().getName()).isEqualTo(username); }