summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-01-19 00:37:31 +0000
committerRuss Allbery <rra@stanford.edu>2008-01-19 00:37:31 +0000
commitaa57ab48cc9df24ab756b5651959b36a2d81cad3 (patch)
treeff27773218cb6d2677032d18f6872dd45493b82a /tests
parent275cc7eac5d693bffec19884bf37322df59a871c (diff)
When downloading a keytab to a file that already exists, merge the new
keytab keys into that file rather than moving aside the old keytab and creating a new keytab with only the new keys. Also fix get handling in the client for all types other than keytabs. This isn't visible yet since the server doesn't yet support other types of objects.
Diffstat (limited to 'tests')
-rw-r--r--tests/client/basic-t.in60
-rwxr-xr-xtests/data/cmd-fake30
-rw-r--r--tests/data/fake-keytab-2bin0 -> 334 bytes
-rw-r--r--tests/data/fake-keytab-mergebin0 -> 666 bytes
4 files changed, 57 insertions, 33 deletions
diff --git a/tests/client/basic-t.in b/tests/client/basic-t.in
index b4f539c..d983786 100644
--- a/tests/client/basic-t.in
+++ b/tests/client/basic-t.in
@@ -12,7 +12,7 @@
. "@abs_top_srcdir@/tests/libtest.sh"
# Print the number of tests.
-total=23
+total=27
count=1
echo "$total"
@@ -78,29 +78,29 @@ if [ -z "$krb5conf" ] ; then
fi
# Make sure everything's clean.
-rm -f keytab keytab.bak srvtab srvtab.bak sync-kaserver
+rm -f output output.bak keytab keytab.bak srvtab srvtab.bak sync-kaserver
# Now, we can finally run our tests. First, basic operations.
runsuccess "" "$wallet" -k "$principal" -p 14373 -s localhost -c fake-wallet \
- get keytab -f keytab service/fake-test
-if cmp keytab data/fake-data >/dev/null 2>&1 ; then
+ get file -f output fake-test
+if cmp output data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
-if [ -f keytab.bak ] || [ -f keytab.new ] ; then
+if [ -f output.bak ] || [ -f output.new ] ; then
printcount "not ok"
else
printcount "ok"
fi
runsuccess "" "$wallet" -k "$principal" -p 14373 -s localhost -c fake-wallet \
- get keytab -f keytab service/fake-test
-if cmp keytab data/fake-data >/dev/null 2>&1 ; then
+ get file -f output fake-test
+if cmp output data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
-if [ -f keytab.new ] || [ ! -f keytab.bak ] ; then
+if [ -f output.new ] || [ ! -f output.bak ] ; then
printcount "not ok"
else
printcount "ok"
@@ -118,27 +118,36 @@ cat >> krb5.conf <<EOF
wallet_principal = $principal
}
EOF
-runsuccess "" "$wallet" get keytab -f keytab service/fake-test
-if cmp keytab data/fake-data >/dev/null 2>&1 ; then
+runsuccess "" "$wallet" -f output get file fake-test
+if cmp output data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
+rm -f output output.bak
-# Test srvtab support.
-runsuccess "" "$wallet" get keytab -f keytab -S srvtab service/fake-srvtab
+# Test keytab support.
+runsuccess "" "$wallet" get -f keytab keytab service/fake-srvtab
if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
printcount "ok"
rm keytab
else
printcount "not ok"
fi
-if cmp keytab.bak data/fake-data >/dev/null 2>&1 ; then
+if [ ! -f sync-kaserver ] ; then
printcount "ok"
- rm keytab.bak
else
printcount "not ok"
fi
+
+# Test srvtab support.
+runsuccess "" "$wallet" get keytab -f keytab -S srvtab service/fake-srvtab
+if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
+ printcount "ok"
+else
+ printcount "not ok"
+fi
+rm keytab
if [ -f sync-kaserver ] ; then
printcount "ok"
else
@@ -147,7 +156,6 @@ fi
runsuccess "" "$wallet" get keytab -f keytab -S srvtab service/fake-srvtab
if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
printcount "ok"
- rm keytab
else
printcount "not ok"
fi
@@ -159,26 +167,38 @@ else
fi
if cmp srvtab data/fake-srvtab >/dev/null 2>&1 ; then
printcount "ok"
- rm srvtab
else
printcount "not ok"
fi
if cmp srvtab.bak data/fake-srvtab >/dev/null 2>&1 ; then
printcount "ok"
- rm srvtab.bak
else
printcount "not ok"
fi
+rm -f srvtab srvtab.bak
+
+# Test keytab merging.
+runsuccess "" "$wallet" -f keytab get keytab service/fake-keytab
+(klist -keK keytab 2>&1) | sed '/Keytab name:/d' > klist-seen
+(klist -keK data/fake-keytab-merge 2>&1) | sed '/Keytab name:/d' > klist-good
+if cmp klist-seen klist-good >/dev/null 2>&1 ; then
+ printcount "ok"
+ rm -f keytab klist-seen klist-good
+else
+ printcount "not ok"
+fi
+
+# Test various other client functions and errors.
runsuccess "This is a fake keytab." "$wallet" get keytab service/fake-output
-runsuccess "Some stuff about service/fake-test" \
- "$wallet" show keytab service/fake-test
+runsuccess "Some stuff about file fake-test" \
+ "$wallet" show file fake-test
runfailure 1 "wallet: Unknown object type srvtab" \
"$wallet" get srvtab service/fake-test
runfailure 1 "wallet: Unknown keytab service/unknown" \
"$wallet" show keytab service/unknown
runfailure 1 "wallet: Unknown keytab service/unknown" \
"$wallet" get keytab service/unknown
-runsuccess "Expiration date of service/fake-test" \
+runsuccess "Expiration date of keytab service/fake-test" \
"$wallet" expires keytab service/fake-test
# Clean up.
diff --git a/tests/data/cmd-fake b/tests/data/cmd-fake
index e9744a2..4b97f43 100755
--- a/tests/data/cmd-fake
+++ b/tests/data/cmd-fake
@@ -5,14 +5,14 @@
# the client test suite. It doesn't test any of the wallet server code.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
# See LICENSE for licensing terms.
command="$1"
shift
type="$1"
shift
-if [ "$type" != "keytab" ] ; then
+if [ "$type" != "keytab" ] && [ "$type" != "file" ] ; then
echo "Unknown object type $type" >&2
exit 1
fi
@@ -23,7 +23,7 @@ getattr)
echo "Too many arguments" >&2
exit 1
fi
- if [ "$2" != sync ] ; then
+ if [ "$type" != "keytab" ] || [ "$2" != sync ] ; then
echo "Unknown attribute $2" >&2
exit 1
fi
@@ -44,7 +44,7 @@ setattr)
echo "Too many arguments" >&2
exit 1
fi
- if [ "$2" != sync ] ; then
+ if [ "$type" != "keytab" ] || [ "$2" != sync ] ; then
echo "Unknown attribute $2" >&2
exit 1
fi
@@ -67,21 +67,25 @@ get)
echo "Too many arguments" >&2
exit 1
fi
- case "$1" in
- service/fake-test)
+ case "${type}:${1}" in
+ file:fake-test)
cat data/fake-data
exit 0
;;
- service/fake-srvtab)
+ keytab:service/fake-srvtab)
cat data/fake-keytab
exit 0
;;
- service/fake-output)
+ keytab:service/fake-keytab)
+ cat data/fake-keytab-2
+ exit 0
+ ;;
+ keytab:service/fake-output)
printf 'This is a fake keytab.'
exit 0
;;
*)
- echo "Unknown keytab $1" >&2
+ echo "Unknown $type $1" >&2
exit 1
;;
esac
@@ -91,11 +95,11 @@ show)
echo "Too many arguments" >&2
exit 1
fi
- if [ "$1" = "service/fake-test" ] ; then
- echo "Some stuff about $1"
+ if [ "$type" = "file" ] && [ "$1" = "fake-test" ] ; then
+ echo "Some stuff about $type $1"
exit 0
else
- echo "Unknown keytab $1" >&2
+ echo "Unknown $type $1" >&2
exit 1
fi
;;
@@ -104,7 +108,7 @@ expires)
echo "Too many arguments" >&2
exit 1
fi
- echo "Expiration date of $1"
+ echo "Expiration date of $type $1"
exit 0
;;
*)
diff --git a/tests/data/fake-keytab-2 b/tests/data/fake-keytab-2
new file mode 100644
index 0000000..0440930
--- /dev/null
+++ b/tests/data/fake-keytab-2
Binary files differ
diff --git a/tests/data/fake-keytab-merge b/tests/data/fake-keytab-merge
new file mode 100644
index 0000000..31ddc49
--- /dev/null
+++ b/tests/data/fake-keytab-merge
Binary files differ