@Test
    @Configuration("{\r\n" +
            "    \"realm\" : \"TestRealm\",\r\n" +
            "    \"forwardIdentityHttpHeader\" : \"X-Authenticated-Identity\",\r\n" +
            "    \"staticIdentity\" : {\r\n" +
            "      \"identities\" : [\r\n" +
            "        { \"username\" : \"ckent\", \"password\" : \"ckent123!\" },\r\n" +
            "        { \"username\" : \"bwayne\", \"password\" : \"bwayne123!\" },\r\n" +
            "        { \"username\" : \"dprince\", \"password\" : \"dprince123!\" }\r\n" +
            "      ]\r\n" +
            "    }\r\n" +
            "}")
    public void testStatic() throws Throwable {
        PolicyTestRequest request = PolicyTestRequest.build(PolicyTestRequestType.GET, "/some/resource");

        // Failure
        try {
            send(request);
            Assert.fail("Expected a failure response!");
        } catch (PolicyFailureError failure) {
            PolicyFailure policyFailure = failure.getFailure();
            Assert.assertNotNull(policyFailure);
            Assert.assertEquals(PolicyFailureType.Authentication, policyFailure.getType());
            Assert.assertEquals(10004, policyFailure.getFailureCode());
        }

        // Failure
        try {
            request.basicAuth("ckent", "invalid_password");
            send(request);
            Assert.fail("Expected a failure response!");
        } catch (PolicyFailureError failure) {
            PolicyFailure policyFailure = failure.getFailure();
            Assert.assertNotNull(policyFailure);
            Assert.assertEquals(PolicyFailureType.Authentication, policyFailure.getType());
            Assert.assertEquals(10003, policyFailure.getFailureCode());
        }

        // Success
        request.basicAuth("ckent", "ckent123!");
        PolicyTestResponse response = send(request);
        Assert.assertEquals(200, response.code());
        EchoResponse echo = response.entity(EchoResponse.class);
        Assert.assertNotNull(echo);
        String header = echo.getHeaders().get("X-Authenticated-Identity");
        Assert.assertNotNull(header);
        Assert.assertEquals("ckent", header);
    }
Unit test.

@author eric.wittmann@redhat.com
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/BasicAuthenticationPolicyTest.java