@Test
    void verifyRejectAuthnWithCredential() throws Throwable {
        val scriptFile = Files.createTempFile("script3", ".groovy").toFile();
        val script = IOUtils.toString(new ClassPathResource("GroovyAuthnPolicy.groovy").getInputStream(), StandardCharsets.UTF_8);
        FileUtils.write(scriptFile, script, StandardCharsets.UTF_8);
        val policy = new GroovyScriptAuthenticationPolicy("file:" + scriptFile.getCanonicalPath());
        val authentication = CoreAuthenticationTestUtils.getAuthentication();
        authentication.getCredentials().getFirst().getCredentialMetadata().putProperty("mustFail", "true");
        assertThrows(GeneralSecurityException.class, () -> policy.isSatisfiedBy(authentication, mock(ConfigurableApplicationContext.class)));
    }
This is {@link GroovyScriptAuthenticationPolicyTests}.

@author Misagh Moayyed
@since 5.3.0
core/cas-server-core-authentication-api/src/test/java/org/apereo/cas/authentication/policy/GroovyScriptAuthenticationPolicyTests.java