krb5 commit: Add URI lookup testing with resolv_wrapper
Greg Hudson
ghudson at mit.edu
Mon Sep 19 12:31:12 EDT 2016
https://github.com/krb5/krb5/commit/26ae4495eededc9854f533b1cb2c0f23160290d8
commit 26ae4495eededc9854f533b1cb2c0f23160290d8
Author: Matt Rogers <mrogers at redhat.com>
Date: Mon Aug 22 15:34:52 2016 -0400
Add URI lookup testing with resolv_wrapper
Run t_discover_uri.py during make check when resolv_wrapper is
available. Remove tabs from the t_locate_kdc output for simpler line
matching.
ticket: 8496
src/config/pre.in | 3 ++
src/configure.in | 8 ++++++
src/lib/krb5/os/Makefile.in | 10 +++++++-
src/lib/krb5/os/t_discover_uri.py | 47 +++++++++++++++++++++++++++++++++++++
src/lib/krb5/os/t_locate_kdc.c | 2 +-
5 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/src/config/pre.in b/src/config/pre.in
index b3678b8..e062632 100644
--- a/src/config/pre.in
+++ b/src/config/pre.in
@@ -448,6 +448,9 @@ TLS_IMPL_LIBS = @TLS_IMPL_LIBS@
# Whether we have the SASL header file for the LDAP KDB module
HAVE_SASL = @HAVE_SASL@
+# Whether we have libresolv 1.1.5 for URI discovery tests
+HAVE_RESOLV_WRAPPER = @HAVE_RESOLV_WRAPPER@
+
# error table rules
#
### /* these are invoked as $(...) foo.et, which works, but could be better */
diff --git a/src/configure.in b/src/configure.in
index 433e9d1..6cca1c3 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1135,6 +1135,14 @@ fi
AC_SUBST(HAVE_CMOCKA)
AC_SUBST(CMOCKA_LIBS)
+# For URI lookup tests. Requires resolv_wrapper >= 1.1.5 for URI
+# support.
+HAVE_RESOLV_WRAPPER=0
+if pkg-config --atleast-version=1.1.5 resolv_wrapper; then
+ HAVE_RESOLV_WRAPPER=1
+fi
+AC_SUBST(HAVE_RESOLV_WRAPPER)
+
# for plugins/kdb/db2
# AIX is unusual in that it wants all symbols resolved at link time
diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in
index 1951235..efa82e2 100644
--- a/src/lib/krb5/os/Makefile.in
+++ b/src/lib/krb5/os/Makefile.in
@@ -200,7 +200,7 @@ lclint-localaddr: localaddr.c
-DTEST $(srcdir)/localaddr.c
check-unix: check-unix-stdconf check-unix-locate check-unix-trace \
- check-unix-expand
+ check-unix-expand check-unix-uri
check-unix-stdconf: t_std_conf
$(RUN_TEST_LOCAL_CONF) ./t_std_conf -d -s NEW.DEFAULT.REALM -d \
@@ -232,6 +232,14 @@ check-unix-locate: t_locate_kdc
echo 'Skipped t_locate_kdc test: OFFLINE' >> $(SKIPTESTS); \
fi
+check-unix-uri: t_locate_kdc
+ if [ $(HAVE_RESOLV_WRAPPER) = 1 ]; then \
+ $(RUNPYTEST) $(srcdir)/t_discover_uri.py $(PYTESTFLAGS); \
+ else \
+ echo '*** WARNING: skipped t_discover_uri.py due to not using resolv_wrapper'; \
+ echo 'Skipped URI discovery tests: resolv_wrapper 1.1.5 not found' >> $(SKIPTESTS); \
+ fi
+
check-unix-trace: t_trace
rm -f t_trace.out
KRB5_TRACE=t_trace.out ; export KRB5_TRACE ; \
diff --git a/src/lib/krb5/os/t_discover_uri.py b/src/lib/krb5/os/t_discover_uri.py
new file mode 100644
index 0000000..278f983
--- /dev/null
+++ b/src/lib/krb5/os/t_discover_uri.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+from k5test import *
+
+entries = ('URI _kerberos.TEST krb5srv::kkdcp:https://kdc1 1 1\n',
+ 'URI _kerberos.TEST krb5srv::kkdcp:https://kdc3:300/path 3 1\n',
+ 'URI _kerberos.TEST krb5srv:m:kkdcp:https://kdc2/path 2 1\n',
+ 'URI _kerberos.TEST KRB5SRV:xMz:UDP:KDC4 4 1\n',
+ 'URI _kerberos.TEST krb5srv:xyz:tcp:192.168.1.6 6 1\n',
+ 'URI _kerberos.TEST krb5srv::tcp:kdc5:500 5 1\n',
+ 'URI _kerberos.TEST krb5srv::tcp:[dead:beef:cafe:7]:700 7 1\n',
+ 'URI _kerberos.TEST bogustag:m:kkdcp:https://bogus 8 1\n',
+ 'URI _kerberos.TEST krb5srv:m:bogustrans:https://bogus 10 1\n',
+ 'URI _kerberos.TEST krb5srv:m:kkdcp:bogus 11 1\n',
+ 'URI _kerberos.TEST krb5srv:m:bogusnotrans 12 1\n')
+
+expected = ('7 servers:',
+ '0: h:kdc1 t:https p:443 m:0 P:',
+ '1: h:kdc2 t:https p:443 m:1 P:path',
+ '2: h:kdc3 t:https p:300 m:0 P:path',
+ '3: h:KDC4 t:udp p:88 m:1 P:',
+ '4: h:kdc5 t:tcp p:500 m:0 P:',
+ '5: h:192.168.1.6 t:tcp p:88 m:0 P:',
+ '6: h:dead:beef:cafe:7 t:tcp p:700 m:0 P:')
+
+conf = {'libdefaults': {'dns_lookup_kdc' : 'true'}}
+
+realm = K5Realm(create_kdb=False, krb5_conf=conf)
+
+hosts_filename = os.path.join(realm.testdir, 'resolv_hosts')
+f = open(hosts_filename, 'w')
+for line in entries:
+ f.write(line)
+f.close()
+
+realm.env['LD_PRELOAD'] = 'libresolv_wrapper.so'
+realm.env['RESOLV_WRAPPER_HOSTS'] = hosts_filename
+
+out = realm.run(['./t_locate_kdc', 'TEST'], env=realm.env)
+l = out.splitlines()
+
+j = 0
+for i in range(4, 12):
+ if l[i].strip() != expected[j]:
+ fail('URI answers do not match')
+ j += 1
+
+success('uri discovery tests')
diff --git a/src/lib/krb5/os/t_locate_kdc.c b/src/lib/krb5/os/t_locate_kdc.c
index 344bb32..6414b8e 100644
--- a/src/lib/krb5/os/t_locate_kdc.c
+++ b/src/lib/krb5/os/t_locate_kdc.c
@@ -58,7 +58,7 @@ print_addrs (void)
char hostbuf[NI_MAXHOST], srvbuf[NI_MAXSERV];
if (entry->hostname != NULL) {
- printf("%2d: host %s\t%s\tport %d\tm:%d\tp:%s\n", (int)i,
+ printf("%d: h:%s t:%s p:%d m:%d P:%s\n", (int)i,
entry->hostname, ttypename(entry->transport),
entry->port, entry->master,
entry->uri_path ? entry->uri_path : "");
More information about the cvs-krb5
mailing list