Test_Reprepro_Uploaders

Provides unit tests and examples for the Reprepro_Uploaders lens.

Summary
Test_Reprepro_UploadersProvides unit tests and examples for the Reprepro_Uploaders lens.
Augeas Tests
Reprepro_Uploaders.entryA star condition gets mapped as direct value of the “allow” node.
Reprepro_Uploaders.entryFor simple keys, the “by” node gets the value “key” and the key ID gets mapped in a “key” subnode.
Reprepro_Uploaders.entryConditions are mapped inside a tree containing at least an “and” node and an “or” subnode.
Reprepro_Uploaders.entrySome checks use the “contain” keyword to loosen the condition.
Reprepro_Uploaders.entrySome checks support multiple values, separated by ‘|’.
Reprepro_Uploaders.entryNegated conditions are mapped with a “not” subnode.
Augeas Variables
confA full configuration
Augeas Tests
Reprepro_Uploaders.lnsTesting the full conf against Reprepro_Uploaders.lns

Augeas Tests

Reprepro_Uploaders.entry

test Reprepro_Uploaders.entry get "allow * by anybody\n" = { "allow" = "*" { "by" = "anybody" } }

A star condition gets mapped as direct value of the “allow” node.

Reprepro_Uploaders.entry

test Reprepro_Uploaders.entry get "allow * by key ABCD1234\n" = { "allow" = "*" { "by" = "key" { "key" = "ABCD1234" } } }

For simple keys, the “by” node gets the value “key” and the key ID gets mapped in a “key” subnode.

Reprepro_Uploaders.entry

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”).

Reprepro_Uploaders.entry

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.

Reprepro_Uploaders.entry

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.

Reprepro_Uploaders.entry

test Reprepro_Uploaders.entry get "allow not source 'bash' by anybody\n" = { "allow" { "and" { "or" = "source" { "not" } { "or" = "bash" } } } { "by" = "anybody" } }

Negated conditions are mapped with a “not” subnode.

Augeas Variables

conf

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 "

A full configuration

Augeas Tests

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" } } }

Testing the full conf against Reprepro_Uploaders.lns

Parses reprepro’s uploaders files
test Reprepro_Uploaders.entry get "allow * by anybody\n" = { "allow" = "*" { "by" = "anybody" } }
A star condition gets mapped as direct value of the “allow” node.
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 "
A full configuration
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
Close