package com.oreilly.javaxp.cactus.filter;
import org.apache.cactus.FilterTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.client.authentication.BasicAuthentication;
/**
* @author Brian M. Coyner
* $version $Id: TestSecurityFilter.java,v 1.2 2003/02/27 00:24:43 jepc Exp $
*/
public class TestSecurityFilter extends FilterTestCase {
private SecurityFilter filter;
private MockFilterChain mockChain;
public TestSecurityFilter(String name) {
super(name);
}
public void setUp() {
this.filter = new SecurityFilter();
this.mockChain = new MockFilterChain();
}
public void beginAuthenticatedUser(WebRequest webRequest) {
webRequest.setRedirectorName("SecureFilterRedirector");
webRequest.setAuthentication(
new BasicAuthentication("coyner_b", "secret"));
}
public void testAuthenticatedUser() throws Exception {
this.mockChain.setExpectedInvocation(true);
this.filter.doFilter(this.request, this.response, this.mockChain);
this.mockChain.verify();
}
public void testNonAuthenticatedUser() throws Exception {
this.mockChain.setExpectedInvocation(false);
this.filter.doFilter(this.request, this.response, this.mockChain);
this.mockChain.verify();
}
}
|