Imported Upstream version 0.10.0
[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      Some checks use the "contain" keyword to loosen the condition.
47      In that case, a "contain" subnode is added. Be sure to check for it
48      to know how the condition has to be checked.
49  *)
50 test Reprepro_Uploaders.entry get
51     "allow      source 'bash' and binaries contain 'bash-doc' by anybody\n" =
52
53   { "allow"
54     { "and"
55       { "or" = "source"
56               { "or" = "bash" } } }
57     { "and"
58       { "or" = "binaries"
59               { "contain" }
60               { "or" = "bash-doc" } } }
61     { "by" = "anybody" } }
62
63 (* Test: Reprepro_Uploaders.entry
64     Some checks support multiple values, separated by '|'.
65     In this case, each value gets added to an "or" subnode.
66  *)
67 test Reprepro_Uploaders.entry get
68
69     "allow      sections 'main'|'restricted' and source 'bash' or binaries contain 'bash-doc' by anybody\n" =
70
71   { "allow"
72     { "and"
73       { "or" = "sections"
74                { "or" =  "main" }
75                { "or" = "restricted" } } }
76     { "and"
77       { "or" = "source"
78                { "or" = "bash" } }
79       { "or" = "binaries"
80                { "contain" }
81                { "or" = "bash-doc" } } }
82     { "by" = "anybody" } }
83
84 (* Test: Reprepro_Uploaders.entry
85      Negated conditions are mapped with a "not" subnode. *)
86 test Reprepro_Uploaders.entry get
87
88     "allow  not source 'bash' by anybody\n" =
89
90   { "allow"
91     { "and"
92       { "or" = "source"
93          { "not" }
94          { "or" = "bash" } } }
95     { "by" = "anybody" } }
96
97
98
99 (* Variable: conf
100     A full configuration *)
101 let conf = "# ftpmaster
102 allow * by key 74BF771E
103
104 allow sections 'desktop/*' by anybody
105 allow sections 'gforge/*' and binaries contain 'bzr' or not source '*melanie*'|'katya' by any key
106 "
107
108 (* Test: Reprepro_Uploaders.lns
109      Testing the full <conf> against <Reprepro_Uploaders.lns> *)
110 test Reprepro_Uploaders.lns get conf =
111   { "#comment" = "ftpmaster" }
112   { "allow" = "*"
113     { "by" = "key"
114       { "key" = "74BF771E" } } }
115   { }
116   { "allow"
117     { "and" { "or" = "sections" { "or" = "desktop/*" } } }
118     { "by" = "anybody" } }
119   { "allow"
120     { "and" { "or" = "sections" { "or" = "gforge/*" } } }
121     { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } }
122             { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } }
123     { "by" = "key"
124       { "key" = "any" } } }