2 Module: Test_Reprepro_Uploaders
3 Provides unit tests and examples for the <Reprepro_Uploaders> lens.
6 module Test_Reprepro_Uploaders =
8 (* Test: Reprepro_Uploaders.entry
9 A star condition gets mapped as direct value
12 test Reprepro_Uploaders.entry get
13 "allow * by anybody\n" =
16 { "by" = "anybody" } }
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.
22 test Reprepro_Uploaders.entry get
23 "allow * by key ABCD1234\n" =
27 { "key" = "ABCD1234" } } }
29 (* Test: Reprepro_Uploaders.entry
30 Conditions are mapped inside a tree containing
31 at least an "and" node and an "or" subnode.
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" =
43 { "by" = "anybody" } }
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.
50 test Reprepro_Uploaders.entry get
51 "allow source 'bash' and binaries contain 'bash-doc' by anybody\n" =
60 { "or" = "bash-doc" } } }
61 { "by" = "anybody" } }
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.
67 test Reprepro_Uploaders.entry get
69 "allow sections 'main'|'restricted' and source 'bash' or binaries contain 'bash-doc' by anybody\n" =
75 { "or" = "restricted" } } }
81 { "or" = "bash-doc" } } }
82 { "by" = "anybody" } }
84 (* Test: Reprepro_Uploaders.entry
85 Negated conditions are mapped with a "not" subnode. *)
86 test Reprepro_Uploaders.entry get
88 "allow not source 'bash' by anybody\n" =
95 { "by" = "anybody" } }
100 A full configuration *)
101 let conf = "# ftpmaster
102 allow * by key 74BF771E
104 allow sections 'desktop/*' by anybody
105 allow sections 'gforge/*' and binaries contain 'bzr' or not source '*melanie*'|'katya' by any key
108 (* Test: Reprepro_Uploaders.lns
109 Testing the full <conf> against <Reprepro_Uploaders.lns> *)
110 test Reprepro_Uploaders.lns get conf =
111 { "#comment" = "ftpmaster" }
114 { "key" = "74BF771E" } } }
117 { "and" { "or" = "sections" { "or" = "desktop/*" } } }
118 { "by" = "anybody" } }
120 { "and" { "or" = "sections" { "or" = "gforge/*" } } }
121 { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } }
122 { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } }
124 { "key" = "any" } } }