Provides unit tests and examples for the Reprepro_Uploaders lens.
Test_Reprepro_Uploaders | Provides unit tests and examples for the Reprepro_Uploaders lens. |
Augeas Tests | |
Reprepro_Uploaders. | A star condition gets mapped as direct value of the “allow” node. |
Reprepro_Uploaders. | For simple keys, the “by” node gets the value “key” and the key ID gets mapped in a “key” subnode. |
Reprepro_Uploaders. | Conditions are mapped inside a tree containing at least an “and” node and an “or” subnode. |
Reprepro_Uploaders. | Some checks use the “contain” keyword to loosen the condition. |
Reprepro_Uploaders. | Some checks support multiple values, separated by ‘|’. |
Reprepro_Uploaders. | Negated conditions are mapped with a “not” subnode. |
Augeas Variables | |
conf | A full configuration |
Augeas Tests | |
Reprepro_Uploaders.lns | Testing the full conf against Reprepro_Uploaders.lns |
test Reprepro_Uploaders.entry get "allow source 'bash' by anybody\n" = { "allow" { "and" { "or" = "source" { "or" = "bash" } } } { "by" = "anybody" } }
Conditions are mapped inside a tree containing at least an “and” node and an “or” subnode.
The value of each “or” subnode is the type of check (e.g. “source”), and this node contains “or” subnodes with the value(s) allowed for the check (e.g. “bash”).
test Reprepro_Uploaders.entry get "allow source 'bash' and binaries contain 'bash-doc' by anybody\n" = { "allow" { "and" { "or" = "source" { "or" = "bash" } } } { "and" { "or" = "binaries" { "contain" } { "or" = "bash-doc" } } } { "by" = "anybody" } }
Some checks use the “contain” keyword to loosen the condition. In that case, a “contain” subnode is added. Be sure to check for it to know how the condition has to be checked.
test Reprepro_Uploaders.entry get "allow sections 'main'|'restricted' and source 'bash' or binaries contain 'bash-doc' by anybody\n" = { "allow" { "and" { "or" = "sections" { "or" = "main" } { "or" = "restricted" } } } { "and" { "or" = "source" { "or" = "bash" } } { "or" = "binaries" { "contain" } { "or" = "bash-doc" } } } { "by" = "anybody" } }
Some checks support multiple values, separated by ‘|’. In this case, each value gets added to an “or” subnode.
test Reprepro_Uploaders.lns get conf = { "#comment" = "ftpmaster" } { "allow" = "*" { "by" = "key" { "key" = "74BF771E" } } } { } { "allow" { "and" { "or" = "sections" { "or" = "desktop/*" } } } { "by" = "anybody" } } { "allow" { "and" { "or" = "sections" { "or" = "gforge/*" } } } { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } } { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } } { "by" = "key" { "key" = "any" } } }
Testing the full conf against Reprepro_Uploaders.lns
A star condition gets mapped as direct value of the “allow” node.
test Reprepro_Uploaders.entry get "allow * by anybody\n" = { "allow" = "*" { "by" = "anybody" } }
A full configuration
let conf = "# ftpmaster allow * by key 74BF771E allow sections 'desktop/*' by anybody allow sections 'gforge/*' and binaries contain 'bzr' or not source '*melanie*'|'katya' by any key "
Testing the full conf against Reprepro_Uploaders.lns
test Reprepro_Uploaders.lns get conf = { "#comment" = "ftpmaster" } { "allow" = "*" { "by" = "key" { "key" = "74BF771E" } } } { } { "allow" { "and" { "or" = "sections" { "or" = "desktop/*" } } } { "by" = "anybody" } } { "allow" { "and" { "or" = "sections" { "or" = "gforge/*" } } } { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } } { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } } { "by" = "key" { "key" = "any" } } }