]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/history/history_009_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / history / history_009_pos.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/tests/functional/history/history_common.kshlib
33
34 #
35 # DESCRIPTION:
36 #       Verify the delegation internal history are correctly.
37 #
38 # STRATEGY:
39 #       1. Create test group and user.
40 #       2. Define permission sets and verify the internal history correctly.
41 #       3. Separately verify the internal history above is correct.
42 #
43
44 verify_runnable "global"
45
46 function cleanup
47 {
48         del_user $HIST_USER
49         del_group $HIST_GROUP
50 }
51
52 log_assert "Verify delegated commands are logged in the pool history."
53 log_onexit cleanup
54
55 testfs=$TESTPOOL/$TESTFS
56 # Create history test group and user and get user id and group id
57 add_group $HIST_GROUP
58 add_user $HIST_GROUP $HIST_USER
59
60 #       subcmd          allow_options
61 array=( "allow"         "-s @basic snapshot"
62         "allow"         "-s @set @basic"
63         "allow"         "-c create"
64         "unallow"       "-c create"
65         "allow"         "-c @set"
66         "unallow"       "-c @set"
67         "allow"         "-l -u $HIST_USER snapshot"
68         "allow"         "-u $HIST_USER snapshot"
69         "unallow"       "-u $HIST_USER snapshot"
70         "allow"         "-l -u $HIST_USER @set"
71         "allow"         "-u $HIST_USER @set"
72         "unallow"       "-u $HIST_USER @set"
73         "allow"         "-d -u $HIST_USER snapshot"
74         "allow"         "-u $HIST_USER snapshot"
75         "unallow"       "-u $HIST_USER snapshot"
76         "allow"         "-d -u $HIST_USER @set"
77         "allow"         "-u $HIST_USER @set"
78         "unallow"       "-u $HIST_USER @set"
79         "allow"         "-l -g $HIST_GROUP snapshot"
80         "allow"         "-g $HIST_GROUP snapshot"
81         "unallow"       "-g $HIST_GROUP snapshot"
82         "allow"         "-l -g $HIST_GROUP @set"
83         "allow"         "-g $HIST_GROUP @set"
84         "unallow"       "-g $HIST_GROUP @set"
85         "allow"         "-d -g $HIST_GROUP snapshot"
86         "allow"         "-g $HIST_GROUP snapshot"
87         "unallow"       "-g $HIST_GROUP snapshot"
88         "allow"         "-d -g $HIST_GROUP @set"
89         "allow"         "-g $HIST_GROUP @set"
90         "unallow"       "-g $HIST_GROUP @set"
91         "allow"         "-l -e snapshot"
92         "allow"         "-e snapshot"
93         "unallow"       "-e snapshot"
94         "allow"         "-l -e @set"
95         "allow"         "-e @set"
96         "unallow"       "-e @set"
97         "allow"         "-d -e snapshot"
98         "allow"         "-e snapshot"
99         "unallow"       "-e snapshot"
100         "allow"         "-d -e @set"
101         "allow"         "-e @set"
102         "unallow"       "-e @set"
103 )
104
105 typeset -i i=0
106 while ((i < ${#array[@]})); do
107         subcmd=${array[$i]}
108         options=${array[((i + 1))]}
109
110         run_and_verify "zfs $subcmd $options $testfs" "-i"
111         ((i += 2))
112 done
113
114 log_pass "Verify delegated commands are logged in the pool history."