Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_trapperkeeper.aug
1 module Test_Trapperkeeper =
2
3 (* Variable: config *)
4 let config = "
5   # This is a comment
6   webserver: {
7     bar: {
8         # A comment
9         host:           localhost
10         port=           9000
11         default-server: true
12     }
13
14     foo: {
15         host: localhost
16         port = 10000
17     }
18 }
19
20 jruby-puppet: {
21     # This setting determines where JRuby will look for gems.  It is also
22     # used by the `puppetserver gem` command line tool.
23     gem-home: /var/lib/puppet/jruby-gems
24
25     # (optional) path to puppet conf dir; if not specified, will use the puppet default
26     master-conf-dir: /etc/puppet
27
28     # (optional) path to puppet var dir; if not specified, will use the puppet default
29     master-var-dir: /var/lib/puppet
30
31     # (optional) maximum number of JRuby instances to allow; defaults to <num-cpus>+2
32     #max-active-instances: 1
33 }
34
35
36 # CA-related settings
37 certificate-authority: {
38
39     # settings for the certificate_status HTTP endpoint
40     certificate-status: {
41
42         # this setting contains a list of client certnames who are whitelisted to
43         # have access to the certificate_status endpoint.  Any requests made to
44         # this endpoint that do not present a valid client cert mentioned in
45         # this list will be denied access.
46         client-whitelist: []
47     }
48 }
49
50 os-settings: {
51     ruby-load-path: [/usr/lib/ruby/vendor_ruby, /home/foo/ruby ]
52 }
53 \n"
54
55 (* Test: Trapperkeeper.lns
56      Test full config file *)
57 test Trapperkeeper.lns get config =
58   {  }
59   { "#comment" = "This is a comment" }
60   { "@hash" = "webserver"
61     { "@hash" = "bar"
62       { "#comment" = "A comment" }
63       { "@simple" = "host" { "@value" = "localhost" } }
64       { "@simple" = "port" { "@value" = "9000" } }
65       { "@simple" = "default-server" { "@value" = "true" } }
66     }
67     {  }
68     { "@hash" = "foo"
69       { "@simple" = "host" { "@value" = "localhost" } }
70       { "@simple" = "port" { "@value" = "10000" } }
71     }
72   }
73   {  }
74   { "@hash" = "jruby-puppet"
75     { "#comment" = "This setting determines where JRuby will look for gems.  It is also" }
76     { "#comment" = "used by the `puppetserver gem` command line tool." }
77     { "@simple" = "gem-home" { "@value" = "/var/lib/puppet/jruby-gems" } }
78     {  }
79     { "#comment" = "(optional) path to puppet conf dir; if not specified, will use the puppet default" }
80     { "@simple" = "master-conf-dir" { "@value" = "/etc/puppet" } }
81     {  }
82     { "#comment" = "(optional) path to puppet var dir; if not specified, will use the puppet default" }
83     { "@simple" = "master-var-dir" { "@value" = "/var/lib/puppet" } }
84     {  }
85     { "#comment" = "(optional) maximum number of JRuby instances to allow; defaults to <num-cpus>+2" }
86     { "#comment" = "max-active-instances: 1" }
87   }
88   {  }
89   {  }
90   { "#comment" = "CA-related settings" }
91   { "@hash" = "certificate-authority"
92     { "#comment" = "settings for the certificate_status HTTP endpoint" }
93     { "@hash" = "certificate-status"
94       { "#comment" = "this setting contains a list of client certnames who are whitelisted to" }
95       { "#comment" = "have access to the certificate_status endpoint.  Any requests made to" }
96       { "#comment" = "this endpoint that do not present a valid client cert mentioned in" }
97       { "#comment" = "this list will be denied access." }
98       { "@array" = "client-whitelist" }
99     }
100   }
101   {  }
102   { "@hash" = "os-settings"
103     { "@array" = "ruby-load-path"
104       { "1" = "/usr/lib/ruby/vendor_ruby" }
105       { "2" = "/home/foo/ruby" }
106     }
107   }
108   {  }
109
110
111 (* Test: Trapperkeeper.lns
112      Should parse an empty file *)
113 test Trapperkeeper.lns get "\n" = {}
114
115 (* Test: Trapperkeeper.lns
116      Values can be quoted *)
117 test Trapperkeeper.lns get "os-settings: {
118     ruby-load-paths: [\"/usr/lib/ruby/site_ruby/1.8\"]
119 }\n" =
120   { "@hash" = "os-settings"
121     { "@array" = "ruby-load-paths"
122       { "1" = "/usr/lib/ruby/site_ruby/1.8" }
123     }
124   }
125
126 (* Test: Trapperkeeper.lns
127      Keys can be quoted *)
128 test Trapperkeeper.lns get "test: {
129   \"x\": true
130 }\n" =
131   { "@hash" = "test"
132     { "@simple" = "x" { "@value" = "true" } } }
133
134 (* Test: Trapperkeeper.lns
135      Keys can contain / (GH #7)
136 *)
137 test Trapperkeeper.lns get "test: {
138   \"x/y\" : z
139 }\n" =
140   { "@hash" = "test"
141     { "@simple" = "x/y" { "@value" = "z" } } }