private static void assertPolicyFails(final int port, final HttpStatus status,
                                          final Class<? extends Throwable> exceptionClass) {
        val applicationContext = new StaticApplicationContext();
        applicationContext.refresh();

        try (val webServer = new MockWebServer(port,
            new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8), "Output"), status)) {
            webServer.start();
            val props = new RestAuthenticationPolicyProperties();
            props.setUrl("http://localhost:" + port);
            val policy = new RestfulAuthenticationPolicy(props);
            assertThrowsWithRootCause(GeneralSecurityException.class, exceptionClass,
                () -> policy.isSatisfiedBy(CoreAuthenticationTestUtils.getAuthentication("casuser"), applicationContext));
        }
    }
This is {@link RestfulAuthenticationPolicyTests}.

@author Misagh Moayyed
@since 5.2.0
core/cas-server-core-authentication/src/test/java/org/apereo/cas/authentication/policy/RestfulAuthenticationPolicyTests.java