load_lib lib.t api_exit api_start #test "create-principal 1" # #proc test1 {} { # global test # begin_dump # one_line_fail_test [format { # ovsec_kadm_create_principal $server_handle \ # [simple_principal "%s/a"] {OVSEC_KADM_PRINCIPAL} "%s/a" # } $test $test] "NOT_INIT" # end_dump_compare "no-diffs" #} #test1 test "create-principal 2" proc test2 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test { ovsec_kadm_create_principal $server_handle null \ {OVSEC_KADM_PRINCIPAL} testpass } "EINVAL" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test2 test "create-principal 3" proc test3 {} { global test # set prms_id 777 # setup_xfail {*-*-*} $prms_id begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} null } $test] "EINVAL" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test3 test "create-principal 4" proc test4 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} "" } $test] "_Q_TOOSHORT" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test4 test "create-principal 5" proc test5 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle \ [simple_principal "%s/a"] {0x100001} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test5 test "create-principal 6" proc test6 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_LAST_PWD_CHANGE} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test6 test "create-principal 7" proc test7 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_MOD_TIME} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test7 test "create-principal 8" proc test8 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_MOD_NAME} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test8 test "create-principal 9" proc test9 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_MKVNO} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test9 test "create-principal 10" proc test10 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_AUX_ATTRIBUTES} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test10 test "create-principal 11" proc test11 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_POLICY_CLR} "%s/a" } $test $test] "BAD_MASK" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test11 test "create-principal 12" proc test12 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin/none admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "AUTH_ADD" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } if {$RPC} { test12 } test "create-principal 13" proc test13 {} { global test begin_dump if {! (( ! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin/get admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "AUTH_ADD" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } if {$RPC} { test13 } test "create-principal 14" proc test14 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin/modify admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "AUTH_ADD" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } if {$RPC} { test14 } test "create-principal 15" proc test15 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin/delete admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "AUTH_ADD" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } if {$RPC} { test15 } test "create-principal 16" proc test16 {} { global test begin_dump if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_CHANGEPW_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "AUTH_ADD" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } if {$RPC} { test16 } test "create-principal 17" proc test17 {} { global test begin_dump if {! (( [principal_exists "$test/a"]) || [create_principal "$test/a"])} { error_and_restart "$test: couldn't create principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} testpass } $test] "DUP" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test17 test "create-principal 18" proc test18 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin/add admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} tP } $test] "_Q_TOOSHORT" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test18 test "create-principal 19" proc test19 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} testpassword } $test] "_Q_CLASS" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test19 test "create-principal 20" proc test20 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} Abyssinia } $test] "_Q_DICT" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test20 test "create-principal 21" proc test21 {} { global test begin_dump if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } one_line_fail_test [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" non-existant-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} NotinTheDictionary } $test] "UNK_POLICY" if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } end_dump_compare "no-diffs" } test21 test "create-principal 23" proc test23 {} { global test if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } one_line_succeed_test \ [format {ovsec_kadm_get_principal $server_handle "%s/a" p} $test] if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test23 test "create-principal 24" proc test24 {} { global test if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin/rename admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } one_line_succeed_test \ [format {ovsec_kadm_get_principal $server_handle "%s/a" p} $test] if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } if {$RPC} { test24 } test "create-principal 28" proc test28 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return } send "lindex \$principal 10\n" expect { -re "test-pol.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test28 test "create-principal 29" proc test29 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_PRINC_EXPIRE_TIME} \ inTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 1\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test29 test "create-principal 30" proc test30 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_PW_EXPIRATION} \ NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test30 test "create-principal 31" proc test31 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol-nopw] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY \ OVSEC_KADM_PW_EXPIRATION} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test31 test "create-principal 32" proc test32 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ [princ_w_pol "%s/a" test-pol] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY \ OVSEC_KADM_PW_EXPIRATION} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } if { ! [cmd {ovsec_kadm_get_policy $server_handle test-pol policy}]} { error_and_restart "$test: cannot retrieve policy" return } send "lindex \$principal 6\n" expect { -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting mod_date" return } eof { error_and_restart "$test: eof getting mod_date" return } } send "lindex \$principal 3\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_expire" return } eof { error_and_restart "$test: eof getting pw_expire" return } } send "lindex \$policy 2\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_max_life" return } eof { error_and_restart "$test: eof getting pw_max_life" return } } if { $pw_expire != 0 } { fail "$test: pw_expire $pw_expire should be 0" return } else { pass "$test" } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror"$test: unexpected failure in destroy" return } } test32 test "create-principal 33" proc test33 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror"$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ {"%s/a" 0 0 1234 0 null 0 0 0 0 null 0} \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_PW_EXPIRATION} \ NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "1234.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test33 test "create-principal 34" proc test34 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ { "%s/a" 0 0 1234 0 null 0 0 0 0 test-pol-nopw 0} \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY \ OVSEC_KADM_PW_EXPIRATION} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "1234.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test34 test "create-principal 35" proc test35 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ {"%s/a" 0 0 1234 0 null 0 0 0 0 test-pol 0} \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY \ OVSEC_KADM_PW_EXPIRATION} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "1234.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test35 test "create-principal 36" proc test36 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle \ {"%s/a" 0 0 999999999 0 null 0 0 0 0 test-pol 0} \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY \ OVSEC_KADM_PW_EXPIRATION} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } if { ! [cmd {ovsec_kadm_get_policy $server_handle test-pol policy} ]} { error_and_restart "$test: cannot retrieve policy" return } send "lindex \$principal 6\n" expect { -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting mod_date" return } eof { error_and_restart "$test: eof getting mod_date" return } } send "lindex \$principal 3\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_expire" return } eof { error_and_restart "$test: eof getting pw_expire" return } } send "lindex \$policy 2\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_max_life" return } eof { error_and_restart "$test: eof getting pw_max_life" return } } if { $pw_expire != 999999999 } { fail "$test: pw_expire $pw_expire should be 999999999" return } else { pass "$test" } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror"$test: unexpected failure in destroy" return } } test36 test "create-principal 37" proc test37 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL} NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test37 test "create-principal 38" proc test38 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [princ_w_pol "%s/a" \ test-pol-nopw] {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} \ NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 3\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test38 test "create-principal 39" proc test39 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror "$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [princ_w_pol "%s/a" \ test-pol] {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} \ NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if { ! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { error_and_restart "$test: cannot not retrieve principal" return } if { ! [cmd {ovsec_kadm_get_policy $server_handle test-pol policy}]} { error_and_restart "$test: cannot retrieve policy" return } send "lindex \$principal 6\n" expect { -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting mod_date" return } eof { error_and_restart "$test: eof getting mod_date" return } } send "lindex \$principal 3\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_expire" return } eof { error_and_restart "$test: eof getting pw_expire" return } } send "lindex \$policy 2\n" expect { -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } timeout { error_and_restart "$test: timeout getting pw_max_life" return } eof { error_and_restart "$test: eof getting pw_max_life" return } } if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } { fail "$test: pw_expire is wrong" return } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror"$test: unexpected failure in destroy" return } } test39 test "create-principal 40" proc test40 {} { global test global prompt if {! ((! [principal_exists "$test/a"]) || [delete_principal "$test/a"])} { error_and_restart "$test: couldn't delete principal \"$test/a\"" return } if {! [cmd { ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \ server_handle }]} { perror"$test: unexpected failure in init" return } if {! [cmd [format { ovsec_kadm_create_principal $server_handle [simple_principal "%s/a"] \ {OVSEC_KADM_PRINCIPAL OVSEC_KADM_PW_EXPIRATION} \ NotinTheDictionary } $test]]} { fail "$test: can not create principal" return; } if {! [cmd [format { ovsec_kadm_get_principal $server_handle "%s/a" principal } $test]]} { fail "$test: can not retreive principal" return; } send "lindex \$principal 4\n" expect { -re "0.*$prompt$" { pass "$test" } timeout { fail "$test" } } if { ! [cmd {ovsec_kadm_destroy $server_handle}]} { perror "$test: unexpected failure in destroy" return } } test40 test "create-principal 43" proc test43 {} { global test one_line_fail_test [format { ovsec_kadm_create_principal null \ [simple_principal "%s/a"] {OVSEC_KADM_PRINCIPAL} "%s/a" } $test $test] "BAD_SERVER_HANDLE" } test43 return ""