Esempio n. 1
0
    def test_get_request_basic_auth(self):
        # without auth:
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_SCHEME='https')
        self.assertIsNone(get_request_basic_auth(request))

        # with basic auth:
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_AUTHORIZATION=self.basic_auth('user', 'pass'))
        self.assertEqual(get_request_basic_auth(request), "user:pass")

        # with some other auth
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_AUTHORIZATION="Bearer abcde12345")
        self.assertIsNone(get_request_basic_auth(request))
Esempio n. 2
0
    def test_get_request_basic_auth(self):
        # without auth:
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_SCHEME='https')
        self.assertIsNone(get_request_basic_auth(request))

        # with basic auth:
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_AUTHORIZATION=self.basic_auth('user', 'pass'))
        self.assertEqual(get_request_basic_auth(request), "user:pass")

        # with some other auth
        request = self.request_factory.post('/path/to/?query',
                                            HTTP_HOST='www.example.com',
                                            HTTP_AUTHORIZATION="Bearer abcde12345")
        self.assertIsNone(get_request_basic_auth(request))