def test_anonymous(self):
     """Test the anonymous user."""
     username, password = None, None
     auth_info = AuthInfo.get(username, password)
     self.assertIsInstance(auth_info, AnonymousAuth)
     req_args = {'foo': 'bar', }
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertEqual(req_args, updated_req_args)
Esempio n. 2
0
 def test_authenticated(self):
     username, password = '******', 'password'
     auth_info = AuthInfo.get(username=username, password=password)
     assert isinstance(auth_info, BasicAuth)
     req_args = {'foo': 'bar'}
     updated_req_args = auth_info.populate_request_data(req_args)
     assert 'foo' in updated_req_args
     assert 'auth' in updated_req_args
     assert auth_info._headers == {}
Esempio n. 3
0
 def test_anonymous(self):
     """Test the anonymous user."""
     username, password = None, None
     auth_info = AuthInfo.get(username, password)
     self.assertIsInstance(auth_info, AnonymousAuth)
     req_args = {
         'foo': 'bar',
     }
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertEqual(req_args, updated_req_args)
Esempio n. 4
0
 def test_anonymous(self):
     """Test the anonymous user."""
     username, password = None, None
     auth_info = AuthInfo.get(username, password)
     assert isinstance(auth_info, AnonymousAuth)
     req_args = {
         'foo': 'bar',
     }
     updated_req_args = auth_info.populate_request_data(req_args)
     assert req_args == updated_req_args
     assert auth_info._headers == {}
Esempio n. 5
0
 def test_authenticated_with_headers(self):
     username, password = '******', 'password'
     headers = {
         'test-header-1': 'test-value-1',
         'test-header-2': 'test-value-2'
     }
     auth_info = AuthInfo.get(username=username,
                              password=password,
                              headers=headers)
     assert isinstance(auth_info, BasicAuth)
     assert auth_info._headers == headers
Esempio n. 6
0
 def test_anonymous_with_headers(self):
     """Test the anonymous user with custom headers."""
     username, password = None, None
     headers = {
         'test-header-1': 'test-value-1',
         'test-header-2': 'test-value-2'
     }
     auth_info = AuthInfo.get(username=username,
                              password=password,
                              headers=headers)
     assert isinstance(auth_info, AnonymousAuth)
     assert auth_info._headers == headers
Esempio n. 7
0
 def test_authenticated(self):
     username, password = '******', 'password'
     auth_info = AuthInfo.get(username=username, password=password)
     self.assertIsInstance(auth_info, BasicAuth)
     req_args = {'foo': 'bar'}
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertIn('foo', updated_req_args)
     self.assertIn('headers', updated_req_args)
     self.assertIn('Authorization', updated_req_args['headers'])
     auth_header = updated_req_args['headers']['Authorization']
     req_args = updated_req_args
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertEqual(auth_header,
                      updated_req_args['headers']['Authorization'])
     req_args = updated_req_args
     req_args['headers'] = {'User-Agent': 'test'}
     updated_req_args = auth_info.populate_request_data(req_args)
     headers = updated_req_args['headers']
     self.assertIn('User-Agent', headers)
     self.assertIn('Authorization', headers)
     self.assertEqual(len(headers.keys()), 2)
 def test_authenticated(self):
     username, password = '******', 'password'
     auth_info = AuthInfo.get(username=username, password=password)
     self.assertIsInstance(auth_info, BasicAuth)
     req_args = {'foo': 'bar'}
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertIn('foo', updated_req_args)
     self.assertIn('headers', updated_req_args)
     self.assertIn('Authorization', updated_req_args['headers'])
     auth_header = updated_req_args['headers']['Authorization']
     req_args = updated_req_args
     updated_req_args = auth_info.populate_request_data(req_args)
     self.assertEqual(
         auth_header, updated_req_args['headers']['Authorization']
     )
     req_args = updated_req_args
     req_args['headers'] = {'User-Agent': 'test'}
     updated_req_args = auth_info.populate_request_data(req_args)
     headers = updated_req_args['headers']
     self.assertIn('User-Agent', headers)
     self.assertIn('Authorization', headers)
     self.assertEqual(len(headers.keys()), 2)
Esempio n. 9
0
    def test_invalid_auth(self):
        with pytest.raises(ValueError):
            AuthInfo.get(username='******')

        with pytest.raises(ValueError):
            AuthInfo.get(password='******')