Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_reprepro_uploaders.aug
1 (*
2 Module: Test_Reprepro_Uploaders
3   Provides unit tests and examples for the <Reprepro_Uploaders> lens.
4 *)
5
6 module Test_Reprepro_Uploaders =
7
8 (* Test: Reprepro_Uploaders.entry
9      A star condition gets mapped as direct value
10      of the "allow" node.
11  *)
12 test Reprepro_Uploaders.entry get
13     "allow * by anybody\n" =
14
15   { "allow" = "*"
16           { "by" = "anybody" } }
17
18 (* Test: Reprepro_Uploaders.entry
19      For simple keys, the "by" node gets the value "key"
20      and the key ID gets mapped in a "key" subnode.
21  *)
22 test Reprepro_Uploaders.entry get
23     "allow * by key ABCD1234\n" =
24
25   { "allow" = "*"
26           { "by" = "key"
27              { "key" = "ABCD1234" } } }
28
29 (* Test: Reprepro_Uploaders.entry
30      Conditions are mapped inside a tree containing
31      at least an "and" node and an "or" subnode.
32
33      The value of each "or" subnode is the type of check
34      (e.g. "source"), and this node contains "or" subnodes
35      with the value(s) allowed for the check (e.g. "bash"). *)
36 test Reprepro_Uploaders.entry get
37     "allow      source 'bash' by anybody\n" =
38
39   { "allow"
40     { "and"
41       { "or" = "source"
42               { "or" = "bash" } } }
43     { "by" = "anybody" } }
44
45 (* Test: Reprepro_Uploaders.entry
46      Check the field distribution *)
47 test Reprepro_Uploaders.entry get
48     "allow      distribution 'sid' by anybody\n" =
49
50   { "allow"
51     { "and"
52       { "or" = "distribution"
53               { "or" = "sid" } } }
54     { "by" = "anybody" } }
55
56 (* Test: Reprepro_Uploaders.entry
57      Some checks use the "contain" keyword to loosen the condition.
58      In that case, a "contain" subnode is added. Be sure to check for it
59      to know how the condition has to be checked.
60  *)
61 test Reprepro_Uploaders.entry get
62     "allow      source 'bash' and binaries contain 'bash-doc' by anybody\n" =
63
64   { "allow"
65     { "and"
66       { "or" = "source"
67               { "or" = "bash" } } }
68     { "and"
69       { "or" = "binaries"
70               { "contain" }
71               { "or" = "bash-doc" } } }
72     { "by" = "anybody" } }
73
74 (* Test: Reprepro_Uploaders.entry
75     Some checks support multiple values, separated by '|'.
76     In this case, each value gets added to an "or" subnode.
77  *)
78 test Reprepro_Uploaders.entry get
79
80     "allow      sections 'main'|'restricted' and source 'bash' or binaries contain 'bash-doc' by anybody\n" =
81
82   { "allow"
83     { "and"
84       { "or" = "sections"
85                { "or" =  "main" }
86                { "or" = "restricted" } } }
87     { "and"
88       { "or" = "source"
89                { "or" = "bash" } }
90       { "or" = "binaries"
91                { "contain" }
92                { "or" = "bash-doc" } } }
93     { "by" = "anybody" } }
94
95 (* Test: Reprepro_Uploaders.entry
96      Negated conditions are mapped with a "not" subnode. *)
97 test Reprepro_Uploaders.entry get
98
99     "allow  not source 'bash' by anybody\n" =
100
101   { "allow"
102     { "and"
103       { "or" = "source"
104          { "not" }
105          { "or" = "bash" } } }
106     { "by" = "anybody" } }
107
108
109
110 (* Variable: conf
111     A full configuration *)
112 let conf = "# ftpmaster
113 allow * by key 74BF771E
114
115 allow sections 'desktop/*' by anybody
116 allow sections 'gforge/*' and binaries contain 'bzr' or not source '*melanie*'|'katya' by any key
117 "
118
119 (* Test: Reprepro_Uploaders.lns
120      Testing the full <conf> against <Reprepro_Uploaders.lns> *)
121 test Reprepro_Uploaders.lns get conf =
122   { "#comment" = "ftpmaster" }
123   { "allow" = "*"
124     { "by" = "key"
125       { "key" = "74BF771E" } } }
126   { }
127   { "allow"
128     { "and" { "or" = "sections" { "or" = "desktop/*" } } }
129     { "by" = "anybody" } }
130   { "allow"
131     { "and" { "or" = "sections" { "or" = "gforge/*" } } }
132     { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } }
133             { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } }
134     { "by" = "key"
135       { "key" = "any" } } }
136
137 (* Test: Reprepro_Uploaders.lns
138      Support group conditions, GH #283 *)
139 test Reprepro_Uploaders.lns get "allow sections 'desktop/*' by group groupname\n" =
140   { "allow"
141     { "and" { "or" = "sections" { "or" = "desktop/*" } } }
142     { "by" = "group" { "group" = "groupname" } } }
143
144 (* Test: Reprepro_Uploaders.lns
145      Declare group condition, GH #283 *)
146 test Reprepro_Uploaders.lns get "group groupname add key-id\n" =
147   { "group" = "groupname"
148     { "add" = "key-id" } }
149
150 (* Test: Reprepro_Uploaders.lns
151      Group inheritance, GH #283 *)
152 test Reprepro_Uploaders.lns get "group groupname contains group2\n" =
153   { "group" = "groupname"
154     { "contains" = "group2" } }
155
156 (* Test: Reprepro_Uploaders.lns
157      Empty group, GH #283 *)
158 test Reprepro_Uploaders.lns get "group groupname empty\n" =
159   { "group" = "groupname"
160     { "empty" } }
161
162 (* Test: Reprepro_Uploaders.lns
163      Unused group, GH #283 *)
164 test Reprepro_Uploaders.lns get "group groupname unused\n" =
165   { "group" = "groupname"
166     { "unused" } }