Search in sources :

Example 1 with RestfulInterruptProperties

use of org.apereo.cas.configuration.model.support.interrupt.RestfulInterruptProperties in project cas by apereo.

the class RestEndpointInterruptInquirerTests method verifyResponseCanBeFoundFromRest.

@Test
public void verifyResponseCanBeFoundFromRest() {
    val restProps = new RestfulInterruptProperties();
    restProps.setUrl("http://localhost:8888");
    val context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    request.addHeader("accept-language", "fr");
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
    val q = new RestEndpointInterruptInquirer(restProps);
    val response = q.inquire(CoreAuthenticationTestUtils.getAuthentication("casuser"), CoreAuthenticationTestUtils.getRegisteredService(), CoreAuthenticationTestUtils.getService(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), context);
    assertNotNull(response);
    assertTrue(response.isBlock());
    assertTrue(response.isSsoEnabled());
    assertEquals(2, response.getLinks().size());
    assertEquals(getClass().getSimpleName(), response.getMessage());
}
Also used : lombok.val(lombok.val) RestfulInterruptProperties(org.apereo.cas.configuration.model.support.interrupt.RestfulInterruptProperties) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Example 2 with RestfulInterruptProperties

use of org.apereo.cas.configuration.model.support.interrupt.RestfulInterruptProperties in project cas by apereo.

the class RestEndpointInterruptInquirerTests method verifyBadAttempt.

@Test
public void verifyBadAttempt() {
    val restProps = new RestfulInterruptProperties();
    restProps.setUrl("http://localhost:8888");
    val context = new MockRequestContext();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
    val q = new RestEndpointInterruptInquirer(restProps);
    val response = q.inquire(null, CoreAuthenticationTestUtils.getRegisteredService(), CoreAuthenticationTestUtils.getService(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), context);
    assertFalse(response.isInterrupt());
}
Also used : lombok.val(lombok.val) RestfulInterruptProperties(org.apereo.cas.configuration.model.support.interrupt.RestfulInterruptProperties) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)2 RestfulInterruptProperties (org.apereo.cas.configuration.model.support.interrupt.RestfulInterruptProperties)2 Test (org.junit.jupiter.api.Test)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)2 MockRequestContext (org.springframework.webflow.test.MockRequestContext)2