summaryrefslogtreecommitdiffstats
path: root/src/kadmin/import/unit-test
diff options
context:
space:
mode:
authorMarc Horowitz <marc@mit.edu>1996-07-22 20:49:46 +0000
committerMarc Horowitz <marc@mit.edu>1996-07-22 20:49:46 +0000
commitedf8b4d8a6a665c2aa150993cd813ea6c5cf12e1 (patch)
tree6c2974a97b448c040fa4a31708ec5e02f187526c /src/kadmin/import/unit-test
parent013bb1391582ed9e653ae706e398ddb8d08cfcc9 (diff)
downloadkrb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.tar.gz
krb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.tar.xz
krb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.zip
this commit includes all the changes on the OV_9510_INTEGRATION and
OV_MERGE branches. This includes, but is not limited to, the new openvision admin system, and major changes to gssapi to add functionality, and bring the implementation in line with rfc1964. before committing, the code was built and tested for netbsd and solaris. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8774 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kadmin/import/unit-test')
-rw-r--r--src/kadmin/import/unit-test/Makefile.ov9
-rw-r--r--src/kadmin/import/unit-test/config/unix.exp36
-rw-r--r--src/kadmin/import/unit-test/helpers.exp93
-rw-r--r--src/kadmin/import/unit-test/import.0/usage.exp23
-rw-r--r--src/kadmin/import/unit-test/valid_export_file27
5 files changed, 188 insertions, 0 deletions
diff --git a/src/kadmin/import/unit-test/Makefile.ov b/src/kadmin/import/unit-test/Makefile.ov
new file mode 100644
index 000000000..c7ac33c0b
--- /dev/null
+++ b/src/kadmin/import/unit-test/Makefile.ov
@@ -0,0 +1,9 @@
+#
+# $Id$
+#
+
+TOP = ../..
+include $(TOP)/config.mk/template
+
+unit-test::
+ $(RUNTEST) IMPORT=../ovsec_adm_import --tool import
diff --git a/src/kadmin/import/unit-test/config/unix.exp b/src/kadmin/import/unit-test/config/unix.exp
new file mode 100644
index 000000000..af4ff443e
--- /dev/null
+++ b/src/kadmin/import/unit-test/config/unix.exp
@@ -0,0 +1,36 @@
+#
+# import_version -- extract and print the version number of import
+#
+
+proc import_version {} {
+ global IMPORT
+ set tmp [exec ident $IMPORT]
+ if [regexp {Header: .*import.c,v ([0-9]+\.[0-9]+)} $tmp \
+ dummy version] then {
+ clone_output "$IMPORT version $version\n"
+ } else {
+ clone_output "$IMPORT version <unknown>\n"
+ }
+}
+#
+# import_load -- loads the program
+#
+proc import_load {} {
+ #
+}
+
+# import_exit -- clean up and exit
+proc import_exit {} {
+ #
+}
+
+#
+# import_start -- start import running
+#
+proc import_start { args } {
+ global IMPORT
+ global spawn_id
+
+ verbose "% $IMPORT $args" 1
+ eval spawn $IMPORT $args
+}
diff --git a/src/kadmin/import/unit-test/helpers.exp b/src/kadmin/import/unit-test/helpers.exp
new file mode 100644
index 000000000..5905614e7
--- /dev/null
+++ b/src/kadmin/import/unit-test/helpers.exp
@@ -0,0 +1,93 @@
+#
+# $Id$
+#
+
+proc myfail { comment } {
+ global mytest_name
+ global mytest_status
+ wait
+ fail "$mytest_name: $comment"
+ set mytest_status 1
+}
+
+proc mypass {} {
+}
+
+##
+## When you expect on an id, and eof is detected, the spawn_id is closed.
+## It may be waited for, but calling expect or close on this id is an ERROR!
+##
+
+proc mytest { name kpargs status args } {
+ global spawn_id
+ global timeout
+ global mytest_name
+ global mytest_status
+
+ verbose "starting test: $name"
+
+ set mytest_name "$name"
+
+ eval import_start $kpargs
+
+ # at the end, eof is success
+
+ lappend args { eof { if {[regexp "\[\r\n\]$" $expect_out(buffer)] == 0} { myfail "final status message not newline-terminated" } } }
+
+ # for each test argument....
+ # rep invariant: when this foreach ends, the id is close'd, but
+ # not wait'ed.
+
+ foreach test $args {
+ set mytest_status 0
+
+ # treat the arg as an expect parameter
+ # if failure, the process will be closed and waited.
+
+ uplevel 1 "expect {
+ $test
+ timeout { close; myfail \"timeout\"}
+ eof { myfail \"eof read before expected message string\" }
+ }"
+
+ if {$mytest_status == 1} { return }
+ }
+
+ # at this point, the id is closed and we can wait on it.
+
+ set ret [wait]
+ verbose "% Exit $ret" 1
+ if {[lindex $ret 0] == -1} {
+ fail "$name: wait returned error [lindex $ret 1]"
+ } else {
+ if { ((![string compare $status zero]) &&
+ ([lindex $ret 1] == 0)) ||
+ ((![string compare $status nonzero]) &&
+ ([lindex $ret 1] != 0)) } {
+ pass "$name"
+ } else {
+ fail "$name: unexpected return status [lindex $ret 1], should be $status"
+ }
+ }
+}
+
+proc import_win { name args } {
+ mytest "$name" "$args" zero {
+ -re "Successfully imported \[0-9\]+ records."
+ { mypass }
+ eof
+ { myfail "error: $expect_out(buffer)" }
+ }
+}
+
+proc import_lose { name args error } {
+ mytest "$name" "$args" nonzero {
+ -re "Successfully imported \[0-9\]+ records."
+ { myfail "unexpected success" }
+ -re "ovsec_adm_import: .*$error"
+ { mypass }
+ eof
+ { myfail "error: $expect_out(buffer)" }
+ }
+}
+
diff --git a/src/kadmin/import/unit-test/import.0/usage.exp b/src/kadmin/import/unit-test/import.0/usage.exp
new file mode 100644
index 000000000..8e82f5a21
--- /dev/null
+++ b/src/kadmin/import/unit-test/import.0/usage.exp
@@ -0,0 +1,23 @@
+#
+# $Id$
+#
+
+set timeout 5
+
+load_lib "helpers.exp"
+
+#
+# Here are the tests
+#
+
+import_lose "C.6: input file not readable" /foo/bar/baz \
+ "No such file or directory while opening input file"
+
+import_lose "C.7: two arguments" {foo bar} \
+ "Usage:"
+
+system {rm -rf /krb5}
+
+import_lose "C.2: /krb5 doesn't exist" ./valid_export_file \
+ "Secure administration database lock file missing while importing"
+
diff --git a/src/kadmin/import/unit-test/valid_export_file b/src/kadmin/import/unit-test/valid_export_file
new file mode 100644
index 000000000..dad19c874
--- /dev/null
+++ b/src/kadmin/import/unit-test/valid_export_file
@@ -0,0 +1,27 @@
+OpenV*Secure V1.0 Tue Dec 21 14:18:18 1993
+policy test-pol 0 10000 8 2 3 1
+policy dict-only 0 0 1 1 1 1
+policy once-a-min 30 0 1 1 1 1
+policy test-pol-nopw 0 0 1 1 1 2
+princ admin/delete@SECURE-TEST.OV.COM 0 0 0 0
+princ test3@SECURE-TEST.OV.COM 0 0 0 0
+princ admin/modify@SECURE-TEST.OV.COM 0 0 0 0
+princ ovsec_adm/changepw@SECURE-TEST.OV.COM 0 0 0 0
+princ test2@SECURE-TEST.OV.COM 0 0 0 0
+princ admin/pol@SECURE-TEST.OV.COM test-pol-nopw 800 0 0 0
+princ admin/rename@SECURE-TEST.OV.COM 0 0 0 0
+princ test1@SECURE-TEST.OV.COM 0 0 0 0
+princ krbtgt/SECURE-TEST.OV.COM@SECURE-TEST.OV.COM 0 0 0 0
+princ pol3@SECURE-TEST.OV.COM dict-only 800 0 0 0
+princ admin/get-pol@SECURE-TEST.OV.COM test-pol-nopw 800 0 0 0
+princ admin/none@SECURE-TEST.OV.COM 0 0 0 0
+princ testuser@SECURE-TEST.OV.COM 0 0 0 0
+princ pol2@SECURE-TEST.OV.COM once-a-min 800 0 0 0
+princ K/M@SECURE-TEST.OV.COM 0 0 0 0
+princ pol1@SECURE-TEST.OV.COM test-pol 800 0 0 0
+princ ovsec_adm/history@SECURE-TEST.OV.COM 0 0 0 0
+princ admin@SECURE-TEST.OV.COM 0 0 0 0
+princ admin/add@SECURE-TEST.OV.COM 0 0 0 0
+princ admin/get@SECURE-TEST.OV.COM 0 0 0 0
+princ ovsec_adm/admin@SECURE-TEST.OV.COM 0 0 0 0
+End of Database 25 records