update test_krbv.py for requests_kerberos.__version__ checking
This commit is contained in:
parent
80b4bd1ad6
commit
4d70642217
1 changed files with 14 additions and 6 deletions
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import six
|
||||
import unittest
|
||||
|
||||
# This is python-mock, not the rpm mock tool we know and love
|
||||
|
|
@ -18,12 +20,18 @@ class KrbVTestCase(unittest.TestCase):
|
|||
with self.assertRaises(ImportError):
|
||||
session.krb_login()
|
||||
|
||||
@mock.patch('koji.krbV', autospec=True)
|
||||
@mock.patch('koji.krbV', create=True)
|
||||
@mock.patch('requests_kerberos.__version__', new='0.7.0')
|
||||
def test_krbv_old_requests_kerberos(self, krbV_mock):
|
||||
"""Test that when krbV and gssapi are absent, we behave rationally"""
|
||||
@mock.patch('koji.ClientSession._serverPrincipal')
|
||||
def test_krbv_old_requests_kerberos(self, _serverPrincipal_mock, krbV_mock):
|
||||
self.assertIsNotNone(koji.krbV)
|
||||
ctx = koji.krbV.default_context.return_value
|
||||
ctx.mk_req = mock.MagicMock()
|
||||
ac = mock.MagicMock()
|
||||
ctx.mk_req.return_value = (ac, six.b('req'))
|
||||
ac.rd_priv = mock.MagicMock(return_value='session-id session-key')
|
||||
session = koji.ClientSession('whatever')
|
||||
with self.assertRaises(koji.AuthError) as cm:
|
||||
session.krb_login(principal='any@somewhere.com')
|
||||
self.assertEqual(cm.exception.args[0], 'cannot specify a principal without a keytab')
|
||||
session._callMethod = mock.MagicMock(
|
||||
return_value=(base64.encodestring(six.b('a')), base64.encodestring(six.b('b')), [0, 1, 2, 3]))
|
||||
rv = session.krb_login(principal='any@SOMEWHERE.COM', keytab='/path/to/keytab')
|
||||
self.assertTrue(rv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue