Package org.apache.ace.authentication.processor.basicauth

Examples of org.apache.ace.authentication.processor.basicauth.BasicHttpAuthenticationProcessor


    /**
     * Tests that a null authentication header will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateEmptyAuthenticationHeaderYieldsNull() {
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here


        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("password"), eq("secret"))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);
       
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("password"), eq("otherSecret"))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);

        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("password"), eq("secret"))).thenReturn(Boolean.TRUE);

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);

        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result != null : "Expected a valid user to be returned!";
       
        assert "bob".equals(user.getName()) : "Expected user bob to be returned!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateNonBase64AuthenticationHeaderYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn("foo");
       
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

    /**
     * Tests that a class cast exception is thrown for invalid context when calling authenticate.
     */
    @Test(groups = { UNIT }, expectedExceptions = ClassCastException.class)
    public void testAuthenticateThrowsClassCastForInvalidContext() {
        new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, new Object());
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateUnknownUserYieldsNull() {
        when(m_servletRequest.getHeader(AUTHORIZATION_HEADER)).thenReturn(createAuthHeaderValue("alice:secret"));
       
        User result = new BasicHttpAuthenticationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Expected no result!";
    }
View Full Code Here

    /**
     * Tests that canHandle yields false for any object other than {@link HttpServletRequest}.
     */
    @Test(groups = { UNIT })
    public void testCanHandleDoesAcceptServletRequest() {
        assert new BasicHttpAuthenticationProcessor().canHandle(mock(HttpServletRequest.class));
    }
View Full Code Here

    /**
     * Tests that canHandle throws an {@link IllegalArgumentException} for an empty context.
     */
    @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class)
    public void testCanHandleDoesNotAcceptEmptyArray() {
        new BasicHttpAuthenticationProcessor().canHandle(new Object[0]);
    }
View Full Code Here

    /**
     * Tests that canHandle throws an {@link IllegalArgumentException} for a null context.
     */
    @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class)
    public void testCanHandleDoesNotAcceptNull() {
        new BasicHttpAuthenticationProcessor().canHandle((Object[]) null);
    }
View Full Code Here

TOP

Related Classes of org.apache.ace.authentication.processor.basicauth.BasicHttpAuthenticationProcessor

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.