Merge pull request #10048 from hulu/auth_test_update

Test case where auth loader is called with no auth type specified
This commit is contained in:
Thomas S Hatch 2014-01-31 09:41:43 -08:00
commit 0be2ce9132

View File

@ -26,15 +26,24 @@ class LoadAuthTestCase(TestCase):
'test_password': '',
'eauth': 'pam'}
# To to see if we bail if the eauth key isn't there
ret = self.lauth.load_name({})
self.assertEqual(ret, '', "Did not bail when eauth key was missing")
# Test a case where the loader auth doesn't have the auth type
# ret = self.lauth.load_name(valid_eauth_load)
# self.assertEqual(ret, '', "Did not bail when the auth loader didn't have the auth type.")
without_auth_type = dict(valid_eauth_load)
without_auth_type.pop('eauth')
ret = self.lauth.load_name(without_auth_type)
self.assertEqual(ret, '', "Did not bail when the auth loader didn't have the auth type.")
# Test a case with valid params
with patch('salt.utils.format_call') as format_call_mock:
expected_ret = call('fake_func_str', {'username': 'test_user', 'test_password': '', 'show_timeout': False, 'eauth': 'pam'})
self.lauth.load_name(valid_eauth_load)
expected_ret = call('fake_func_str', {
'username': 'test_user',
'test_password': '',
'show_timeout': False,
'eauth': 'pam'
})
ret = self.lauth.load_name(valid_eauth_load)
format_call_mock.assert_has_calls(expected_ret)
if __name__ == '__main__':
from integration import run_tests
run_tests(LoadAuthTestCase, needs_daemon=False)