#! /bin/sh # # Test suite for the wallet command-line client. # # Written by Russ Allbery # Copyright 2006, 2007, 2008, 2010 # The Board of Trustees of the Leland Stanford Junior University # # See LICENSE for licensing terms. # Load the test library. . "$SOURCE/tap/libtap.sh" . "$SOURCE/tap/kerberos.sh" . "$SOURCE/tap/remctl.sh" cd "$SOURCE" # We need a modified krb5.conf file to test wallet configuration settings in # krb5.conf. Despite the hard-coding of test-k5.stanford.edu, this test isn't # Stanford-specific; it just matches the files that are distributed with the # package. krb5conf= for p in /etc/krb5.conf /usr/local/etc/krb5.conf data/krb5.conf ; do if [ -r "$p" ] ; then krb5conf="$p" sed -e '/^[ ]*test-k5.stanford.edu =/,/}/d' \ -e 's/\(default_realm.*=\) .*/\1 test-k5.stanford.edu/' \ -e 's/^[ ]*wallet_.*//' \ -e '/^[ ]*wallet[ ]*=[ ]*{/,/}/d' \ "$p" > ./krb5.conf cat >> krb5.conf <> krb5.conf < input ok_program 'store from stdin' 0 '' "$wallet" store file fake-test < input rm -f input echo "file fake-test" > store-correct echo "This is a test of store" >> store-correct ok '...and the correct data was stored' diff store-output store-correct rm -f store-output store-correct # Test store with -f. echo "This is more store input" > store-input echo "file fake-test" > store-correct cat store-input >> store-correct ok_program 'store from a file' 0 '' \ "$wallet" -f store-input store file fake-test ok '...and the correct data was stored' cmp store-output store-correct rm -f store-input store-output store-correct printf 'This is store input\000with a nul character' > store-input echo 'file fake-nul' > store-correct cat store-input >> store-correct ok_program 'store from a file with a nul' 0 '' \ "$wallet" -f store-input store file fake-nul ok '...and the correct data was stored' cmp store-output store-correct rm -f store-input store-output store-correct # Test various other client functions and errors. ok_program 'get output to stdout' 0 'This is a fake keytab.' \ "$wallet" get keytab service/fake-output ok_program 'show output' 0 'Some stuff about file fake-test' \ "$wallet" show file fake-test ok_program 'unknown object type' 1 'wallet: Unknown object type srvtab' \ "$wallet" get srvtab service/fake-test ok_program 'unknown keytab name in show' 1 \ 'wallet: Unknown keytab service/unknown' \ "$wallet" show keytab service/unknown ok_program 'unknown keytab name in get' 1 \ 'wallet: Unknown keytab service/unknown' \ "$wallet" get keytab service/unknown ok_program 'expiration date' 0 'Expiration date of keytab service/fake-test' \ "$wallet" expires keytab service/fake-test # Clean up. rm -f autocreated krb5.conf remctld_stop kerberos_cleanup