summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2009-04-14 12:46:00 +0000
committerGravatar Karl Ramm <kcr@1ts.org>2009-04-14 12:46:00 +0000
commit3dd9abb58c23e7441fa6019fb00992d017ac6a36 (patch)
tree2ff3be2d55f71869343c0ebe6cb134b3e5222360 /lib
parentd95a96414d5d0c27d994f4b638491d27b6725707 (diff)
Export a new variable, Zauthtype, which indicates what sort of authentication
the library was compiled for. Use this variable in the tests such that they will pass (and, like, test something) if the library was not compiled with authentication.
Diffstat (limited to 'lib')
-rw-r--r--lib/ZInit.c8
-rwxr-xr-xlib/zephyr_tests.py24
-rw-r--r--lib/zephyr_tests.txt11
3 files changed, 36 insertions, 7 deletions
diff --git a/lib/ZInit.c b/lib/ZInit.c
index 42ef2ad..d37ba04 100644
--- a/lib/ZInit.c
+++ b/lib/ZInit.c
@@ -38,6 +38,14 @@ static const char rcsid_ZInitialize_c[] =
static int z_get_host_realm_replacement(char *, char ***);
#endif
+#if defined(HAVE_KRB5)
+int Zauthtype = 5;
+#elif defined(HAVE_KRB4)
+int Zauthtype = 4;
+#else
+int Zauthtype = 0;
+#endif
+
Code_t
ZInitialize(void)
{
diff --git a/lib/zephyr_tests.py b/lib/zephyr_tests.py
index 2795ba3..041c2de 100755
--- a/lib/zephyr_tests.py
+++ b/lib/zephyr_tests.py
@@ -332,6 +332,9 @@ class libZephyr(object):
library_path = ctypes.util.find_library("zephyr")
self._lib = ctypes.cdll.LoadLibrary(library_path)
+ # grab the Zauthtype variable
+ self.Zauthtype = ctypes.c_int.in_dll(self._lib, 'Zauthtype').value
+
# generic bindings?
for funcname in self.testable_funcs:
setattr(self, funcname, getattr(self._lib, funcname))
@@ -427,8 +430,12 @@ class ZephyrTestSuite(TestSuite):
print "fd", self._libzephyr.ZGetFD()
realm = self._libzephyr.ZGetRealm()
print "realm", realm
- if not realm or realm == "local-realm":
+ if not realm:
+ raise TestFailure("empty realm %s" % realm)
+ if self._libzephyr.Zauthtype and realm == 'local-realm':
raise TestFailure("useless realm %s" % realm)
+ if self._libzephyr.Zauthtype == 0 and realm != 'local-realm':
+ raise TestFailure("wrong realm %s (should be local-realm)" % realm)
print self._libzephyr.ZGetSender()
def test_notices(self):
@@ -470,11 +477,20 @@ class ZephyrTestSuite(TestSuite):
assert not self._libzephyr.ZCompareUID(notice1.z_uid, notice2.z_uid), "distinct notices don't compare as distinct"
# ctypes_pprint(notice1.z_uid)
+ def test_zauthtype(self):
+ """Make sure Zauthtype is an acceptable value"""
+ assert self._libzephyr.Zauthtype in (0, 4, 5)
+
def test_z_expand_realm(self):
"""test ZExpandRealm"""
- assert self._libzephyr.ZExpandRealm("") == ""
- assert self._libzephyr.ZExpandRealm("localhost") == ""
- assert self._libzephyr.ZExpandRealm("bitsy.mit.edu") == "ATHENA.MIT.EDU"
+ if self._libzephyr.Zauthtype:
+ assert self._libzephyr.ZExpandRealm("") == ""
+ assert self._libzephyr.ZExpandRealm("localhost") == ""
+ assert self._libzephyr.ZExpandRealm("bitsy.mit.edu") == "ATHENA.MIT.EDU"
+ else:
+ assert self._libzephyr.ZExpandRealm("") == ""
+ assert self._libzephyr.ZExpandRealm("localhost") == "LOCALHOST"
+ assert self._libzephyr.ZExpandRealm("bitsy.mit.edu") == "BITSY.MIT.EDU"
def find_buildpath():
parser = optparse.OptionParser(usage=__doc__,
diff --git a/lib/zephyr_tests.txt b/lib/zephyr_tests.txt
index 086d460..c817aa1 100644
--- a/lib/zephyr_tests.txt
+++ b/lib/zephyr_tests.txt
@@ -24,9 +24,12 @@ ZInit() got run by libZephyr, internally. Make sure other things
actually got set up:
>>> assert _z.ZGetFD() == -1
+ >>> Zauthtype = _z.Zauthtype
+ >>> assert Zauthtype in (0, 4, 5)
>>> realm = _z.ZGetRealm()
>>> assert realm
- >>> assert realm != "local-realm"
+ >>> if Zauthtype: assert realm != 'local-realm'
+ >>> if not Zauthtype: assert realm == 'local-realm'
>>> assert _z.ZGetSender()
>>> assert "@" in _z.ZGetSender()
@@ -76,8 +79,10 @@ ZNotice_t as the constructor...
Trivial test of ZExpandRealm, using terribly well known hostnames:
>>> assert _z.ZExpandRealm("") == ""
- >>> assert _z.ZExpandRealm("localhost") == ""
- >>> assert _z.ZExpandRealm("bitsy.mit.edu") == "ATHENA.MIT.EDU"
+ >>> if Zauthtype: assert _z.ZExpandRealm("localhost") == ""
+ >>> if Zauthtype: assert _z.ZExpandRealm("bitsy.mit.edu") == "ATHENA.MIT.EDU"
+ >>> if not Zauthtype: assert _z.ZExpandRealm("localhost") == "LOCALHOST"
+ >>> if not Zauthtype: assert _z.ZExpandRealm("bitsy.mit.edu") == "BITSY.MIT.EDU"
Trivial test of ZopenPort and ZClosePort: