1load_lib lib.t
2api_exit
3api_start
4
5test "get-principal 1"
6proc test1 {} {
7    if {! [cmd {
8	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
9		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
10		server_handle
11    }]} {
12	perror "$test: unexpected failure in init"
13	return
14    }
15    one_line_fail_test \
16	    {kadm5_get_principal $server_handle null p KADM5_PRINCIPAL_NORMAL_MASK} "EINVAL"
17    if { ! [cmd {kadm5_destroy $server_handle}]} {
18	perror "$test: unexpected failure in destroy"
19	return
20    }
21}
22test1
23
24test "get-principal 2"
25proc test2 {} {
26    global test
27    if {! (( ! [principal_exists "$test/a"]) ||
28	   [delete_principal "$test/a"])} {
29	error_and_restart "$test: couldn't create principal \"$test/a\""
30	return
31    }
32
33    if {! [cmd {
34	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
35		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
36		server_handle
37    }]} {
38	perror "$test: unexpected failure in init"
39	return
40    }
41    one_line_fail_test [format {
42	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
43    } $test] "UNK_PRINC"
44    if { ! [cmd {kadm5_destroy $server_handle}]} {
45	perror "$test: unexpected failure in destroy"
46	return
47    }
48}
49test2
50
51test "get-principal 3"
52proc test3 {} {
53    global test
54    if {! ((  [principal_exists "$test/a"]) ||
55	   [create_principal "$test/a"])} {
56	error_and_restart "$test: couldn't create principal \"$test/a\""
57	return
58    }
59
60    if {! [cmd {
61	kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \
62		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
63		server_handle
64    }]} {
65	perror "$test: unexpected failure in init"
66	return
67    }
68    one_line_fail_test [format {
69	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
70    } $test] "AUTH_GET"
71    if { ! [cmd {kadm5_destroy $server_handle}]} {
72	perror "$test: unexpected failure in destroy"
73	return
74    }
75}
76if {$RPC} { test3 }
77
78test "get-principal 4"
79proc test4 {} {
80    global test
81    if {! ((  [principal_exists "$test/a"]) ||
82	   [create_principal "$test/a"])} {
83	error_and_restart "$test: couldn't create principal \"$test/a\""
84	return
85    }
86
87    if {! [cmd {
88	kadm5_init admin/add admin $KADM5_ADMIN_SERVICE null \
89		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
90		server_handle
91    }]} {
92	perror "$test: unexpected failure in init"
93	return
94    }
95    one_line_fail_test [format {
96	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
97    } $test] "AUTH_GET"
98    if { ! [cmd {kadm5_destroy $server_handle}]} {
99
100	perror "$test: unexpected failure in destroy"
101	return
102    }
103}
104if {$RPC} { test4 }
105
106test "get-principal 5"
107proc test5 {} {
108    global test
109    if {! ((  [principal_exists "$test/a"]) ||
110	   [create_principal "$test/a"])} {
111	error_and_restart "$test: couldn't create principal \"$test/a\""
112	return
113    }
114
115    if {! [cmd {
116	kadm5_init admin/modify admin $KADM5_ADMIN_SERVICE null \
117		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
118		server_handle
119    }]} {
120	perror "$test: unexpected failure in init"
121	return
122    }
123    one_line_fail_test [format {
124	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
125    } $test] "AUTH_GET"
126    if { ! [cmd {kadm5_destroy $server_handle}]} {
127
128	perror "$test: unexpected failure in destroy"
129	return
130    }
131}
132if {$RPC} { test5 }
133
134test "get-principal 6"
135proc test6 {} {
136    global test
137    if {! ((  [principal_exists "$test/a"]) ||
138	   [create_principal "$test/a"])} {
139	error_and_restart "$test: couldn't create principal \"$test/a\""
140	return
141    }
142
143    if {! [cmd {
144	kadm5_init admin/delete admin $KADM5_ADMIN_SERVICE null \
145		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
146		server_handle
147    }]} {
148	perror "$test: unexpected failure in init"
149	return
150    }
151    one_line_fail_test [format {
152	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
153    } $test] "AUTH_GET"
154    if { ! [cmd {kadm5_destroy $server_handle}]} {
155
156	perror "$test: unexpected failure in destroy"
157	return
158    }
159}
160if {$RPC} { test6 }
161
162test "get-principal 7"
163proc test7 {} {
164    global test
165    if {! ((  [principal_exists "$test/a"]) ||
166	   [create_principal "$test/a"])} {
167	error_and_restart "$test: couldn't create principal \"$test/a\""
168	return
169    }
170
171    if {! [cmd {
172	kadm5_init admin/delete admin $KADM5_CHANGEPW_SERVICE null \
173		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
174		server_handle
175    }]} {
176	perror "$test: unexpected failure in init"
177	return
178    }
179    one_line_fail_test [format {
180	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
181    } $test] "AUTH_GET"
182    if { ! [cmd {kadm5_destroy $server_handle}]} {
183
184	perror "$test: unexpected failure in destroy"
185	return
186    }
187}
188if {$RPC} { test7 }
189
190
191test "get-principal 8"
192proc test8 {} {
193    global test
194    if {! ((  [principal_exists "$test/a"]) ||
195	   [create_principal "$test/a"])} {
196	error_and_restart "$test: couldn't create principal \"$test/a\""
197	return
198    }
199
200    if {! [cmd {
201	kadm5_init admin/get admin $KADM5_CHANGEPW_SERVICE null \
202		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
203		server_handle
204    }]} {
205	perror "$test: unexpected failure in init"
206	return
207    }
208    one_line_fail_test [format {
209	kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK
210    } $test] "AUTH_GET"
211    if { ! [cmd {kadm5_destroy $server_handle}]} {
212	perror "$test: unexpected failure in destroy"
213	return
214    }
215}
216if {$RPC} { test8 }
217
218
219test "get-principal 9"
220proc test9 {} {
221    global test
222    if {! [cmd {
223	kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \
224		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
225		server_handle
226    }]} {
227	perror "$test: unexpected failure in init"
228	return
229    }
230    one_line_succeed_test \
231	    {kadm5_get_principal $server_handle admin/none p KADM5_PRINCIPAL_NORMAL_MASK}
232    if { ! [cmd {kadm5_destroy $server_handle}]} {
233	perror "$test: unexpected failure in destroy"
234	return
235    }
236}
237test9
238
239test "get-principal 10"
240proc test10 {} {
241    global test
242    if {! [cmd {
243	kadm5_init admin/none admin $KADM5_CHANGEPW_SERVICE null \
244		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
245		server_handle
246    }]} {
247	perror "$test: unexpected failure in init"
248	return
249    }
250    one_line_succeed_test \
251	    {kadm5_get_principal $server_handle admin/none p KADM5_PRINCIPAL_NORMAL_MASK}
252    if { ! [cmd {kadm5_destroy $server_handle}]} {
253	perror "$test: unexpected failure in destroy"
254	return
255    }
256}
257test10
258
259test "get-principal 11"
260proc test11 {} {
261    global test
262    if {! [cmd {
263	kadm5_init admin/get admin $KADM5_ADMIN_SERVICE null \
264		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
265		server_handle
266    }]} {
267	perror "$test: unexpected failure in init"
268	return
269    }
270    one_line_succeed_test {kadm5_get_principal $server_handle admin/get p KADM5_PRINCIPAL_NORMAL_MASK}
271    if { ! [cmd {kadm5_destroy $server_handle}]} {
272	perror "$test: unexpected failure in destroy"
273	return
274    }
275}
276test11
277
278test "get-principal 12"
279proc test12 {} {
280    global test
281    if {! [cmd {
282	kadm5_init admin/get admin $KADM5_CHANGEPW_SERVICE null \
283		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
284		server_handle
285    }]} {
286	perror "$test: unexpected failure in init"
287	return
288    }
289    one_line_succeed_test {kadm5_get_principal $server_handle admin/get p KADM5_PRINCIPAL_NORMAL_MASK}
290    if { ! [cmd {kadm5_destroy $server_handle}]} {
291	perror "$test: unexpected failure in destroy"
292	return
293    }
294}
295test12
296
297test "get-principal 13"
298proc test13 {} {
299    global test
300    if {! [cmd {
301	kadm5_init admin/get admin $KADM5_ADMIN_SERVICE null \
302		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
303		server_handle
304    }]} {
305	perror "$test: unexpected failure in init"
306	return
307    }
308    one_line_succeed_test {kadm5_get_principal $server_handle admin/add p KADM5_PRINCIPAL_NORMAL_MASK}
309    if { ! [cmd {kadm5_destroy $server_handle}]} {
310	perror "$test: unexpected failure in destroy"
311	return
312    }
313}
314test13
315
316test "get-principal 14"
317proc test14 {} {
318    global test
319    if {! [cmd {
320	kadm5_init admin/get-mod admin $KADM5_ADMIN_SERVICE null \
321		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
322		server_handle
323    }]} {
324	perror "$test: unexpected failure in init"
325	return
326    }
327    one_line_succeed_test {kadm5_get_principal $server_handle admin/add p KADM5_PRINCIPAL_NORMAL_MASK}
328    if { ! [cmd {kadm5_destroy $server_handle}]} {
329	perror "$test: unexpected failure in destroy"
330	return
331    }
332}
333test14
334
335test "get-principal 15"
336proc test15 {} {
337    one_line_fail_test \
338	    {kadm5_get_principal null "admin" p KADM5_PRINCIPAL_NORMAL_MASK} "BAD_SERVER_HANDLE"
339}
340test15
341
342return ""
343
344
345
346
347