Imported Upstream version 1.15.1
[platform/upstream/krb5.git] / src / lib / kadm5 / unit-test / api.current / crte-policy.exp
1 load_lib lib.t
2 api_exit
3 api_start
4
5 # Description: (1) Fails for mask with undefined bit set.
6 # 01/24/94: pshuang: untried.
7 test "create-policy 1"
8 proc test1 {} {
9     global test
10     if {! (( ! [policy_exists "$test/a"]) ||
11            [delete_policy "$test/a"])} {
12             error_and_restart "$test: couldn't delete policy \"$test/a\""
13             return
14     }
15     if {! [cmd {
16         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
17                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
18                 server_handle
19     }]} {
20         perror "$test: unexpected failure in init"
21         return
22     }
23     one_line_fail_test [format {
24         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
25                 0xF01000
26     } $test] "BAD_MASK"
27     if { ! [cmd {kadm5_destroy $server_handle}]} {
28         perror "$test: unexpected failure in destroy"
29         return
30     }
31 }
32 test1
33
34 # Description: (2) Fails if caller connected with CHANGEPW_SERVICE.
35 test "create-policy 2"
36 proc test2 {} {
37     global test
38     if {! (( ! [policy_exists "$test/a"]) ||
39            [delete_policy "$test/a"])} {
40             error_and_restart "$test: couldn't delete principal \"$test/a\""
41             return
42     }
43     if {! [cmd {
44         kadm5_init admin admin $KADM5_CHANGEPW_SERVICE null \
45                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
46                 server_handle
47     }]} {
48         perror "$test: unexpected failure in init"
49         return
50     }
51     one_line_fail_test [format {
52         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
53                 {KADM5_POLICY}
54     } $test] "AUTH_ADD"
55     if { ! [cmd {kadm5_destroy $server_handle}]} {
56         perror "$test: unexpected failure in destroy";
57         return
58     }
59 }
60 if {$RPC} { test2 }
61
62 # Description: (3) Fails for mask without POLICY bit set.
63 # 01/24/94: pshuang: untried.
64 test "create-policy 3"
65 proc test3 {} {
66     global test
67     if {! (( ! [policy_exists "$test/a"]) ||
68            [delete_policy "$test/a"])} {
69             error_and_restart "$test: couldn't delete policy \"$test/a\""
70             return
71     }
72     if {! [cmd {
73         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
74                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
75                 server_handle
76     }]} {
77         perror "$test: unexpected failure in init"
78         return
79     }
80     one_line_fail_test [format {
81         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
82                 0x000000
83     } $test] "BAD_MASK"
84     if { ! [cmd {kadm5_destroy $server_handle}]} {
85         perror "$test: unexpected failure in destroy"
86         return
87     }
88 }
89 test3
90
91 # Description: (5) Fails for invalid policy name.
92 # 01/24/94: pshuang: untried.
93 test "create-policy 5"
94 proc test5 {} {
95     global test
96     if {! [cmd {
97         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
98                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
99                 server_handle
100     }]} {
101         perror "$test: unexpected failure in init"
102         return
103     }
104     one_line_fail_test [format {
105         kadm5_create_policy $server_handle [simple_policy "%s/\a"] \
106                 {KADM5_POLICY}
107     } $test] "BAD_POLICY"
108     if { ! [cmd {kadm5_destroy $server_handle}]} {
109         perror "$test: unexpected failure in destroy"
110         return
111     }
112 }
113 test5
114
115 # Description: (6) Fails for existing policy name.
116 test "create-policy 6"
117 proc test6 {} {
118     global test
119 #    set prms_id 777
120 #    setup_xfail {*-*-*} $prms_id
121
122     if {! [cmd {
123         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
124                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
125                 server_handle
126     }]} {
127         perror "$test: unexpected failure in init"
128         return
129     }
130     one_line_fail_test {
131         kadm5_create_policy $server_handle [simple_policy test-pol] \
132                 {KADM5_POLICY}
133     } "DUP"
134     if { ! [cmd {kadm5_destroy $server_handle}]} {
135         perror "$test: unexpected failure in destroy"
136         return
137     }
138 }
139 test6
140
141 # Description: (7) Fails for null policy name.
142 # 01/24/94: pshuang: untried.
143 test "create-policy 7"
144 proc test7 {} {
145     global test
146 #    set prms_id 1977
147 #    setup_xfail {*-*-*} $prms_id
148     
149     if {! [cmd {
150         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
151                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
152                 server_handle
153     }]} {
154         perror "$test: unexpected failure in init"
155         return
156     }
157     one_line_fail_test {
158         kadm5_create_policy $server_handle [simple_policy null] \
159                 {KADM5_POLICY}
160     } "EINVAL"
161     if { ! [cmd {kadm5_destroy $server_handle}]} {
162         perror "$test: unexpected failure in destroy"
163         return
164     }
165 }
166 test7
167
168 # Description: (8) Fails for empty-string policy name.
169 test "create-policy 8"
170 proc test8 {} {
171     global test
172
173     if {! [cmd {
174         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
175                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
176                 server_handle
177     }]} {
178         perror "$test: unexpected failure in init"
179         return
180     }
181     one_line_fail_test {
182         kadm5_create_policy $server_handle [simple_policy ""] \
183                 {KADM5_POLICY}
184     } "BAD_POLICY"
185     if { ! [cmd {kadm5_destroy $server_handle}]} {
186         perror "$test: unexpected failure in destroy"
187         return
188     }
189 }
190 test8
191
192 # Description: (9) Accepts 0 for pw_min_life.
193 test "create-policy 9"
194 proc test9 {} {
195     global test
196     global prompt
197
198     if {! (( ! [policy_exists "$test/a"]) ||
199            [delete_policy "$test/a"])} {
200             error_and_restart "$test: couldn't delete principal \"$test/a\""
201             return
202     }
203
204     if {! [cmd {
205         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
206                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
207                 server_handle
208     }]} {
209         perror "$test: unexpected failure in init"
210         return
211     }
212     if { ! [cmd [format {
213         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
214                 {KADM5_POLICY KADM5_PW_MIN_LIFE}
215     } $test]]} {
216         fail "$test: create failed"
217         return
218     }
219     if {! [cmd [format {
220         kadm5_get_policy $server_handle "%s/a" policy
221     } $test]]} {
222         fail "$test: can not retrieve policy"
223         return
224     }
225     send "lindex \$policy 1\n"
226     expect {
227         -re "0\n$prompt$"               { pass "$test" }
228         timeout                         { fail "$test" }
229     }
230     if { ! [cmd {kadm5_destroy $server_handle}]} {
231         perror "$test: unexpected failure in destroy"
232         return
233     }
234 }
235 test9
236
237 # Description: (10) Accepts non-zero for pw_min_life.
238 test "create-policy 10"
239 proc test10 {} {
240     global test
241     global prompt
242
243     if {! (( ! [policy_exists "$test/a"]) ||
244            [delete_policy "$test/a"])} {
245             error_and_restart "$test: couldn't delete principal \"$test/a\""
246             return
247     }
248
249     if {! [cmd {
250         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
251                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
252                 server_handle
253     }]} {
254         perror "$test: unexpected failure in init"
255         return
256     }
257     if { ! [cmd [format {
258         kadm5_create_policy $server_handle {"%s/a" 32 0 0 0 0 0 } \
259                 {KADM5_POLICY KADM5_PW_MIN_LIFE}
260     } $test]]} {
261         fail "$test"
262         return
263     }
264     if {! [cmd [format {
265         kadm5_get_policy $server_handle "%s/a" policy
266     } $test]]} {
267         fail "$test: can not retreuve policy"
268         return
269     }
270     send "lindex \$policy 1\n"
271     expect {
272         -re "32\n$prompt$"              { pass "$test" }
273         timeout                         { fail "$test" }
274     }
275     if { ! [cmd {kadm5_destroy $server_handle}]} {
276         perror "$test: unexpected failure in destroy"
277         return
278     }
279 }
280 test10
281
282 # Description: (11) Accepts 0 for pw_max_life.
283 test "create-policy 11"
284 proc test11 {} {
285     global test
286     global prompt
287
288     if {! (( ! [policy_exists "$test/a"]) ||
289            [delete_policy "$test/a"])} {
290             error_and_restart "$test: couldn't delete principal \"$test/a\""
291             return
292     }
293
294     if {! [cmd {
295         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
296                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
297                 server_handle
298     }]} {
299         perror "$test: unexpected failure in init"
300         return
301     }
302     if {! [cmd [format {
303         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
304                 {KADM5_POLICY KADM5_PW_MAX_LIFE}
305     } $test]]} {
306         fail "$test"
307         return
308     }
309     if {! [cmd [format {
310         kadm5_get_policy $server_handle "%s/a" policy
311     } $test]]} {
312         fail "$test: can not retreuve policy"
313         return
314     }
315     send "lindex \$policy 2\n"
316     expect {
317         -re "0\n$prompt$"               { pass "$test" }
318         timeout                         { fail "$test" }
319     }
320     
321     if { ! [cmd {kadm5_destroy $server_handle}]} {
322         perror "$test: unexpected failure in destroy"
323         return
324     }
325 }
326 test11
327
328 # Description: (12) Accepts non-zero for pw_max_life.
329 test "create-policy 12"
330 proc test12 {} {
331     global test
332     global prompt
333
334     if {! (( ! [policy_exists "$test/a"]) ||
335            [delete_policy "$test/a"])} {
336             error_and_restart "$test: couldn't delete principal \"$test/a\""
337             return
338     }
339
340     if {! [cmd {
341         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
342                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
343                 server_handle
344     }]} {
345         perror "$test: unexpected failure in init"
346         return
347     }
348     if {! [cmd [format {
349         kadm5_create_policy $server_handle {"%s/a" 0 32 0 0 0 0 } \
350                 {KADM5_POLICY KADM5_PW_MAX_LIFE}
351     } $test]]} {
352         fail "$test"
353         return
354     }
355     if {! [cmd [format {
356         kadm5_get_policy $server_handle "%s/a" policy
357     } $test]]} {
358         fail "$test: can not retreuve policy"
359         return
360     }
361     send "lindex \$policy 2\n"
362     expect {
363         -re "32\n$prompt$"              { pass "$test" }
364         timeout                         { fail "$test" }
365     }
366     if { ! [cmd {kadm5_destroy $server_handle}]} {
367         perror "$test: unexpected failure in destroy"
368         return
369     }
370 }
371 test12
372
373 # Description: (13) Rejects 0 for pw_min_length.
374 test "create-policy 13"
375 proc test13 {} {
376     global test
377     global prompt
378
379
380     if {! (( ! [policy_exists "$test/a"]) ||
381            [delete_policy "$test/a"])} {
382             error_and_restart "$test: couldn't delete principal \"$test/a\""
383             return
384     }
385     if {! [cmd {
386         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
387                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
388                 server_handle
389     }]} {
390         perror "$test: unexpected failure in init"
391         return
392     }
393     one_line_fail_test [format {
394         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
395                 {KADM5_POLICY KADM5_PW_MIN_LENGTH}
396     } $test] "BAD_LENGTH"
397     if { ! [cmd {kadm5_destroy $server_handle}]} {
398         perror "$test: unexpected failure in destroy"
399         return
400     }
401 }
402 test13
403
404 # Description: (14) Accepts non-zero for pw_min_length.
405 test "create-policy 14"
406 proc test14 {} {
407     global test
408     global prompt
409
410     if {! (( ! [policy_exists "$test/a"]) ||
411            [delete_policy "$test/a"])} {
412             error_and_restart "$test: couldn't delete principal \"$test/a\""
413             return
414     }
415
416     if {! [cmd {
417         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
418                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
419                 server_handle
420     }]} {
421         perror "$test: unexpected failure in init"
422         return
423     }
424     if {! [cmd [format {
425         kadm5_create_policy $server_handle {"%s/a" 0 0 8 0 0 0 } \
426                 {KADM5_POLICY KADM5_PW_MIN_LENGTH}
427     } $test]]} {
428         fail $test
429         return
430     }
431     if {! [cmd [format {
432         kadm5_get_policy $server_handle "%s/a" policy
433     } $test]]} {
434         fail "$test: can not retreuve policy"
435         return
436     }
437     send "lindex \$policy 3\n"
438     expect {
439         -re "8\n$prompt$"               { pass "$test" }
440         timeout                         { fail "$test" }
441     }
442     
443     if { ! [cmd {kadm5_destroy $server_handle}]} {
444         perror "$test: unexpected failure in destroy"
445         return
446     }
447 }
448 test14
449
450 # Description: (15) Rejects 0 for pw_min_classes.
451 test "create-policy 15"
452 proc test15 {} {
453     global test
454
455     if {! (( ! [policy_exists "$test/a"]) ||
456            [delete_policy "$test/a"])} {
457             error_and_restart "$test: couldn't delete principal \"$test/a\""
458             return
459     }
460
461     if {! [cmd {
462         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
463                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
464                 server_handle
465     }]} {
466         perror "$test: unexpected failure in init"
467         return
468     }
469     one_line_fail_test [format {
470         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
471                 {KADM5_POLICY KADM5_PW_MIN_CLASSES}
472     } $test] "BAD_CLASS"
473     if { ! [cmd {kadm5_destroy $server_handle}]} {
474         perror "$test: unexpected failure in destroy"
475         return
476     }
477 }
478 test15
479
480 # Description: (16) Accepts 1 for pw_min_classes.
481 test "create-policy 16"
482 proc test16 {} {
483     global test
484     global prompt
485
486     if {! (( ! [policy_exists "$test/a"]) ||
487            [delete_policy "$test/a"])} {
488             error_and_restart "$test: couldn't delete principal \"$test/a\""
489             return
490     }
491
492     if {! [cmd {
493         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
494                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
495                 server_handle
496     }]} {
497         perror "$test: unexpected failure in init"
498         return
499     }
500     if {! [cmd [format {
501         kadm5_create_policy $server_handle {"%s/a" 0 0 0 1 0 0 } \
502                 {KADM5_POLICY KADM5_PW_MIN_CLASSES}
503     } $test]]} {
504         fail $test
505         return
506     }
507     if {! [cmd [format {
508         kadm5_get_policy $server_handle "%s/a" policy
509     } $test]]} {
510         fail "$test: can not retreuve policy"
511         return
512     }
513     send "lindex \$policy 4\n"
514     expect {
515         -re "1\n$prompt$"               { pass "$test" }
516         timeout                         { fail "$test" }
517     }
518     
519     if { ! [cmd {kadm5_destroy $server_handle}]} {
520         perror "$test: unexpected failure in destroy"
521         return
522     }
523 }
524 test16
525
526 # Description: (17) Accepts 4 for pw_min_classes.
527 test "create-policy 17"
528 proc test17 {} {
529     global test
530     global prompt
531
532     if {! (( ! [policy_exists "$test/a"]) ||
533            [delete_policy "$test/a"])} {
534             error_and_restart "$test: couldn't delete principal \"$test/a\""
535             return
536     }
537     if {! [cmd {
538         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
539                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
540                 server_handle
541     }]} {
542         perror "$test: unexpected failure in init"
543         return
544     }
545     if {! [cmd [format {
546         kadm5_create_policy $server_handle {"%s/a" 0 0 0 5 0 0} \
547                 {KADM5_POLICY KADM5_PW_MIN_CLASSES}
548     } $test]]} {
549         fail $test
550         return
551     }
552     if {! [cmd [format {
553         kadm5_get_policy $server_handle "%s/a" policy
554     } $test]]} {
555         fail "$test: can not retreuve policy"
556         return
557     }
558     send "lindex \$policy 4\n"
559     expect {
560         -re "5\n$prompt$"               { pass "$test" }
561         timeout                         { fail "$test" }
562     }
563     if { ! [cmd {kadm5_destroy $server_handle}]} {
564         perror "$test: unexpected failure in destroy"
565         return
566     }
567 }
568 test17
569
570 # Description: (18) Rejects 5 for pw_min_classes.
571 test "create-policy 18"
572 proc test18 {} {
573     global test
574
575     if {! (( ! [policy_exists "$test/a"]) ||
576            [delete_policy "$test/a"])} {
577             error_and_restart "$test: couldn't delete principal \"$test/a\""
578             return
579     }
580     if {! [cmd {
581         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
582                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
583                 server_handle
584     }]} {
585         perror "$test: unexpected failure in init"
586         return
587     }
588     one_line_fail_test [format {
589         kadm5_create_policy $server_handle {"%s/a" 0 0 0 6 0 0} \
590                 {KADM5_POLICY KADM5_PW_MIN_CLASSES}
591     } $test] "BAD_CLASS"
592     if { ! [cmd {kadm5_destroy $server_handle}]} {
593         perror "$test: unexpected failure in destroy"
594         return
595     }
596 }
597 test18
598
599 # Description: (19) Rejects 0 for pw_history_num.
600 test "create-policy 19"
601 proc test19 {} {
602     global test
603
604     if {! (( ! [policy_exists "$test/a"]) ||
605            [delete_policy "$test/a"])} {
606             error_and_restart "$test: couldn't delete principal \"$test/a\""
607             return
608     }
609     if {! [cmd {
610         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
611                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
612                 server_handle
613     }]} {
614         perror "$test: unexpected failure in init"
615         return
616     }
617     one_line_fail_test [format {
618         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
619                 {KADM5_POLICY KADM5_PW_HISTORY_NUM}
620     } $test] "BAD_HISTORY"
621     if { ! [cmd {kadm5_destroy $server_handle}]} {
622         perror "$test: unexpected failure in destroy"
623         return
624     }
625 }
626 test19
627
628 # Description: (20) Accepts 1 for pw_history_num.
629 test "create-policy 20"
630 proc test20 {} {
631     global test
632     global prompt
633
634     if {! (( ! [policy_exists "$test/a"]) ||
635            [delete_policy "$test/a"])} {
636             error_and_restart "$test: couldn't delete principal \"$test/a\""
637             return
638     }
639     if {! [cmd {
640         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
641                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
642                 server_handle
643     }]} {
644         perror "$test: unexpected failure in init"
645         return
646     }
647     if {! [cmd  [format {
648         kadm5_create_policy $server_handle {"%s/a" 0 0 0 0 1 0} \
649                 {KADM5_POLICY KADM5_PW_HISTORY_NUM}
650     } $test]]} {
651         fail $test
652         return
653     }
654     if {! [cmd [format {
655         kadm5_get_policy $server_handle "%s/a" policy
656     } $test]]} {
657         fail "$test: can not retreuve policy"
658         return
659     }
660     send "lindex \$policy 5\n"
661     expect {
662         -re "1\n$prompt$"               { pass "$test" }
663         timeout                         { fail "$test" }
664     }
665     if { ! [cmd {kadm5_destroy $server_handle}]} {
666         perror "$test: unexpected failure in destroy"
667         return
668     }
669 }
670 test20
671
672 # Description: (21) Accepts 10 for pw_history_num.
673 test "create-policy 21"
674 proc test21 {} {
675     global test
676     global prompt
677
678     if {! (( ! [policy_exists "$test/a"]) ||
679            [delete_policy "$test/a"])} {
680             error_and_restart "$test: couldn't delete principal \"$test/a\""
681             return
682     }
683
684     if {! [cmd {
685         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
686                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
687                 server_handle
688     }]} {
689         perror "$test: unexpected failure in init"
690         return
691     }
692     if {! [cmd [format {
693         kadm5_create_policy $server_handle {"%s/a" 0 0 0 0 10 0} \
694                 {KADM5_POLICY KADM5_PW_HISTORY_NUM}
695     } $test]]} {
696         fail $test
697         return
698     }
699     if {! [cmd [format {
700         kadm5_get_policy $server_handle "%s/a" policy
701     } $test]]} {
702         fail "$test: can not retrieve policy"
703         return
704     }
705     send "lindex \$policy 5\n"
706     expect {
707         -re "10\n$prompt$"              { pass "$test" }
708         timeout                         { fail "$test" }
709     }
710     if { ! [cmd {kadm5_destroy $server_handle}]} {
711         perror "$test: unexpected failure in destroy"
712         return
713     }
714 }
715 test21
716     
717 # Description: (22) Fails for user with no access bits.
718 test "create-policy 22"
719 proc test22 {} {
720     global test
721     if {! (( ! [policy_exists "$test/a"]) ||
722            [delete_policy "$test/a"])} {
723             error_and_restart "$test: couldn't delete principal \"$test/a\""
724             return
725     }
726
727     if {! [cmd {
728         kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \
729                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
730                 server_handle
731     }]} {
732         perror "$test: unexpected failure in init"
733         return
734     }
735     one_line_fail_test [format {
736         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
737                 {KADM5_POLICY}
738     } $test] "AUTH_ADD"
739     if { ! [cmd {kadm5_destroy $server_handle}]} {
740         perror "$test: unexpected failure in destroy"
741         return
742     }
743 }
744 if {$RPC} test22
745
746 # Description: (23) Fails for user with "get" but not "add".
747 test "create-policy 23"
748 proc test23 {} {
749     global test
750     if {! (( ! [policy_exists "$test/a"]) ||
751            [delete_policy "$test/a"])} {
752             error_and_restart "$test: couldn't delete principal \"$test/a\""
753             return
754     }
755
756     if {! [cmd {
757         kadm5_init admin/get admin $KADM5_ADMIN_SERVICE null \
758                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
759                 server_handle
760     }]} {
761         perror "$test: unexpected failure in init"
762         return
763     }
764     one_line_fail_test [format {
765         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
766                 {KADM5_POLICY}
767     } $test] "AUTH_ADD"
768     if { ! [cmd {kadm5_destroy $server_handle}]} {
769         perror "$test: unexpected failure in destroy"
770         return
771     }
772 }
773 if {$RPC} test23
774
775 # Description: (24) Fails for user with "modify" but not "add".
776 # 01/24/94: pshuang: untried.
777 test "create-policy 24"
778 proc test24 {} {
779     global test
780     if {! (( ! [policy_exists "$test/a"]) ||
781            [delete_policy "$test/a"])} {
782             error_and_restart "$test: couldn't delete principal \"$test/a\""
783             return
784     }
785
786     if {! [cmd {
787         kadm5_init admin/modify admin $KADM5_ADMIN_SERVICE null \
788                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
789                 server_handle
790     }]} {
791         perror "$test: unexpected failure in init"
792         return
793     }
794     one_line_fail_test [format {
795         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
796                 {KADM5_POLICY}
797     } $test] "AUTH_ADD"
798     if { ! [cmd {kadm5_destroy $server_handle}]} {
799         perror "$test: unexpected failure in destroy"
800         return
801     }
802 }
803 if {$RPC} test24
804
805 # Description: (25) Fails for user with "delete" but not "add".
806 # 01/24/94: pshuang: untried.
807 test "create-policy 25"
808 proc test25 {} {
809     global test
810     if {! (( ! [policy_exists "$test/a"]) ||
811            [delete_policy "$test/a"])} {
812             error_and_restart "$test: couldn't delete principal \"$test/a\""
813             return
814     }
815
816     if {! [cmd {
817         kadm5_init admin/delete admin $KADM5_ADMIN_SERVICE null \
818                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
819                 server_handle
820     }]} {
821         perror "$test: unexpected failure in init"
822         return
823     }
824     one_line_fail_test [format {
825         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
826                 {KADM5_POLICY}
827     } $test] "AUTH_ADD"
828     if { ! [cmd {kadm5_destroy $server_handle}]} {
829         perror "$test: unexpected failure in destroy"
830         return
831     }
832 }
833 if {$RPC} test25
834
835 # Description: Succeeds for user with "add".
836 test "create-policy 26"
837 proc test26 {} {
838     global test
839
840     if {! (( ! [policy_exists "$test/a"]) ||
841            [delete_policy "$test/a"])} {
842             error_and_restart "$test: couldn't delete principal \"$test/a\""
843             return
844     }
845     if {! [cmd {
846         kadm5_init admin/add admin $KADM5_ADMIN_SERVICE null \
847                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
848                 server_handle
849     }]} {
850         perror "$test: unexpected failure in init"
851         return
852     }
853     one_line_succeed_test [format {
854         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
855                 {KADM5_POLICY}
856     } $test]
857     if { ! [cmd {kadm5_destroy $server_handle}]} {
858         perror "$test: unexpected failure in destroy"
859         return
860     }
861 }
862 test26
863
864 # Description: Succeeds for user with "get" and "add".
865 # 01/24/94: pshuang: untried.
866 test "create-policy 27"
867 proc test27 {} {
868     global test
869
870     if {! (( ! [policy_exists "$test/a"]) ||
871            [delete_policy "$test/a"])} {
872             error_and_restart "$test: couldn't delete principal \"$test/a\""
873             return
874     }
875     if {! [cmd {
876         kadm5_init admin/get-add admin $KADM5_ADMIN_SERVICE null \
877                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
878                 server_handle
879     }]} {
880         perror "$test: unexpected failure in init"
881         return
882     }
883     one_line_succeed_test [format {
884         kadm5_create_policy $server_handle [simple_policy "%s/a"] \
885                 {KADM5_POLICY}
886     } $test]
887     if { ! [cmd {kadm5_destroy $server_handle}]} {
888         perror "$test: unexpected failure in destroy"
889         return
890     }
891 }
892 test27
893
894 # Description: (28) Rejects null policy argument.
895 # 01/24/94: pshuang: untried.
896 test "create-policy 28"
897 proc test28 {} {
898     global test
899     if {! [cmd {
900         kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
901                 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \
902                 server_handle
903     }]} {
904         perror "$test: unexpected failure in init"
905         return
906     }
907     one_line_fail_test {
908         kadm5_create_policy $server_handle null {KADM5_POLICY}
909     } "EINVAL"
910     if { ! [cmd {kadm5_destroy $server_handle}]} {
911         perror "$test: unexpected failure in destroy"
912         return
913     }
914 }
915 test28
916
917 test "create-policy 30"
918 proc test30 {} {
919     global test
920     one_line_fail_test [format {
921         kadm5_create_policy null [simple_policy "%s/a"] \
922                 {KADM5_POLICY}
923     } $test] "BAD_SERVER_HANDLE"
924 }
925 test30
926
927 return ""