1load_lib lib.t
2api_exit
3api_start
4
5test "modify-policy 2"
6proc test2 {} {
7    global test
8
9    if {! ((  [policy_exists "$test/a"]) ||
10	   [create_policy "$test/a"])} {
11	    error_and_restart "$test: couldn't create policy \"$test/a\""
12	    return
13    }
14
15    if {! [cmd {
16	kadm5_init admin admin $KADM5_CHANGEPW_SERVICE null \
17		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
18		server_handle
19    }]} {
20	perror "$test: unexpected failure in init"
21	return
22    }
23    one_line_fail_test [format {
24	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
25		{KADM5_PW_MAX_LIFE}
26    } $test] "AUTH_MODIFY"
27    if { ! [cmd {kadm5_destroy $server_handle}]} {
28	perror "$test: unexpected failure in destroy"
29	return
30    }
31}
32if {$RPC} { test2 }
33
34test "modify-policy 8"
35proc test8 {} {
36    global test
37#    set prms_id 744
38#    setup_xfail {*-*-*} $prms_id
39
40    if {! ((  [policy_exists "$test/a"]) ||
41	   [create_policy "$test/a"])} {
42	    error_and_restart "$test: couldn't create policy \"$test/a\""
43	    return
44    }
45
46    if {! [cmd {
47	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
48		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
49		server_handle
50    }]} {
51	perror "$test: unexpected failure in init"
52	return
53    }
54    one_line_fail_test {
55	kadm5_modify_policy $server_handle [simple_policy ""] \
56		{KADM5_PW_MAX_LIFE}
57    } "BAD_POLICY"
58    if { ! [cmd {kadm5_destroy $server_handle}]} {
59	perror "$test: unexpected failure in destroy"
60	return
61    }
62}
63test8
64
65test "modify-policy 9"
66proc test9 {} {
67    global test
68    global prompt
69    if {! ((  [policy_exists "$test/a"]) ||
70	   [create_policy "$test/a"])} {
71	    error_and_restart "$test: couldn't create policy \"$test/a\""
72	    return
73    }
74
75    if {! [cmd {
76	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
77		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
78		server_handle
79    }]} {
80	perror "$test: unexpected failure in init"
81	return
82    }
83    if {! [cmd [format {
84	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
85		{KADM5_PW_MIN_LIFE}
86    } $test]]} {
87	fail $test
88	return
89    }
90    if {! [cmd [format {
91	kadm5_get_policy $server_handle "%s/a" policy
92    } $test]]} {
93	fail "$test: can not retrieve policy"
94	return
95    }
96    send "lindex \$policy 1\n"
97    expect {
98	-re "0\n$prompt$"		{ pass "$test" }
99	timeout				{ fail "$test" }
100    }
101
102    if { ! [cmd {kadm5_destroy $server_handle}]} {
103	perror "$test: unexpected failure in destroy"
104	return
105    }
106}
107test9
108
109test "modify-policy 10"
110proc test10 {} {
111    global test
112    global prompt
113    if {! ((  [policy_exists "$test/a"]) ||
114	   [create_policy "$test/a"])} {
115	    error_and_restart "$test: couldn't create policy \"$test/a\""
116	    return
117    }
118    if {! [cmd {
119	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
120		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
121		server_handle
122    }]} {
123	perror "$test: unexpected failure in init"
124	return
125    }
126    if {! [cmd [format {
127	kadm5_modify_policy $server_handle {"%s/a" 32 0 0 0 0 0} \
128		{KADM5_PW_MIN_LIFE}
129    } $test]]} {
130	fail $test
131	return
132    }
133    if {! [cmd [format {
134	kadm5_get_policy $server_handle "%s/a" policy
135    } $test]]} {
136	fail "$test: can not retrieve policy"
137	return
138    }
139    send "lindex \$policy 1\n"
140    expect {
141	-re "32\n$prompt$"		{ pass "$test" }
142	timeout				{ fail "$test" }
143    }
144    if { ! [cmd {kadm5_destroy $server_handle}]} {
145	perror "$test: unexpected failure in destroy"
146	return
147    }
148}
149test10
150
151
152test "modify-policy 11"
153proc test11 {} {
154    global test
155    global prompt
156
157    if {! ((  [policy_exists "$test/a"]) ||
158	   [create_policy "$test/a"])} {
159	    error_and_restart "$test: couldn't create policy \"$test/a\""
160	    return
161    }
162
163    if {! [cmd {
164	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
165		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
166		server_handle
167    }]} {
168	perror "$test: unexpected failure in init"
169	return
170    }
171    if {! [cmd [format {
172	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
173		{KADM5_PW_MAX_LIFE}
174    } $test]]} {
175	fail $test
176	return
177    }
178    if {! [cmd [format {
179	kadm5_get_policy $server_handle "%s/a" policy
180    } $test]]} {
181	fail "$test: can not retrieve policy"
182	return
183    }
184    send "lindex \$policy 2\n"
185    expect {
186	-re "0\n$prompt$"		{ pass "$test" }
187	timeout				{ fail "$test" }
188    }
189    if { ! [cmd {kadm5_destroy $server_handle}]} {
190	perror "$test: unexpected failure in destroy"
191	return
192    }
193}
194test11
195
196test "modify-policy 12"
197proc test12 {} {
198    global test
199    global prompt
200
201    if {! ((  [policy_exists "$test/a"]) ||
202	   [create_policy "$test/a"])} {
203	    error_and_restart "$test: couldn't create policy \"$test/a\""
204	    return
205    }
206
207    if {! [cmd {
208	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
209		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
210		server_handle
211    }]} {
212	perror "$test: unexpected failure in init"
213	return
214    }
215    if {! [cmd [format {
216	kadm5_modify_policy $server_handle {"%s/a" 0 32 0 0 0 0} \
217		{KADM5_PW_MAX_LIFE}
218    } $test]]} {
219	fail $test
220	return
221    }
222    if {! [cmd [format {
223	kadm5_get_policy $server_handle "%s/a" policy
224    } $test]]} {
225	fail "$test: can not retrieve policy"
226	return
227    }
228    send "lindex \$policy 2\n"
229    expect {
230	-re "32\n$prompt$"		{ pass "$test" }
231	timeout				{ fail "$test" }
232    }
233    if { ! [cmd {kadm5_destroy $server_handle}]} {
234	perror "$test: unexpected failure in destroy"
235	return
236    }
237}
238test12
239
240test "modify-policy 13"
241proc test13 {} {
242    global test
243    if {! ((  [policy_exists "$test/a"]) ||
244	   [create_policy "$test/a"])} {
245	    error_and_restart "$test: couldn't create policy \"$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_2 \
252		server_handle
253    }]} {
254	perror "$test: unexpected failure in init"
255	return
256    }
257    one_line_fail_test [format {
258	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
259		{KADM5_PW_MIN_LENGTH}
260    } $test] "BAD_LENGTH"
261    if { ! [cmd {kadm5_destroy $server_handle}]} {
262	perror "$test: unexpected failure in destroy"
263	return
264    }
265}
266test13
267
268test "modify-policy 14"
269proc test14 {} {
270    global test
271    global prompt
272
273    if {! ((  [policy_exists "$test/a"]) ||
274	   [create_policy "$test/a"])} {
275	    error_and_restart "$test: couldn't create policy \"$test/a\""
276	    return
277    }
278
279    if {! [cmd {
280	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
281		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
282		server_handle
283    }]} {
284	perror "$test: unexpected failure in init"
285	return
286    }
287    if {! [cmd [format {
288	kadm5_modify_policy $server_handle {"%s/a" 0 0 8 0 0 0} \
289		{KADM5_PW_MIN_LENGTH}
290    } $test]]} {
291	fail $test
292	return
293    }
294    if {! [cmd [format {
295	kadm5_get_policy $server_handle "%s/a" policy
296    } $test]]} {
297	fail "$test: can not retrieve policy"
298	return
299    }
300    send "lindex \$policy 3\n"
301    expect {
302	-re "8\n$prompt$"		{ pass "$test" }
303	timeout				{ fail "$test" }
304    }
305    if { ! [cmd {kadm5_destroy $server_handle}]} {
306	perror "$test: unexpected failure in destroy"
307	return
308    }
309}
310test14
311
312test "modify-policy 15"
313proc test15 {} {
314    global test
315    if {! ((  [policy_exists "$test/a"]) ||
316	   [create_policy "$test/a"])} {
317	    error_and_restart "$test: couldn't create policy \"$test/a\""
318	    return
319    }
320
321    if {! [cmd {
322	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
323		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
324		server_handle
325    }]} {
326	perror "$test: unexpected failure in init"
327	return
328    }
329    one_line_fail_test [format {
330	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
331		{KADM5_PW_MIN_CLASSES}
332    } $test] "BAD_CLASS"
333    if { ! [cmd {kadm5_destroy $server_handle}]} {
334	perror "$test: unexpected failure in destroy"
335	return
336    }
337}
338test15
339
340test "modify-policy 16"
341proc test16 {} {
342    global test
343    global prompt
344
345    if {! ((  [policy_exists "$test/a"]) ||
346	   [create_policy "$test/a"])} {
347	    error_and_restart "$test: couldn't create policy \"$test/a\""
348	    return
349    }
350
351    if {! [cmd {
352	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
353		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
354		server_handle
355    }]} {
356	perror "$test: unexpected failure in init"
357	return
358    }
359    if {! [cmd [format {
360	kadm5_modify_policy $server_handle {"%s/a" 0 0 0 1 0 0} \
361		{KADM5_PW_MIN_CLASSES}
362    } $test]]} {
363	fail $test
364	return
365    }
366    if {! [cmd [format {
367	kadm5_get_policy $server_handle "%s/a" policy
368    } $test]]} {
369	fail "$test: can not retrieve policy"
370	return
371    }
372    send "lindex \$policy 4\n"
373    expect {
374	-re "1\n$prompt$"		{ pass "$test" }
375	timeout				{ fail "$test" }
376    }
377
378
379    if { ! [cmd {kadm5_destroy $server_handle}]} {
380	perror "$test: unexpected failure in destroy"
381	return
382    }
383}
384test16
385
386test "modify-policy 17"
387proc test17 {} {
388    global test
389    global prompt
390
391    if {! ((  [policy_exists "$test/a"]) ||
392	   [create_policy "$test/a"])} {
393	    error_and_restart "$test: couldn't create policy \"$test/a\""
394	    return
395    }
396
397    if {! [cmd {
398	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
399		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
400		server_handle
401    }]} {
402	perror "$test: unexpected failure in init"
403	return
404    }
405    if {! [cmd [format {
406	kadm5_modify_policy $server_handle {"%s/a" 0 0 0 5 0 0} \
407		{KADM5_PW_MIN_CLASSES}
408    } $test]]} {
409	fail $test
410	return
411    }
412    if {! [cmd [format {
413	kadm5_get_policy $server_handle "%s/a" policy
414    } $test]]} {
415	fail "$test: can not retrieve policy"
416	return
417    }
418    send "lindex \$policy 4\n"
419    expect {
420	-re "5\n$prompt$"		{ pass "$test" }
421	timeout				{ fail "$test" }
422    }
423
424    if { ! [cmd {kadm5_destroy $server_handle}]} {
425	perror "$test: unexpected failure in destroy"
426	return
427    }
428}
429test17
430
431test "modify-policy 18"
432proc test18 {} {
433    global test
434    global prompt
435
436    if {! ((  [policy_exists "$test/a"]) ||
437	   [create_policy "$test/a" ])} {
438	    error_and_restart "$test: couldn't create policy \"$test/a\""
439	    return
440    }
441
442    if {! [cmd {
443	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
444		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
445		server_handle
446    }]} {
447	perror "$test: unexpected failure in init"
448	return
449    }
450    one_line_fail_test [format {
451	kadm5_modify_policy $server_handle {"%s/a" 0 0 0 6 0 0} \
452		{KADM5_PW_MIN_CLASSES}
453    } $test] "BAD_CLASS"
454    if { ! [cmd {kadm5_destroy $server_handle}]} {
455	perror "$test: unexpected failure in destroy"
456	return
457    }
458}
459test18
460
461test "modify-policy 19"
462proc test19 {} {
463    global test
464
465    if {! ((  [policy_exists "$test/a"]) ||
466	   [create_policy "$test/a" ])} {
467	    error_and_restart "$test: couldn't create policy \"$test/a\""
468	    return
469    }
470
471    if {! [cmd {
472	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
473		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
474		server_handle
475    }]} {
476	perror "$test: unexpected failure in init"
477	return
478    }
479    one_line_fail_test [format {
480	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
481		{KADM5_PW_HISTORY_NUM}
482    } $test] "BAD_HISTORY"
483    if { ! [cmd {kadm5_destroy $server_handle}]} {
484	perror "$test: unexpected failure in destroy"
485	return
486    }
487}
488test19
489
490test "modify-policy 20"
491proc test20 {} {
492    global test
493    global prompt
494
495    if {! ((  [policy_exists "$test/a"]) ||
496	   [create_policy "$test/a" ])} {
497	    error_and_restart "$test: couldn't create policy \"$test/a\""
498	    return
499    }
500
501    if {! [cmd {
502	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
503		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
504		server_handle
505    }]} {
506	perror "$test: unexpected failure in init"
507	return
508    }
509    if {! [cmd [format {
510	kadm5_modify_policy $server_handle {"%s/a" 0 0 0 0 1 0} \
511		{KADM5_PW_HISTORY_NUM}
512    } $test]]} {
513	fail $test
514	return
515    }
516    if {! [cmd [format {
517	kadm5_get_policy $server_handle "%s/a" policy
518    } $test]]} {
519	fail "$test: can not retrieve policy"
520	return
521    }
522    send "lindex \$policy 5\n"
523    expect {
524	-re "1\n$prompt$"		{ pass "$test" }
525	timeout				{ fail "$test" }
526    }
527
528    if { ! [cmd {kadm5_destroy $server_handle}]} {
529	perror "$test: unexpected failure in destroy"
530	return
531    }
532}
533test20
534
535test "modify-policy 21"
536proc test21 {} {
537    global test
538    global prompt
539
540    if {! ((  [policy_exists "$test/a"]) ||
541	   [create_policy "$test/a" ])} {
542	    error_and_restart "$test: couldn't create policy \"$test/a\""
543	    return
544    }
545
546    if {! [cmd {
547	kadm5_init admin admin $KADM5_ADMIN_SERVICE null \
548		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
549		server_handle
550    }]} {
551	perror "$test: unexpected failure in init"
552	return
553    }
554    if {! [cmd [format {
555	kadm5_modify_policy $server_handle {"%s/a" 0 0 0 0 10 0} \
556		{KADM5_PW_HISTORY_NUM}
557    } $test]]} {
558	fail $test
559	return
560    }
561    if {! [cmd [format {
562	kadm5_get_policy $server_handle "%s/a" policy
563    } $test]]} {
564	fail "$test: can not retrieve policy"
565	return
566    }
567    send "lindex \$policy 5\n"
568    expect {
569	-re "10\n$prompt$"		{ pass "$test" }
570	timeout				{ fail "$test" }
571    }
572
573    if { ! [cmd {kadm5_destroy $server_handle}]} {
574	perror "$test: unexpected failure in destroy"
575	return
576    }
577}
578test21
579
580test "modify-policy 22"
581proc test22 {} {
582    global test
583    if {! ((  [policy_exists "$test/a"]) ||
584	   [create_policy "$test/a" ])} {
585	    error_and_restart "$test: couldn't create policy \"$test/a\""
586	    return
587    }
588
589    if {! [cmd {
590	kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \
591		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
592		server_handle
593    }]} {
594	perror "$test: unexpected failure in init"
595	return
596    }
597    one_line_fail_test [format {
598	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
599		{KADM5_PW_MAX_LIFE}
600    } $test] "AUTH_MODIFY"
601    if { ! [cmd {kadm5_destroy $server_handle}]} {
602	perror "$test: unexpected failure in destroy"
603	return
604    }
605}
606if {$RPC} test22
607
608test "modify-policy 23"
609proc test23 {} {
610    global test
611    if {! ((  [policy_exists "$test/a"]) ||
612	   [create_policy "$test/a" ])} {
613	    error_and_restart "$test: couldn't create policy \"$test/a\""
614	    return
615    }
616
617    if {! [cmd {
618	kadm5_init admin/get admin $KADM5_ADMIN_SERVICE null \
619		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
620		server_handle
621    }]} {
622	perror "$test: unexpected failure in init"
623	return
624    }
625    one_line_fail_test [format {
626	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
627		{KADM5_PW_MAX_LIFE}
628    } $test] "AUTH_MODIFY"
629    if { ! [cmd {kadm5_destroy $server_handle}]} {
630	perror "$test: unexpected failure in destroy"
631	return
632    }
633}
634if {$RPC} test23
635
636test "modify-policy 26"
637proc test26 {} {
638    global test
639    if {! ((  [policy_exists "$test/a"]) ||
640	   [create_policy "$test/a" ])} {
641	    error_and_restart "$test: couldn't create policy \"$test/a\""
642	    return
643    }
644
645    if {! [cmd {
646	kadm5_init admin/modify admin $KADM5_ADMIN_SERVICE null \
647		$KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
648		server_handle
649    }]} {
650	perror "$test: unexpected failure in init"
651	return
652    }
653    one_line_succeed_test [format {
654	kadm5_modify_policy $server_handle [simple_policy "%s/a"] \
655		{KADM5_PW_MAX_LIFE}
656    } $test]
657    if { ! [cmd {kadm5_destroy $server_handle}]} {
658	perror "$test: unexpected failure in destroy"
659	return
660    }
661}
662test26
663
664test "modify-policy 30"
665proc test30 {} {
666    global test
667
668    one_line_fail_test [format {
669	kadm5_modify_policy null [simple_policy "%s/a"] \
670		{KADM5_PW_MAX_LIFE}
671    } $test] "BAD_SERVER_HANDLE"
672}
673test30
674
675return ""
676