summaryrefslogtreecommitdiffstats
path: root/src/lib/kadm5/unit-test/api.current/dlte-policy.exp
blob: 4ba40fd49631bc8bb36a7202d29413fe792d22bb (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
load_lib lib.t
api_exit
api_start

test "delete-policy 2"
proc test2 {} {
    global test
#    set prms_id 744
#    setup_xfail {*-*-*} $prms_id

    if {! [cmd {
	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    one_line_fail_test \
	    {kadm5_delete_policy $server_handle ""} "BAD_POL"
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
test2

test "delete-policy 5"
proc test5 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }

    if {! [cmd {
	kadm5_init admin admin $KADM5_CHANGEPW_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    one_line_fail_test [format {
	kadm5_delete_policy $server_handle "%s/a"
    } $test] "AUTH_DELETE"
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
if ${RPC} test5

test "delete-policy 6"
proc test6 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }

    if {! [cmd {
	kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    one_line_fail_test [format {
	kadm5_delete_policy $server_handle "%s/a"
    } $test] "AUTH_DELETE"
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
if ${RPC} test6

test "delete-policy 7"
proc test7 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }

    if {! [cmd {
	kadm5_init admin/add admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    one_line_fail_test [format {
	kadm5_delete_policy $server_handle "%s/a"
    } $test] "AUTH_DELETE"
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
if {$RPC} test7

test "delete-policy 10"
proc test10 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }

    if {! [cmd {
	kadm5_init admin/delete admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    if { ! [cmd [format {
	kadm5_delete_policy $server_handle  "%s/a"
    } $test]]} {
	fail "$test"
	return
    }
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
    if { [policy_exists "$test/a"]} {
	fail "$test"
	return
    }
}
test10

test "delete-policy 12"
proc test12 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }
    if {! ((! [principal_exists "$test/a"]) ||
	   [delete_principal "$test/a"])} {
	    error_and_restart "$test: couldn't delete principal \"$test/a\""
	    return
    }
    if {! [cmd {
	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test unexecpted failure in init"
	return
    }
    if {! [cmd [format {
	kadm5_create_principal $server_handle [princ_w_pol "%s/a" \
		"%s/a"] {KADM5_PRINCIPAL KADM5_POLICY} \
		NotinTheDictionary
    } $test $test]]} {
	fail "$test: can not create principal"
	return;
    }
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
    if {! [cmd {
	kadm5_init admin/delete admin $KADM5_ADMIN_SERVICE null \
		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
		server_handle
    }]} {
	perror "$test: unexpected failure in init"
	return
    }
    one_line_succeed_test [format {
	kadm5_delete_policy $server_handle "%s/a"
    } $test]
    if { ! [cmd {kadm5_destroy $server_handle}]} {
	perror "$test: unexpected failure in destroy"
	return
    }
}
test12

test "delete-policy 13"
proc test13 {} {
    global test
    if {! ((  [policy_exists "$test/a"]) ||
	   [create_policy "$test/a"])} {
	    error_and_restart "$test: couldn't create policy \"$test/a\""
	    return
    }
    one_line_fail_test [format {
	kadm5_delete_policy null "%s/a"
    } $test] "BAD_SERVER_HANDLE"
}
test13

return ""