Ejemplo n.º 1
0
    def test_environ(self):
        environ = {"one": "two", "three": "four"}
        auth = auth_lib.AuthContext({}, environ)
        self.assertNotEqual(context.from_environ(environ).auth, auth)

        context.set_in_environ(
            environ, context.from_environ(environ).replace(auth=auth)
        )
        self.assertEqual(environ["one"], "two")
        self.assertEqual(environ["three"], "four")
        self.assertEqual(context.from_environ(environ).auth, auth)
Ejemplo n.º 2
0
    def test_environ(self):
        environ = {"one": "two", "three": "four"}
        auth = auth_lib.AuthContext({}, environ)
        req_context = context.from_environ(environ)
        self.assertNotEqual(req_context.auth, auth)
        self.assertNotEqual(req_context.remote_ip, REMOTE_IP)
        self.assertNotEqual(req_context.x_forwarded_for, X_FORWARDED_FOR_IPS)

        context.set_in_environ(
            environ,
            context.from_environ(environ).replace(
                auth=auth,
                remote_ip=REMOTE_IP,
                x_forwarded_for=X_FORWARDED_FOR_IPS,
            ),
        )
        self.assertEqual(environ["one"], "two")
        self.assertEqual(environ["three"], "four")
        req_context = context.from_environ(environ)
        self.assertEqual(req_context.auth, auth)
        self.assertEqual(req_context.remote_ip, REMOTE_IP)
        self.assertEqual(req_context.x_forwarded_for, X_FORWARDED_FOR_IPS)
Ejemplo n.º 3
0
 def wrapper(environ, start_response):
     environ = dict(environ)
     auth_ctx = auth.AuthContext(auth_providers, environ)
     ctx = context.from_environ(environ).replace(auth=auth_ctx)
     context.set_in_environ(environ, ctx)
     return wsgi_app(environ, start_response)
Ejemplo n.º 4
0
 def test_context(self):
     ctx = context.RequestContext()
     environ = {}
     context.set_in_environ(environ, ctx)
     self.assertEqual(context.from_environ(environ), ctx)