check python-requests-kerberos version before gssapi login
relates: #747
This commit is contained in:
parent
fa5a77b0d4
commit
af1a85841b
2 changed files with 26 additions and 3 deletions
|
|
@ -29,7 +29,9 @@ class TestGSSAPI(unittest.TestCase):
|
|||
retry=False)
|
||||
self.assertEqual(old_environ, dict(**os.environ))
|
||||
|
||||
def test_gssapi_login_keytab(self):
|
||||
@mock.patch('koji.requests_kerberos.__version__', new='0.9.0')
|
||||
@mock.patch('koji.HTTPKerberosAuth')
|
||||
def test_gssapi_login_keytab(self, HTTPKerberosAuth_mock):
|
||||
principal = 'user@EXAMPLE.COM'
|
||||
keytab = '/path/to/keytab'
|
||||
ccache = '/path/to/cache'
|
||||
|
|
@ -39,6 +41,19 @@ class TestGSSAPI(unittest.TestCase):
|
|||
retry=False)
|
||||
self.assertEqual(old_environ, dict(**os.environ))
|
||||
|
||||
@mock.patch('koji.requests_kerberos.__version__', new='0.7.0')
|
||||
def test_gssapi_login_keytab_unsupported_requests_kerberos_version(self):
|
||||
principal = 'user@EXAMPLE.COM'
|
||||
keytab = '/path/to/keytab'
|
||||
ccache = '/path/to/cache'
|
||||
old_environ = dict(**os.environ)
|
||||
with self.assertRaises(koji.PythonImportError) as cm:
|
||||
self.session.gssapi_login(principal, keytab, ccache)
|
||||
self.assertEqual(cm.exception.args[0],
|
||||
'version of python-requests-kerberos(0.7.0) should >= 0.9.0')
|
||||
self.session._callMethod.assert_not_called()
|
||||
self.assertEqual(old_environ, dict(**os.environ))
|
||||
|
||||
def test_gssapi_login_error(self):
|
||||
old_environ = dict(**os.environ)
|
||||
self.session._callMethod.side_effect = Exception('login failed')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue