Package org.pac4j.core.context

Examples of org.pac4j.core.context.MockWebContext


        final String logoutRequest = "<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"LR-1-B2b0CVRW5eSvPBZPsAVXdNPj7jee4SWjr9y\" Version=\"2.0\" IssueInstant=\"2012-12-19T15:30:55Z\"><saml:NameID xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">@NOT_USED@</saml:NameID><samlp:SessionIndex>ST-1-FUUhL26EgrkcD6I2Mry9-cas01.example.org</samlp:SessionIndex></samlp:LogoutRequest>";
        final CasClient casClient = new CasClient();
        casClient.setCallbackUrl(CALLBACK_URL);
        casClient.setCasLoginUrl(LOGIN_URL);
        casClient.init();
        final MockWebContext context = MockWebContext.create().addRequestParameter("logoutRequest", logoutRequest)
            .setRequestMethod("POST");
        try {
            casClient.getCredentials(context);
            fail("should throw RequiresHttpAction");
        } catch (final RequiresHttpAction e) {
            assertEquals(200, context.getResponseStatus());
            assertEquals("logout request : no credential returned", e.getMessage());
        }
    }
View Full Code Here


    }
   
    public void testMissingPgt() {
        final CasProxyReceptor client = new CasProxyReceptor();
        client.setCallbackUrl(CALLBACK_URL);
        final MockWebContext context = MockWebContext.create();
        try {
            client.getCredentials(context.addRequestParameter(CasProxyReceptor.PARAM_PROXY_GRANTING_TICKET, VALUE));
        } catch (final RequiresHttpAction e) {
            assertEquals(200, context.getResponseStatus());
            assertEquals("", context.getResponseContent());
            assertEquals("Missing proxyGrantingTicket or proxyGrantingTicketIou", e.getMessage());
        }
    }
View Full Code Here

    }
   
    public void testMissingPgtiou() {
        final CasProxyReceptor client = new CasProxyReceptor();
        client.setCallbackUrl(CALLBACK_URL);
        final MockWebContext context = MockWebContext.create();
        try {
            client.getCredentials(context.addRequestParameter(CasProxyReceptor.PARAM_PROXY_GRANTING_TICKET_IOU, VALUE));
        } catch (final RequiresHttpAction e) {
            assertEquals(200, context.getResponseStatus());
            assertEquals("", context.getResponseContent());
            assertEquals("Missing proxyGrantingTicket or proxyGrantingTicketIou", e.getMessage());
        }
    }
View Full Code Here

    }
   
    public void testOk() {
        final CasProxyReceptor client = new CasProxyReceptor();
        client.setCallbackUrl(CALLBACK_URL);
        final MockWebContext context = MockWebContext.create()
            .addRequestParameter(CasProxyReceptor.PARAM_PROXY_GRANTING_TICKET, VALUE)
            .addRequestParameter(CasProxyReceptor.PARAM_PROXY_GRANTING_TICKET_IOU, VALUE);
        try {
            client.getCredentials(context);
            fail("should throw RequiresHttpAction");
        } catch (final RequiresHttpAction e) {
            assertEquals(200, context.getResponseStatus());
            assertTrue(context.getResponseContent().length() > 0);
            assertEquals("No credential for CAS proxy receptor -> returns ok", e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.pac4j.core.context.MockWebContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.