Skip to content

Commit baf926c

Browse files
Add version-checking and don't test known-broken on 1.10
This adds a version checking decorator. It disables two tests for MIT versions <1.11 that are known-broken due to token handling.
1 parent 75a2b03 commit baf926c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

gssapi/tests/_utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
from gssapi._utils import import_gssapi_extension
22

3+
try:
4+
import commands
5+
get_output = commands.getoutput
6+
except ImportError:
7+
import subprocess
8+
9+
def _get_output(*args, **kwargs):
10+
res = subprocess.check_output(*args, shell=True, **kwargs)
11+
decoded = res.decode('utf-8')
12+
return decoded.strip()
13+
14+
get_output = _get_output
15+
316

417
def _extension_test(extension_name, extension_text):
518
def make_ext_test(func):
@@ -13,3 +26,24 @@ def ext_test(self, *args, **kwargs):
1326
return ext_test
1427

1528
return make_ext_test
29+
30+
31+
_KRB_VERSION = None
32+
33+
34+
def _minversion_test(target_version, problem):
35+
global _KRB_VERSION
36+
if _KRB_VERSION is None:
37+
_KRB_VERSION = get_output("krb5-config --version")
38+
_KRB_VERSION = _KRB_VERSION.split(' ')[-1].split('.')
39+
40+
def make_ext_test(func):
41+
def ext_test(self, *args, **kwargs):
42+
if _KRB_VERSION < target_version.split('.'):
43+
self.skipTest("Your GSSAPI (version %s) is known to have "
44+
"problems with %s" % (_KRB_VERSION, problem))
45+
else:
46+
func(self, *args, **kwargs)
47+
return ext_test
48+
49+
return make_ext_test

gssapi/tests/test_high_level.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from gssapi import raw as gb
1515
from gssapi import _utils as gssutils
1616
from gssapi import exceptions as excs
17-
from gssapi.tests._utils import _extension_test
17+
from gssapi.tests._utils import _extension_test, _minversion_test
1818
from gssapi.tests import k5test as kt
1919

2020

@@ -656,6 +656,7 @@ def test_verify_signature_raise(self):
656656
server_ctx.verify_signature.should_raise(gb.GSSError,
657657
b'other message', mic_token)
658658

659+
@_minversion_test("1.11", "returning tokens")
659660
def test_defer_step_error_on_method(self):
660661
gssctx.SecurityContext.__DEFER_STEP_ERRORS__ = True
661662
bdgs = gb.ChannelBindings(application_data=b'abcxyz')
@@ -671,6 +672,7 @@ def test_defer_step_error_on_method(self):
671672
server_ctx.step(client_token).should_be_a(bytes)
672673
server_ctx.encrypt.should_raise(gb.BadChannelBindingsError, b'test')
673674

675+
@_minversion_test("1.11", "returning tokens")
674676
def test_defer_step_error_on_complete_property_access(self):
675677
gssctx.SecurityContext.__DEFER_STEP_ERRORS__ = True
676678
bdgs = gb.ChannelBindings(application_data=b'abcxyz')

0 commit comments

Comments
 (0)