aboutsummaryrefslogtreecommitdiff
path: root/src/lib/kadm5/unit-test/api.2/randkey-principal-v2.exp
blob: c9d1104bc992971a1bfff80234ebae7f7e137719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
load_lib lib.t
api_exit
api_start

test "randkey-principal 100"
proc test100 {} {
    global test prompt

    if {! (( ! [principal_exists "$test/a"]) ||
	   [delete_principal "$test/a"])} {
	    error_and_restart "$test: couldn't create principal \"$test/a\""
	    return
    }
    if {! [create_principal "$test/a"]} {
	error_and_restart "$test: creating principal"
	return
    }

    # I'd like to specify a long list of keysalt tuples and make sure
    # that randkey does the right thing, but we can only use those
    # enctypes that krbtgt has a key for: des-cbc-crc:normal and
    # des-cbc-crc:v4, according to the prototype kdc.conf.
    if {! [cmd [format {
	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
		server_handle
    }]]} {
	perror "$test: unexpected failure in init"
	return
    }
    if {! [cmd [format {
	kadm5_randkey_principal $server_handle "%s/a" keys num_keys
    } $test]]} {
	perror "$test: unexpected failure in randkey_principal"
    }
    send "puts \$num_keys\n"
    expect {
	-re "(\[0-9\]+)\n$prompt" { set num_keys $expect_out(1,string) }
	timeout {
	    error_and_restart "$test: timeout getting num_keys"
	    return
	}
	eof {
	    error_and_restart "$test: eof getting num_keys"
	    return
	}
    }

    # XXX Perhaps I should actually check the key type returned.
    if {$num_keys == 2} {
	pass "$test"
    } else {
	fail "$test: $num_keys keys, should be 2"
    }
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
test100

return ""