def test_handle_code_failed(self): # Setup response_doc = auth_utils.generate_failure_response(auth_utils.CODE_FAILED) e = exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_authentication_failed.call_count, 1)
def test_handle_code_unknown(self): # Setup response_doc = auth_utils.generate_failure_response('foo') e = bindings_exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_unknown.call_count, 1)
def test_handle_code_username(self): # Setup response_doc = auth_utils.generate_failure_response(auth_utils.CODE_USER_PASS) e = exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_invalid_username.call_count, 1)
def test_handle_code_unknown(self): # Setup response_doc = auth_utils.generate_failure_response('foo') e = exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_unknown.call_count, 1)
def test_handle_code_invalid_ssl_cert(self): # Setup response_doc = auth_utils.generate_failure_response(auth_utils.CODE_INVALID_SSL_CERT) e = bindings_exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_authentication_failed.call_count, 1)
def test_handle_code_username(self): # Setup response_doc = auth_utils.generate_failure_response( auth_utils.CODE_USER_PASS) e = exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_invalid_username.call_count, 1)
def test_handle_code_invalid_ssl_cert(self): # Setup response_doc = auth_utils.generate_failure_response( auth_utils.CODE_INVALID_SSL_CERT) e = exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_authentication_failed.call_count, 1)
def test_permissions(self): """ Tests a client-side permissions error. """ # Test response_body = auth_utils.generate_failure_response(auth_utils.CODE_FAILED) e = exceptions.PermissionsException(response_body) code = self.exception_handler.handle_permission(e) # Verify self.assertEqual(code, handler.CODE_PERMISSIONS_EXCEPTION) self.assertTrue('specified user' in self.recorder.lines[0])
def test_handle_code_failed(self): # Setup response_doc = auth_utils.generate_failure_response( auth_utils.CODE_FAILED) e = bindings_exceptions.PermissionsException(response_doc) # Test code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertEqual(self.handler._handle_authentication_failed.call_count, 1)
def test_permission(self): """ Tests a client-side error when the connection is rejected due to auth reasons. """ # Test response_body = auth_utils.generate_failure_response(auth_utils.CODE_FAILED) e = exceptions.PermissionsException(response_body) code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertTrue('Authentication' in self.recorder.lines[0]) self.assertEqual(TAG_FAILURE, self.prompt.get_write_tags()[0]) self.assertTrue('A valid' in self.recorder.lines[2]) # skip blank line self.assertEqual(TAG_PARAGRAPH, self.prompt.get_write_tags()[1])
def test_permission(self): """ Tests a client-side error when the connection is rejected due to auth reasons. """ # Test response_body = auth_utils.generate_failure_response( auth_utils.CODE_FAILED) e = exceptions.PermissionsException(response_body) code = self.handler.handle_permission(e) # Verify self.assertEqual(code, exceptions.CODE_PERMISSIONS_EXCEPTION) self.assertTrue('Authentication' in self.recorder.lines[0]) self.assertEqual(TAG_FAILURE, self.prompt.get_write_tags()[0]) self.assertTrue('A valid' in self.recorder.lines[2]) # skip blank line self.assertEqual(TAG_PARAGRAPH, self.prompt.get_write_tags()[1])
def __init__(self, error_code=error_codes.PLP0025, **kwargs): super(PulpCodedAuthenticationException, self).__init__(error_code=error_code, **kwargs) # For backwards compatibility, get the old error code self.old_error_code = auth_utils.generate_failure_response(error_code)
def __init__(self, error_code): """ :param error_code: one of the error codes in pulp.common.auth_utils """ super(AuthenticationFailed, self).__init__() self.error_doc = auth_utils.generate_failure_response(error_code)
def __init__(self, error_code): """ :param error_code: one of the error codes in pulp.common.auth_utils """ self.error_doc = auth_utils.generate_failure_response(error_code)