コード例 #1
0
    def test_direct_access(self):
        from pyramid_heroku.client_addr import ClientAddr

        self.request.environ['REMOTE_ADDR'] = '1.2.3.4'
        ClientAddr(self.handler, self.registry)(self.request)
        self.handler.assert_called_with(self.request)
        self.assertEqual(self.request.client_addr, '1.2.3.4')
コード例 #2
0
    def test_spaces(self):
        from pyramid_heroku.client_addr import ClientAddr

        self.request.environ['REMOTE_ADDR'] = '127.0.0.1'  # load balancer
        self.request.headers['X-Forwarded-For'] = ' 6.6.6.6, 1.2.3.4 '

        ClientAddr(self.handler, self.registry)(self.request)
        self.handler.assert_called_with(self.request)
        self.assertEqual(self.request.client_addr, '1.2.3.4')
コード例 #3
0
    def test_spaces(self):
        from pyramid_heroku.client_addr import ClientAddr

        self.request.environ["REMOTE_ADDR"] = "127.0.0.1"  # load balancer
        self.request.headers["X-Forwarded-For"] = " 6.6.6.6, 1.2.3.4 "

        ClientAddr(self.handler, self.registry)(self.request)
        self.handler.assert_called_with(self.request)
        self.assertEqual(self.request.client_addr, "1.2.3.4")