Ejemplo n.º 1
0
    def testHttpSessionContextIntegrationFilter(self):
        def start_response():
            pass

        def application(environ, start_response):
            return ["Success"]

        environ = {}
        environ["PATH_INFO"] = "/index.html"

        sessionStrategy = StubSessionStrategy()
        httpSessionContextIntegrationFilter = HttpSessionContextIntegrationFilter(
            sessionStrategy)
        # HttpSessionContextIntegrationFilter expects another filter after it to alter the credentials.
        stubAuthenticationFilter = StubAuthenticationFilter()

        filterChainProxy = FilterChainProxy()
        filterChainProxy.filterInvocationDefinitionSource = [
            ("/.*",
             [httpSessionContextIntegrationFilter, stubAuthenticationFilter])
        ]
        filterChainProxy.application = application

        self.assertEquals(["Success"],
                          filterChainProxy(environ, start_response))
        self.assertEquals(["Success"],
                          filterChainProxy(environ, start_response))

        httpSession = sessionStrategy.getHttpSession(environ)
        httpSession[httpSessionContextIntegrationFilter.
                    SPRINGPYTHON_SECURITY_CONTEXT_KEY] = pickle.dumps(
                        "Bad credentials")
        self.assertEquals(["Success"],
                          filterChainProxy(environ, start_response))
Ejemplo n.º 2
0
    def testIteratingThroughASimpleFilterChain(self):
        filterChain = FilterChain()
        self.assertEquals(0, len(filterChain.chain))

        httpSessionContextIntegrationFilter = HttpSessionContextIntegrationFilter(
        )
        exceptionTranslationFilter = ExceptionTranslationFilter()
        authenticationProcessFilter = AuthenticationProcessingFilter()
        filterSecurityInterceptor = FilterSecurityInterceptor()

        filterChain.addFilter(httpSessionContextIntegrationFilter)
        filterChain.addFilter(exceptionTranslationFilter)
        filterChain.addFilter(authenticationProcessFilter)
        filterChain.addFilter(filterSecurityInterceptor)

        chain = filterChain.getFilterChain()
        self.assertEquals(httpSessionContextIntegrationFilter, chain.next())
        self.assertEquals(exceptionTranslationFilter, chain.next())
        self.assertEquals(authenticationProcessFilter, chain.next())
        self.assertEquals(filterSecurityInterceptor, chain.next())
        self.assertRaises(StopIteration, chain.next)
Ejemplo n.º 3
0
 def httpContextFilter(self):
     filter = HttpSessionContextIntegrationFilter()
     filter.sessionStrategy = self.cherrypySessionStrategy()
     return filter
Ejemplo n.º 4
0
 def httpSessionContextIntegrationFilter(self):
     """This filter is used to move SecurityContext to/from the HttpSession of the web requests."""
     filter = HttpSessionContextIntegrationFilter()
     filter.sessionStrategy = self.cherrypySessionStrategy()
     return filter
Ejemplo n.º 5
0
 def httpSessionContextIntegrationFilter(self):
     """This filter is used to move SecurityContext to/from the HttpSession of the web requests."""
     filter = HttpSessionContextIntegrationFilter()
     filter.sessionStrategy = self.cherrypySessionStrategy()
     return filter
Ejemplo n.º 6
0
 def httpContextFilter(self):
     filter = HttpSessionContextIntegrationFilter()
     filter.sessionStrategy = self.cherrypySessionStrategy()
     return filter