|
@@ -12,7 +12,6 @@
|
|
* See the License for the specific language governing permissions and
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* limitations under the License.
|
|
*/
|
|
*/
|
|
-
|
|
|
|
package net.sf.acegisecurity.context;
|
|
package net.sf.acegisecurity.context;
|
|
|
|
|
|
import junit.framework.TestCase;
|
|
import junit.framework.TestCase;
|
|
@@ -22,9 +21,6 @@ import net.sf.acegisecurity.GrantedAuthority;
|
|
import net.sf.acegisecurity.GrantedAuthorityImpl;
|
|
import net.sf.acegisecurity.GrantedAuthorityImpl;
|
|
import net.sf.acegisecurity.MockFilterConfig;
|
|
import net.sf.acegisecurity.MockFilterConfig;
|
|
import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
|
|
import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
|
|
-import net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter;
|
|
|
|
-import net.sf.acegisecurity.context.SecurityContext;
|
|
|
|
-import net.sf.acegisecurity.context.SecurityContextImpl;
|
|
|
|
|
|
|
|
import org.springframework.mock.web.MockHttpServletRequest;
|
|
import org.springframework.mock.web.MockHttpServletRequest;
|
|
import org.springframework.mock.web.MockHttpServletResponse;
|
|
import org.springframework.mock.web.MockHttpServletResponse;
|
|
@@ -46,8 +42,6 @@ import javax.servlet.ServletResponse;
|
|
* @version $Id$
|
|
* @version $Id$
|
|
*/
|
|
*/
|
|
public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
- //~ Constructors ===========================================================
|
|
|
|
-
|
|
|
|
public HttpSessionContextIntegrationFilterTests() {
|
|
public HttpSessionContextIntegrationFilterTests() {
|
|
super();
|
|
super();
|
|
}
|
|
}
|
|
@@ -56,8 +50,6 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
super(arg0);
|
|
super(arg0);
|
|
}
|
|
}
|
|
|
|
|
|
- //~ Methods ================================================================
|
|
|
|
-
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
junit.textui.TestRunner.run(HttpSessionContextIntegrationFilterTests.class);
|
|
junit.textui.TestRunner.run(HttpSessionContextIntegrationFilterTests.class);
|
|
}
|
|
}
|
|
@@ -88,7 +80,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
// Build an Authentication object we simulate came from HttpSession
|
|
// Build an Authentication object we simulate came from HttpSession
|
|
PrincipalAcegiUserToken sessionPrincipal = new PrincipalAcegiUserToken("key",
|
|
PrincipalAcegiUserToken sessionPrincipal = new PrincipalAcegiUserToken("key",
|
|
"someone", "password",
|
|
"someone", "password",
|
|
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_ROLE")});
|
|
|
|
|
|
+ new GrantedAuthority[] { new GrantedAuthorityImpl("SOME_ROLE") });
|
|
|
|
|
|
// Build a Context to store in HttpSession (simulating prior request)
|
|
// Build a Context to store in HttpSession (simulating prior request)
|
|
SecurityContext sc = new SecurityContextImpl();
|
|
SecurityContext sc = new SecurityContextImpl();
|
|
@@ -128,12 +120,14 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
// Build an Authentication object we simulate came from HttpSession
|
|
// Build an Authentication object we simulate came from HttpSession
|
|
PrincipalAcegiUserToken sessionPrincipal = new PrincipalAcegiUserToken("key",
|
|
PrincipalAcegiUserToken sessionPrincipal = new PrincipalAcegiUserToken("key",
|
|
"someone", "password",
|
|
"someone", "password",
|
|
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_ROLE")});
|
|
|
|
|
|
+ new GrantedAuthority[] { new GrantedAuthorityImpl("SOME_ROLE") });
|
|
|
|
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
"someone", "password",
|
|
"someone", "password",
|
|
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")});
|
|
|
|
|
|
+ new GrantedAuthority[] {
|
|
|
|
+ new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")
|
|
|
|
+ });
|
|
|
|
|
|
// Build a Context to store in HttpSession (simulating prior request)
|
|
// Build a Context to store in HttpSession (simulating prior request)
|
|
SecurityContext sc = new SecurityContextImpl();
|
|
SecurityContext sc = new SecurityContextImpl();
|
|
@@ -169,7 +163,9 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
"someone", "password",
|
|
"someone", "password",
|
|
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")});
|
|
|
|
|
|
+ new GrantedAuthority[] {
|
|
|
|
+ new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")
|
|
|
|
+ });
|
|
|
|
|
|
// Build a mock request
|
|
// Build a mock request
|
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
@@ -217,7 +213,9 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
// Build an Authentication object we simulate our Authentication changed it to
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
PrincipalAcegiUserToken updatedPrincipal = new PrincipalAcegiUserToken("key",
|
|
"someone", "password",
|
|
"someone", "password",
|
|
- new GrantedAuthority[] {new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")});
|
|
|
|
|
|
+ new GrantedAuthority[] {
|
|
|
|
+ new GrantedAuthorityImpl("SOME_DIFFERENT_ROLE")
|
|
|
|
+ });
|
|
|
|
|
|
// Build a mock request
|
|
// Build a mock request
|
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
|
@@ -251,8 +249,6 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
filter.destroy();
|
|
filter.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
- //~ Inner Classes ==========================================================
|
|
|
|
-
|
|
|
|
private class MockFilterChain extends TestCase implements FilterChain {
|
|
private class MockFilterChain extends TestCase implements FilterChain {
|
|
private Authentication changeContextHolder;
|
|
private Authentication changeContextHolder;
|
|
private Authentication expectedOnContextHolder;
|
|
private Authentication expectedOnContextHolder;
|
|
@@ -265,7 +261,8 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|
this.toThrowDuringChain = toThrowDuringChain;
|
|
this.toThrowDuringChain = toThrowDuringChain;
|
|
}
|
|
}
|
|
|
|
|
|
- private MockFilterChain() {}
|
|
|
|
|
|
+ private MockFilterChain() {
|
|
|
|
+ }
|
|
|
|
|
|
public void doFilter(ServletRequest arg0, ServletResponse arg1)
|
|
public void doFilter(ServletRequest arg0, ServletResponse arg1)
|
|
throws IOException, ServletException {
|
|
throws IOException, ServletException {
|