1# CDDL HEADER START
2#
3# The contents of this file are subject to the terms of the
4# Common Development and Distribution License (the "License").
5# You may not use this file except in compliance with the License.
6#
7# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8# or http://www.opensolaris.org/os/licensing.
9# See the License for the specific language governing permissions
10# and limitations under the License.
11#
12# When distributing Covered Code, include this CDDL HEADER in each
13# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14# If applicable, add the following below this CDDL HEADER, with the
15# fields enclosed by brackets "[]" replaced with your own identifying
16# information: Portions Copyright [yyyy] [name of copyright owner]
17#
18# CDDL HEADER END
19#
20
21# $FreeBSD$
22
23#
24# Copyright 2012 Spectra Logic.  All rights reserved.
25# Use is subject to license terms.
26#
27
28
29atf_test_case zfs_allow_001_pos cleanup
30zfs_allow_001_pos_head()
31{
32	atf_set "descr" "everyone' is interpreted as a keyword even if a useror group named 'everyone' exists."
33	atf_set "require.progs" "ksh93 zfs sudo"
34}
35zfs_allow_001_pos_body()
36{
37	. $(atf_get_srcdir)/../../include/default.cfg
38	. $(atf_get_srcdir)/delegate_common.kshlib
39	. $(atf_get_srcdir)/delegate.cfg
40
41	verify_disk_count "$DISKS" 1
42	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
43	ksh93 $(atf_get_srcdir)/zfs_allow_001_pos.ksh || atf_fail "Testcase failed"
44}
45zfs_allow_001_pos_cleanup()
46{
47	. $(atf_get_srcdir)/../../include/default.cfg
48	. $(atf_get_srcdir)/delegate_common.kshlib
49	. $(atf_get_srcdir)/delegate.cfg
50
51	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
52}
53
54
55atf_test_case zfs_allow_002_pos cleanup
56zfs_allow_002_pos_head()
57{
58	atf_set "descr" "<user|group> is interpreted as user if possible, then as group."
59	atf_set "require.progs" "ksh93 zfs sudo"
60}
61zfs_allow_002_pos_body()
62{
63	. $(atf_get_srcdir)/../../include/default.cfg
64	. $(atf_get_srcdir)/delegate_common.kshlib
65	. $(atf_get_srcdir)/delegate.cfg
66
67	verify_disk_count "$DISKS" 1
68	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
69	ksh93 $(atf_get_srcdir)/zfs_allow_002_pos.ksh || atf_fail "Testcase failed"
70}
71zfs_allow_002_pos_cleanup()
72{
73	. $(atf_get_srcdir)/../../include/default.cfg
74	. $(atf_get_srcdir)/delegate_common.kshlib
75	. $(atf_get_srcdir)/delegate.cfg
76
77	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
78}
79
80
81atf_test_case zfs_allow_003_pos cleanup
82zfs_allow_003_pos_head()
83{
84	atf_set "descr" "Verify option '-l' only allow permission to the dataset itself."
85	atf_set "require.progs" "ksh93 zfs sudo"
86}
87zfs_allow_003_pos_body()
88{
89	. $(atf_get_srcdir)/../../include/default.cfg
90	. $(atf_get_srcdir)/delegate_common.kshlib
91	. $(atf_get_srcdir)/delegate.cfg
92
93	verify_disk_count "$DISKS" 1
94	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
95	ksh93 $(atf_get_srcdir)/zfs_allow_003_pos.ksh || atf_fail "Testcase failed"
96}
97zfs_allow_003_pos_cleanup()
98{
99	. $(atf_get_srcdir)/../../include/default.cfg
100	. $(atf_get_srcdir)/delegate_common.kshlib
101	. $(atf_get_srcdir)/delegate.cfg
102
103	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
104}
105
106
107atf_test_case zfs_allow_004_pos cleanup
108zfs_allow_004_pos_head()
109{
110	atf_set "descr" "Verify option '-d' allow permission to the descendent datasets."
111	atf_set "require.progs" "ksh93 zfs sudo"
112}
113zfs_allow_004_pos_body()
114{
115	. $(atf_get_srcdir)/../../include/default.cfg
116	. $(atf_get_srcdir)/delegate_common.kshlib
117	. $(atf_get_srcdir)/delegate.cfg
118
119	verify_disk_count "$DISKS" 1
120	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
121	ksh93 $(atf_get_srcdir)/zfs_allow_004_pos.ksh || atf_fail "Testcase failed"
122}
123zfs_allow_004_pos_cleanup()
124{
125	. $(atf_get_srcdir)/../../include/default.cfg
126	. $(atf_get_srcdir)/delegate_common.kshlib
127	. $(atf_get_srcdir)/delegate.cfg
128
129	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
130}
131
132
133atf_test_case zfs_allow_005_pos cleanup
134zfs_allow_005_pos_head()
135{
136	atf_set "descr" "Verify option '-c' will be granted locally to the creator."
137	atf_set "require.progs" "ksh93 zfs sudo"
138}
139zfs_allow_005_pos_body()
140{
141	. $(atf_get_srcdir)/../../include/default.cfg
142	. $(atf_get_srcdir)/delegate_common.kshlib
143	. $(atf_get_srcdir)/delegate.cfg
144
145	verify_disk_count "$DISKS" 1
146	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
147	ksh93 $(atf_get_srcdir)/zfs_allow_005_pos.ksh || atf_fail "Testcase failed"
148}
149zfs_allow_005_pos_cleanup()
150{
151	. $(atf_get_srcdir)/../../include/default.cfg
152	. $(atf_get_srcdir)/delegate_common.kshlib
153	. $(atf_get_srcdir)/delegate.cfg
154
155	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
156}
157
158
159atf_test_case zfs_allow_006_pos cleanup
160zfs_allow_006_pos_head()
161{
162	atf_set "descr" "Changing permissions in a set will change what is allowedwherever the set is used."
163	atf_set "require.progs" "ksh93 zfs sudo"
164}
165zfs_allow_006_pos_body()
166{
167	. $(atf_get_srcdir)/../../include/default.cfg
168	. $(atf_get_srcdir)/delegate_common.kshlib
169	. $(atf_get_srcdir)/delegate.cfg
170
171	verify_disk_count "$DISKS" 1
172	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
173	ksh93 $(atf_get_srcdir)/zfs_allow_006_pos.ksh || atf_fail "Testcase failed"
174}
175zfs_allow_006_pos_cleanup()
176{
177	. $(atf_get_srcdir)/../../include/default.cfg
178	. $(atf_get_srcdir)/delegate_common.kshlib
179	. $(atf_get_srcdir)/delegate.cfg
180
181	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
182}
183
184
185atf_test_case zfs_allow_007_pos cleanup
186zfs_allow_007_pos_head()
187{
188	atf_set "descr" "Verify permission set can be masked on descendent dataset."
189	atf_set "require.progs" "ksh93 zfs sudo"
190}
191zfs_allow_007_pos_body()
192{
193	. $(atf_get_srcdir)/../../include/default.cfg
194	. $(atf_get_srcdir)/delegate_common.kshlib
195	. $(atf_get_srcdir)/delegate.cfg
196
197	verify_disk_count "$DISKS" 1
198	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
199	ksh93 $(atf_get_srcdir)/zfs_allow_007_pos.ksh || atf_fail "Testcase failed"
200}
201zfs_allow_007_pos_cleanup()
202{
203	. $(atf_get_srcdir)/../../include/default.cfg
204	. $(atf_get_srcdir)/delegate_common.kshlib
205	. $(atf_get_srcdir)/delegate.cfg
206
207	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
208}
209
210
211atf_test_case zfs_allow_008_pos cleanup
212zfs_allow_008_pos_head()
213{
214	atf_set "descr" "Verify non-root user can allow permissions."
215	atf_set "require.progs" "ksh93 zfs sudo"
216}
217zfs_allow_008_pos_body()
218{
219	. $(atf_get_srcdir)/../../include/default.cfg
220	. $(atf_get_srcdir)/delegate_common.kshlib
221	. $(atf_get_srcdir)/delegate.cfg
222
223	verify_disk_count "$DISKS" 1
224	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
225	ksh93 $(atf_get_srcdir)/zfs_allow_008_pos.ksh || atf_fail "Testcase failed"
226}
227zfs_allow_008_pos_cleanup()
228{
229	. $(atf_get_srcdir)/../../include/default.cfg
230	. $(atf_get_srcdir)/delegate_common.kshlib
231	. $(atf_get_srcdir)/delegate.cfg
232
233	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
234}
235
236
237atf_test_case zfs_allow_009_neg cleanup
238zfs_allow_009_neg_head()
239{
240	atf_set "descr" "Verify invalid arguments are handled correctly."
241	atf_set "require.progs" "ksh93 zfs sudo"
242}
243zfs_allow_009_neg_body()
244{
245	. $(atf_get_srcdir)/../../include/default.cfg
246	. $(atf_get_srcdir)/delegate_common.kshlib
247	. $(atf_get_srcdir)/delegate.cfg
248
249	verify_disk_count "$DISKS" 1
250	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
251	ksh93 $(atf_get_srcdir)/zfs_allow_009_neg.ksh || atf_fail "Testcase failed"
252}
253zfs_allow_009_neg_cleanup()
254{
255	. $(atf_get_srcdir)/../../include/default.cfg
256	. $(atf_get_srcdir)/delegate_common.kshlib
257	. $(atf_get_srcdir)/delegate.cfg
258
259	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
260}
261
262
263atf_test_case zfs_allow_010_pos cleanup
264zfs_allow_010_pos_head()
265{
266	atf_set "descr" "Verify privileged user has correct permissions once which was delegated to him in datasets"
267	atf_set "require.progs" "ksh93 zfs sudo"
268}
269zfs_allow_010_pos_body()
270{
271	. $(atf_get_srcdir)/../../include/default.cfg
272	. $(atf_get_srcdir)/delegate_common.kshlib
273	. $(atf_get_srcdir)/delegate.cfg
274
275	verify_disk_count "$DISKS" 1
276	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
277	ksh93 $(atf_get_srcdir)/zfs_allow_010_pos.ksh || atf_fail "Testcase failed"
278}
279zfs_allow_010_pos_cleanup()
280{
281	. $(atf_get_srcdir)/../../include/default.cfg
282	. $(atf_get_srcdir)/delegate_common.kshlib
283	. $(atf_get_srcdir)/delegate.cfg
284
285	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
286}
287
288
289atf_test_case zfs_allow_011_neg cleanup
290zfs_allow_011_neg_head()
291{
292	atf_set "descr" "Verify zpool subcmds and system readonly properties can't be delegated."
293	atf_set "require.progs" "ksh93 zfs sudo"
294}
295zfs_allow_011_neg_body()
296{
297	. $(atf_get_srcdir)/../../include/default.cfg
298	. $(atf_get_srcdir)/delegate_common.kshlib
299	. $(atf_get_srcdir)/delegate.cfg
300
301	verify_disk_count "$DISKS" 1
302	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
303	ksh93 $(atf_get_srcdir)/zfs_allow_011_neg.ksh || atf_fail "Testcase failed"
304}
305zfs_allow_011_neg_cleanup()
306{
307	. $(atf_get_srcdir)/../../include/default.cfg
308	. $(atf_get_srcdir)/delegate_common.kshlib
309	. $(atf_get_srcdir)/delegate.cfg
310
311	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
312}
313
314
315atf_test_case zfs_allow_012_neg cleanup
316zfs_allow_012_neg_head()
317{
318	atf_set "descr" "Verify privileged user can not use permissions properly when delegation property is set off"
319	atf_set "require.progs" "ksh93 zfs sudo"
320}
321zfs_allow_012_neg_body()
322{
323	. $(atf_get_srcdir)/../../include/default.cfg
324	. $(atf_get_srcdir)/delegate_common.kshlib
325	. $(atf_get_srcdir)/delegate.cfg
326
327	verify_disk_count "$DISKS" 1
328	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
329	ksh93 $(atf_get_srcdir)/zfs_allow_012_neg.ksh || atf_fail "Testcase failed"
330}
331zfs_allow_012_neg_cleanup()
332{
333	. $(atf_get_srcdir)/../../include/default.cfg
334	. $(atf_get_srcdir)/delegate_common.kshlib
335	. $(atf_get_srcdir)/delegate.cfg
336
337	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
338}
339
340
341atf_init_test_cases()
342{
343
344	atf_add_test_case zfs_allow_001_pos
345	atf_add_test_case zfs_allow_002_pos
346	atf_add_test_case zfs_allow_003_pos
347	atf_add_test_case zfs_allow_004_pos
348	atf_add_test_case zfs_allow_005_pos
349	atf_add_test_case zfs_allow_006_pos
350	atf_add_test_case zfs_allow_007_pos
351	atf_add_test_case zfs_allow_008_pos
352	atf_add_test_case zfs_allow_009_neg
353	atf_add_test_case zfs_allow_010_pos
354	atf_add_test_case zfs_allow_011_neg
355	atf_add_test_case zfs_allow_012_neg
356}
357