Search in sources :

Example 1 with GroovyDelegatedClientIdentityProviderRedirectionStrategy

use of org.apereo.cas.pac4j.client.GroovyDelegatedClientIdentityProviderRedirectionStrategy in project cas by apereo.

the class GroovyDelegatedClientIdentityProviderRedirectionStrategyTests method verifyOperation.

@Test
public void verifyOperation() {
    val context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    val response = new MockHttpServletResponse();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
    RequestContextHolder.setRequestContext(context);
    ExternalContextHolder.setExternalContext(context.getExternalContext());
    val provider = DelegatedClientIdentityProviderConfiguration.builder().name("SomeClient").type("CasClient").redirectUrl("https://localhost:8443/redirect").build();
    val service = RegisteredServiceTestUtils.getService();
    val resource = new ClassPathResource("GroovyClientRedirectStrategy.groovy");
    val strategy = new GroovyDelegatedClientIdentityProviderRedirectionStrategy(this.servicesManager, new WatchableGroovyScriptResource(resource));
    assertFalse(strategy.getPrimaryDelegatedAuthenticationProvider(context, service, provider).isEmpty());
    assertEquals(0, strategy.getOrder());
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) WatchableGroovyScriptResource(org.apereo.cas.util.scripting.WatchableGroovyScriptResource) MockRequestContext(org.springframework.webflow.test.MockRequestContext) GroovyDelegatedClientIdentityProviderRedirectionStrategy(org.apereo.cas.pac4j.client.GroovyDelegatedClientIdentityProviderRedirectionStrategy) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) MockServletContext(org.springframework.mock.web.MockServletContext) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)1 GroovyDelegatedClientIdentityProviderRedirectionStrategy (org.apereo.cas.pac4j.client.GroovyDelegatedClientIdentityProviderRedirectionStrategy)1 WatchableGroovyScriptResource (org.apereo.cas.util.scripting.WatchableGroovyScriptResource)1 Test (org.junit.jupiter.api.Test)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)1 MockRequestContext (org.springframework.webflow.test.MockRequestContext)1