@Test
    void verifyActionExternalScript() throws Throwable {
        val script = """
            import org.apereo.cas.authentication.*
            def run(Object[] args) {
               def (authentication, context, applicationContext, logger) = args
               return Optional.of(new AuthenticationException())
            }""";

        val scriptFile = Files.createTempFile("script1", ".groovy").toFile();
        FileUtils.write(scriptFile, script, StandardCharsets.UTF_8);
        val policy = new GroovyScriptAuthenticationPolicy("file:" + scriptFile.getCanonicalPath());
        assertThrows(GeneralSecurityException.class,
            () -> policy.isSatisfiedBy(CoreAuthenticationTestUtils.getAuthentication(), 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