def test_authenticate_with_valid_user(self):
     """
     Verify authenticate works with a proper JSON file, Authorization header, and a matching user.
     """
     self.http_basic_auth = httpbasicauth.HTTPBasicAuth(
         None, self.user_config)
     environ = create_environ(headers={'HTTP_AUTHORIZATION': 'basic YTph'})
     self.assertEquals(
         True, self.http_basic_auth.authenticate(environ, mock.MagicMock()))
 def test_authenticate_with_invalid_password(self):
     """
     Verify authenticate denies with a proper JSON file, Authorization header, and the wrong password.
     """
     self.http_basic_auth = httpbasicauth.HTTPBasicAuth(
         None, self.user_config)
     environ = create_environ(
         headers={'HTTP_AUTHORIZATION': 'basic YTpiCg=='})
     self.assertEquals(
         False, self.http_basic_auth.authenticate(environ,
                                                  mock.MagicMock()))
 def setUp(self):
     """
     Sets up a fresh instance of the class before each run.
     """
     self.user_config = get_fixture_file_path('conf/users.json')
     self.http_basic_auth = httpbasicauth.HTTPBasicAuth(self.user_config)
 def setUp(self):
     """
     Sets up a fresh instance of the class before each run.
     """
     # Empty users dict prevents it from trying to load from etcd.
     self.http_basic_auth = httpbasicauth.HTTPBasicAuth(None, users={})
Example #5
0
 def setUp(self):
     """
     Sets up a fresh instance of the class before each run.
     """
     self.http_basic_auth = httpbasicauth.HTTPBasicAuth(None, users={})