From 98225c8d0288c800c8fd9071d522df09afd5a08b Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 10 May 1995 21:04:29 +0000 Subject: [PATCH] Add sample client/server tests git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5794 dc483132-0cff-0310-8789-dd5450dbe970 --- src/tests/dejagnu/krb-standalone/.Sanitize | 1 + src/tests/dejagnu/krb-standalone/ChangeLog | 6 + src/tests/dejagnu/krb-standalone/sample.exp | 150 ++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 src/tests/dejagnu/krb-standalone/sample.exp diff --git a/src/tests/dejagnu/krb-standalone/.Sanitize b/src/tests/dejagnu/krb-standalone/.Sanitize index b62ca2bc5..d7351ab25 100644 --- a/src/tests/dejagnu/krb-standalone/.Sanitize +++ b/src/tests/dejagnu/krb-standalone/.Sanitize @@ -25,6 +25,7 @@ Things-to-keep: rcp.exp rsh.exp +sample.exp standalone.exp Things-to-lose: diff --git a/src/tests/dejagnu/krb-standalone/ChangeLog b/src/tests/dejagnu/krb-standalone/ChangeLog index da1934e69..6b91783f2 100644 --- a/src/tests/dejagnu/krb-standalone/ChangeLog +++ b/src/tests/dejagnu/krb-standalone/ChangeLog @@ -1,3 +1,9 @@ +Wed May 10 17:00:01 1995 Ezra Peisach + + * .Sanitize (Things-to-keep): Add sample.exp + + * sample.exp: Added sample client/server tests. + Sat May 6 17:12:37 1995 Ezra Peisach * standalone.exp: klist test - added new line to prevent an OSF/1 diff --git a/src/tests/dejagnu/krb-standalone/sample.exp b/src/tests/dejagnu/krb-standalone/sample.exp new file mode 100644 index 000000000..e16ff2706 --- /dev/null +++ b/src/tests/dejagnu/krb-standalone/sample.exp @@ -0,0 +1,150 @@ +# Test for the sample clients +# This is a DejaGnu test script. +# This script tests that sample user-user communication works. + +# This mostly just calls procedures in test/dejagnu/config/default.exp. + +if ![info exists KLIST] { + set KLIST [findfile $objdir/../../clients/klist/klist] +} + +if ![info exists KDESTROY] { + set KDESTROY [findfile $objdir/../../clients/kdestroy/kdestroy] +} + +if ![info exists SSERVER] { + set SSERVER [findfile $objdir/../../appl/sample/sserver/sserver] +} +if ![info exists SCLIENT] { + set SCLIENT [findfile $objdir/../../appl/sample/sclient/sclient] +} + +# Set up the Kerberos files and environment. +if {![get_hostname] || ![setup_kerberos_files] || ![setup_kerberos_env]} { + return +} + +# Initialize the Kerberos database. The argument tells +# setup_kerberos_db that it is being called from here. +if ![setup_kerberos_db 0] { + return +} + +proc stop_sserver_daemon { } { + global sserver_pid + global sserver_spawn_id + + if [info exists sserver_pid] { + catch "close -i $sserver_spawn_id" + catch "exec kill $sserver_pid" + wait -i $sserver_spawn_id + unset sserver_pid + } + + return 1 +} + +# We are about to start up a couple of daemon processes. We do all +# the rest of the tests inside a proc, so that we can easily kill the +# processes when the procedure ends. + +proc doit { } { + global KLIST + global KDESTROY + global KEY + global SSERVER + global SCLIENT + global hostname + global tmppwd + global spawn_id + global sserver_pid + global sserver_spawn_id + + # Start up the kerberos and kadmind daemons. + if ![start_kerberos_daemons 0] { + return + } + + # Use kadmin to add an host key. + if ![add_random_key sample/$hostname 1] { + return + } + + # Use ksrvutil to create a srvtab entry for sample + if ![setup_srvtab 1 sample] { + return + } + + # Use kinit to get a ticket. + if ![kinit krbtest/admin adminpass$KEY 1] { + return + } + + # Start the sserver + spawn $SSERVER -p 3964 -S $tmppwd/srvtab + set sserver_pid [exp_pid] + set sserver_spawn_id $spawn_id + + verbose "sserver_spawn is" $sserver_spawn_id + + # Give sserver some time to start + catch "exec sleep 2" + + # Test the client + spawn $SCLIENT $hostname 3964 + expect { + "sendauth succeeded, reply is:" { + verbose "Start proper message" + } + timeout { + fail "sclient" + return + } + eof { + fail "sclient" + return + } + } + + expect { + "You are krbtest/admin@KRBTEST.COM" { + verbose "received valid sample message"} + eof { + fail "sclient" + return + } + } + + if ![check_exit_status "ssample"] { + return + } + pass "ssample" + + # Check the exit status of sserver - should exit here + set status_list [wait -i $sserver_spawn_id] + verbose "wait -i $sserver_spawn_id returned $status_list (sserver)" + catch "close -i $sserver_spawn_id" + if { [lindex $status_list 2] != 0 || [lindex $status_list 3] != 0 } { + send_log "exit status: $status_list\n" + verbose "exit status: $status_list" + fail "sserver" + } else { + pass "sserver" + } + # In either case the server shutdown + unset sserver_pid + + return +} + +set status [catch doit msg] + +stop_sserver_daemon + +stop_kerberos_daemons + +if { $status != 0 } { + send_error "ERROR: error in sample.exp\n" + send_error "$msg\n" + exit 1 +} -- 2.26.2