@Test
    public void shouldFailWithWrongToken() throws NoSuchAlgorithmException {
        String encoded = new JWSBuilder().kid(KeyUtils.createKeyId(idpPair.getPublic())).jsonContent(token).rsa256(KeyPairGenerator.getInstance("RSA").generateKeyPair().getPrivate());

        config.setRealmCertificateString(null);
        config.setRealm("http://localhost:1080/auth/realms/apiman-realm");

        apiRequest.getQueryParams().put("access_token", encoded);
        keycloakOauthPolicy.apply(apiRequest, mContext, config, mChain);

        verify(mChain, times(1)).doFailure(any(PolicyFailure.class));
        verify(mChain, never()).doApply(any(ApiRequest.class));
    }
Test the {@link KeycloakOauthPolicy}.

With thanks to the Keycloak project for their RSAVerifierTest whose setup procedures are adapted here for
our requirements.

@author Marc Savy {@literal <msavy@redhat.com>}
plugins/keycloak-oauth-policy/src/test/java/io/apiman/plugins/keycloak_oauth_policy/KeycloakOauthPolicyTest.java