service_kiosk 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. data/Vagrantfile +25 -0
  2. data/bin/kiosk +55 -0
  3. data/bin/start_kiosk.sh +3 -0
  4. data/lib/Procfile.kiosk +1 -0
  5. data/lib/internal_service.rb +59 -0
  6. data/lib/json-simple-1.1.1.jar +0 -0
  7. data/lib/kiosk.rb +57 -0
  8. data/lib/kiosks/logger/output_logger.rb +16 -0
  9. data/lib/mall.rb +77 -0
  10. data/lib/mallcop.rb +9 -0
  11. data/lib/remote_service.rb +61 -0
  12. data/lib/tasks/local_mall.rake +93 -0
  13. data/provision/bootstrap.sh +21 -0
  14. data/provision/manifests/default.pp +49 -0
  15. data/provision/modules/apt/CHANGELOG +83 -0
  16. data/provision/modules/apt/LICENSE +19 -0
  17. data/provision/modules/apt/Modulefile +14 -0
  18. data/provision/modules/apt/README.md +119 -0
  19. data/provision/modules/apt/Rakefile +1 -0
  20. data/provision/modules/apt/manifests/backports.pp +48 -0
  21. data/provision/modules/apt/manifests/builddep.pp +16 -0
  22. data/provision/modules/apt/manifests/conf.pp +18 -0
  23. data/provision/modules/apt/manifests/debian/testing.pp +21 -0
  24. data/provision/modules/apt/manifests/debian/unstable.pp +21 -0
  25. data/provision/modules/apt/manifests/force.pp +24 -0
  26. data/provision/modules/apt/manifests/init.pp +114 -0
  27. data/provision/modules/apt/manifests/key.pp +80 -0
  28. data/provision/modules/apt/manifests/params.pp +23 -0
  29. data/provision/modules/apt/manifests/pin.pp +48 -0
  30. data/provision/modules/apt/manifests/ppa.pp +49 -0
  31. data/provision/modules/apt/manifests/release.pp +17 -0
  32. data/provision/modules/apt/manifests/source.pp +83 -0
  33. data/provision/modules/apt/manifests/update.pp +9 -0
  34. data/provision/modules/apt/spec/classes/apt_spec.rb +129 -0
  35. data/provision/modules/apt/spec/classes/backports_spec.rb +71 -0
  36. data/provision/modules/apt/spec/classes/debian_testing_spec.rb +14 -0
  37. data/provision/modules/apt/spec/classes/debian_unstable_spec.rb +14 -0
  38. data/provision/modules/apt/spec/classes/params_spec.rb +13 -0
  39. data/provision/modules/apt/spec/classes/release_spec.rb +22 -0
  40. data/provision/modules/apt/spec/defines/builddep_spec.rb +18 -0
  41. data/provision/modules/apt/spec/defines/conf_spec.rb +57 -0
  42. data/provision/modules/apt/spec/defines/force_spec.rb +41 -0
  43. data/provision/modules/apt/spec/defines/key_spec.rb +123 -0
  44. data/provision/modules/apt/spec/defines/pin_spec.rb +58 -0
  45. data/provision/modules/apt/spec/defines/ppa_spec.rb +92 -0
  46. data/provision/modules/apt/spec/defines/source_spec.rb +158 -0
  47. data/provision/modules/apt/spec/fixtures/manifests/site.pp +0 -0
  48. data/provision/modules/apt/spec/spec_helper.rb +1 -0
  49. data/provision/modules/apt/templates/pin.pref.erb +5 -0
  50. data/provision/modules/apt/templates/source.list.erb +5 -0
  51. data/provision/modules/apt/tests/builddep.pp +2 -0
  52. data/provision/modules/apt/tests/debian/testing.pp +2 -0
  53. data/provision/modules/apt/tests/debian/unstable.pp +2 -0
  54. data/provision/modules/apt/tests/force.pp +7 -0
  55. data/provision/modules/apt/tests/init.pp +1 -0
  56. data/provision/modules/apt/tests/key.pp +5 -0
  57. data/provision/modules/apt/tests/params.pp +1 -0
  58. data/provision/modules/apt/tests/pin.pp +5 -0
  59. data/provision/modules/apt/tests/ppa.pp +4 -0
  60. data/provision/modules/apt/tests/release.pp +4 -0
  61. data/provision/modules/apt/tests/source.pp +29 -0
  62. data/provision/modules/stdlib/CHANGELOG +177 -0
  63. data/provision/modules/stdlib/LICENSE +19 -0
  64. data/provision/modules/stdlib/Modulefile +11 -0
  65. data/provision/modules/stdlib/README.markdown +929 -0
  66. data/provision/modules/stdlib/README_DEVELOPER.markdown +35 -0
  67. data/provision/modules/stdlib/RELEASE_PROCESS.markdown +24 -0
  68. data/provision/modules/stdlib/Rakefile +2 -0
  69. data/provision/modules/stdlib/lib/facter/pe_version.rb +53 -0
  70. data/provision/modules/stdlib/lib/facter/puppet_vardir.rb +26 -0
  71. data/provision/modules/stdlib/lib/facter/root_home.rb +19 -0
  72. data/provision/modules/stdlib/lib/facter/util/puppet_settings.rb +21 -0
  73. data/provision/modules/stdlib/lib/puppet/parser/functions/abs.rb +36 -0
  74. data/provision/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +49 -0
  75. data/provision/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +34 -0
  76. data/provision/modules/stdlib/lib/puppet/parser/functions/chomp.rb +35 -0
  77. data/provision/modules/stdlib/lib/puppet/parser/functions/chop.rb +37 -0
  78. data/provision/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +35 -0
  79. data/provision/modules/stdlib/lib/puppet/parser/functions/delete.rb +46 -0
  80. data/provision/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +49 -0
  81. data/provision/modules/stdlib/lib/puppet/parser/functions/downcase.rb +33 -0
  82. data/provision/modules/stdlib/lib/puppet/parser/functions/empty.rb +28 -0
  83. data/provision/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +24 -0
  84. data/provision/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +35 -0
  85. data/provision/modules/stdlib/lib/puppet/parser/functions/flatten.rb +33 -0
  86. data/provision/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +46 -0
  87. data/provision/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +17 -0
  88. data/provision/modules/stdlib/lib/puppet/parser/functions/getvar.rb +26 -0
  89. data/provision/modules/stdlib/lib/puppet/parser/functions/grep.rb +33 -0
  90. data/provision/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +52 -0
  91. data/provision/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +25 -0
  92. data/provision/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +25 -0
  93. data/provision/modules/stdlib/lib/puppet/parser/functions/has_key.rb +28 -0
  94. data/provision/modules/stdlib/lib/puppet/parser/functions/hash.rb +41 -0
  95. data/provision/modules/stdlib/lib/puppet/parser/functions/is_array.rb +22 -0
  96. data/provision/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +47 -0
  97. data/provision/modules/stdlib/lib/puppet/parser/functions/is_float.rb +27 -0
  98. data/provision/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +22 -0
  99. data/provision/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +27 -0
  100. data/provision/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +32 -0
  101. data/provision/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +27 -0
  102. data/provision/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +27 -0
  103. data/provision/modules/stdlib/lib/puppet/parser/functions/is_string.rb +26 -0
  104. data/provision/modules/stdlib/lib/puppet/parser/functions/join.rb +41 -0
  105. data/provision/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +47 -0
  106. data/provision/modules/stdlib/lib/puppet/parser/functions/keys.rb +26 -0
  107. data/provision/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +20 -0
  108. data/provision/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +33 -0
  109. data/provision/modules/stdlib/lib/puppet/parser/functions/max.rb +13 -0
  110. data/provision/modules/stdlib/lib/puppet/parser/functions/member.rb +44 -0
  111. data/provision/modules/stdlib/lib/puppet/parser/functions/merge.rb +33 -0
  112. data/provision/modules/stdlib/lib/puppet/parser/functions/min.rb +13 -0
  113. data/provision/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +40 -0
  114. data/provision/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +24 -0
  115. data/provision/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +24 -0
  116. data/provision/modules/stdlib/lib/puppet/parser/functions/pick.rb +29 -0
  117. data/provision/modules/stdlib/lib/puppet/parser/functions/prefix.rb +45 -0
  118. data/provision/modules/stdlib/lib/puppet/parser/functions/range.rb +80 -0
  119. data/provision/modules/stdlib/lib/puppet/parser/functions/reject.rb +31 -0
  120. data/provision/modules/stdlib/lib/puppet/parser/functions/reverse.rb +28 -0
  121. data/provision/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +32 -0
  122. data/provision/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +46 -0
  123. data/provision/modules/stdlib/lib/puppet/parser/functions/size.rb +48 -0
  124. data/provision/modules/stdlib/lib/puppet/parser/functions/sort.rb +27 -0
  125. data/provision/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +36 -0
  126. data/provision/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +41 -0
  127. data/provision/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +32 -0
  128. data/provision/modules/stdlib/lib/puppet/parser/functions/strftime.rb +107 -0
  129. data/provision/modules/stdlib/lib/puppet/parser/functions/strip.rb +39 -0
  130. data/provision/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +39 -0
  131. data/provision/modules/stdlib/lib/puppet/parser/functions/time.rb +49 -0
  132. data/provision/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +28 -0
  133. data/provision/modules/stdlib/lib/puppet/parser/functions/type.rb +50 -0
  134. data/provision/modules/stdlib/lib/puppet/parser/functions/unique.rb +51 -0
  135. data/provision/modules/stdlib/lib/puppet/parser/functions/upcase.rb +41 -0
  136. data/provision/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +36 -0
  137. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +56 -0
  138. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +33 -0
  139. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +34 -0
  140. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +33 -0
  141. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +40 -0
  142. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +52 -0
  143. data/provision/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +33 -0
  144. data/provision/modules/stdlib/lib/puppet/parser/functions/values.rb +39 -0
  145. data/provision/modules/stdlib/lib/puppet/parser/functions/values_at.rb +98 -0
  146. data/provision/modules/stdlib/lib/puppet/parser/functions/zip.rb +65 -0
  147. data/provision/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +59 -0
  148. data/provision/modules/stdlib/lib/puppet/type/anchor.rb +41 -0
  149. data/provision/modules/stdlib/lib/puppet/type/file_line.rb +70 -0
  150. data/provision/modules/stdlib/manifests/init.pp +20 -0
  151. data/provision/modules/stdlib/manifests/stages.pp +43 -0
  152. data/provision/modules/stdlib/spec/functions/defined_with_params_spec.rb +37 -0
  153. data/provision/modules/stdlib/spec/functions/ensure_packages_spec.rb +42 -0
  154. data/provision/modules/stdlib/spec/functions/ensure_resource_spec.rb +40 -0
  155. data/provision/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb +8 -0
  156. data/provision/modules/stdlib/spec/monkey_patches/publicize_methods.rb +10 -0
  157. data/provision/modules/stdlib/spec/spec.opts +6 -0
  158. data/provision/modules/stdlib/spec/spec_helper.rb +28 -0
  159. data/provision/modules/stdlib/spec/unit/facter/pe_version_spec.rb +76 -0
  160. data/provision/modules/stdlib/spec/unit/facter/root_home_spec.rb +40 -0
  161. data/provision/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb +35 -0
  162. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/abs_spec.rb +25 -0
  163. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/bool2num_spec.rb +24 -0
  164. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/capitalize_spec.rb +19 -0
  165. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/chomp_spec.rb +19 -0
  166. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/chop_spec.rb +19 -0
  167. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/delete_at_spec.rb +19 -0
  168. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/delete_spec.rb +38 -0
  169. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/downcase_spec.rb +24 -0
  170. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/empty_spec.rb +23 -0
  171. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/flatten_spec.rb +23 -0
  172. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb +33 -0
  173. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/get_module_path_spec.rb +46 -0
  174. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/getvar_spec.rb +37 -0
  175. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/grep_spec.rb +19 -0
  176. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_interface_with_spec.rb +64 -0
  177. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_address_spec.rb +39 -0
  178. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_network_spec.rb +36 -0
  179. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_key_spec.rb +42 -0
  180. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/hash_spec.rb +19 -0
  181. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_array_spec.rb +29 -0
  182. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +64 -0
  183. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_float_spec.rb +29 -0
  184. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_hash_spec.rb +29 -0
  185. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_integer_spec.rb +29 -0
  186. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +39 -0
  187. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +29 -0
  188. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_numeric_spec.rb +29 -0
  189. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_string_spec.rb +34 -0
  190. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb +40 -0
  191. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/join_spec.rb +19 -0
  192. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/keys_spec.rb +21 -0
  193. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/lstrip_spec.rb +19 -0
  194. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/max_spec.rb +23 -0
  195. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/member_spec.rb +24 -0
  196. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/merge_spec.rb +47 -0
  197. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/min_spec.rb +23 -0
  198. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/num2bool_spec.rb +24 -0
  199. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb +22 -0
  200. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/parseyaml_spec.rb +24 -0
  201. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/pick_spec.rb +34 -0
  202. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/prefix_spec.rb +19 -0
  203. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/range_spec.rb +34 -0
  204. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/reject_spec.rb +20 -0
  205. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/reverse_spec.rb +19 -0
  206. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/rstrip_spec.rb +24 -0
  207. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/shuffle_spec.rb +24 -0
  208. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/size_spec.rb +24 -0
  209. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/sort_spec.rb +24 -0
  210. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/squeeze_spec.rb +24 -0
  211. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/str2bool_spec.rb +24 -0
  212. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb +45 -0
  213. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/strftime_spec.rb +29 -0
  214. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/strip_spec.rb +18 -0
  215. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/swapcase_spec.rb +19 -0
  216. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/time_spec.rb +29 -0
  217. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/to_bytes_spec.rb +58 -0
  218. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/type_spec.rb +43 -0
  219. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/unique_spec.rb +24 -0
  220. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/upcase_spec.rb +24 -0
  221. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/uriescape_spec.rb +24 -0
  222. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +83 -0
  223. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb +38 -0
  224. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_bool_spec.rb +51 -0
  225. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_hash_spec.rb +43 -0
  226. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_re_spec.rb +76 -0
  227. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_slength_spec.rb +48 -0
  228. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_string_spec.rb +60 -0
  229. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/values_at_spec.rb +38 -0
  230. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/values_spec.rb +31 -0
  231. data/provision/modules/stdlib/spec/unit/puppet/parser/functions/zip_spec.rb +15 -0
  232. data/provision/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb +127 -0
  233. data/provision/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb +11 -0
  234. data/provision/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb +69 -0
  235. data/provision/modules/stdlib/spec/watchr.rb +86 -0
  236. data/provision/modules/stdlib/tests/file_line.pp +9 -0
  237. data/provision/modules/stdlib/tests/has_interface_with.pp +10 -0
  238. data/provision/modules/stdlib/tests/has_ip_address.pp +3 -0
  239. data/provision/modules/stdlib/tests/has_ip_network.pp +4 -0
  240. data/provision/modules/stdlib/tests/init.pp +1 -0
  241. metadata +291 -0
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "the min function" do
6
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7
+
8
+ it "should exist" do
9
+ Puppet::Parser::Functions.function("min").should == "function_min"
10
+ end
11
+
12
+ it "should raise a ParseError if there is less than 1 arguments" do
13
+ lambda { scope.function_min([]) }.should( raise_error(Puppet::ParseError))
14
+ end
15
+
16
+ it "should be able to compare strings" do
17
+ scope.function_min(["albatross","dog","horse"]).should(eq("albatross"))
18
+ end
19
+
20
+ it "should be able to compare numbers" do
21
+ scope.function_min([6,8,4]).should(eq(4))
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the num2bool function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("num2bool").should == "function_num2bool"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should return true if 1" do
16
+ result = scope.function_num2bool(["1"])
17
+ result.should(be_true)
18
+ end
19
+
20
+ it "should return false if 0" do
21
+ result = scope.function_num2bool(["0"])
22
+ result.should(be_false)
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the parsejson function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("parsejson").should == "function_parsejson"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should convert JSON to a data structure" do
16
+ json = <<-EOS
17
+ ["aaa","bbb","ccc"]
18
+ EOS
19
+ result = scope.function_parsejson([json])
20
+ result.should(eq(['aaa','bbb','ccc']))
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the parseyaml function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should convert YAML to a data structure" do
16
+ yaml = <<-EOS
17
+ - aaa
18
+ - bbb
19
+ - ccc
20
+ EOS
21
+ result = scope.function_parseyaml([yaml])
22
+ result.should(eq(['aaa','bbb','ccc']))
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the pick function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("pick").should == "function_pick"
9
+ end
10
+
11
+ it 'should return the correct value' do
12
+ scope.function_pick(['first', 'second']).should == 'first'
13
+ end
14
+
15
+ it 'should return the correct value if the first value is empty' do
16
+ scope.function_pick(['', 'second']).should == 'second'
17
+ end
18
+
19
+ it 'should remove empty string values' do
20
+ scope.function_pick(['', 'first']).should == 'first'
21
+ end
22
+
23
+ it 'should remove :undef values' do
24
+ scope.function_pick([:undef, 'first']).should == 'first'
25
+ end
26
+
27
+ it 'should remove :undefined values' do
28
+ scope.function_pick([:undefined, 'first']).should == 'first'
29
+ end
30
+
31
+ it 'should error if no values are passed' do
32
+ expect { scope.function_pick([]) }.to raise_error(Puppet::Error, /Must provide non empty value./)
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the prefix function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("prefix").should == "function_prefix"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_prefix([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should return a prefixed array" do
16
+ result = scope.function_prefix([['a','b','c'], 'p'])
17
+ result.should(eq(['pa','pb','pc']))
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the range function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("range").should == "function_range"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_range([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should return a letter range" do
16
+ result = scope.function_range(["a","d"])
17
+ result.should(eq(['a','b','c','d']))
18
+ end
19
+
20
+ it "should return a number range" do
21
+ result = scope.function_range(["1","4"])
22
+ result.should(eq([1,2,3,4]))
23
+ end
24
+
25
+ it "should work with padded hostname like strings" do
26
+ expected = ("host01".."host10").to_a
27
+ scope.function_range(["host01","host10"]).should eq expected
28
+ end
29
+
30
+ it "should coerce zero padded digits to integers" do
31
+ expected = (0..10).to_a
32
+ scope.function_range(["00", "10"]).should eq expected
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "the reject function" do
6
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7
+
8
+ it "should exist" do
9
+ Puppet::Parser::Functions.function("reject").should == "function_reject"
10
+ end
11
+
12
+ it "should raise a ParseError if there is less than 1 arguments" do
13
+ lambda { scope.function_reject([]) }.should( raise_error(Puppet::ParseError))
14
+ end
15
+
16
+ it "should reject contents from an array" do
17
+ result = scope.function_reject([["1111", "aaabbb","bbbccc","dddeee"], "bbb"])
18
+ result.should(eq(["1111", "dddeee"]))
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the reverse function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("reverse").should == "function_reverse"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_reverse([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should reverse a string" do
16
+ result = scope.function_reverse(["asdfghijkl"])
17
+ result.should(eq('lkjihgfdsa'))
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the rstrip function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("rstrip").should == "function_rstrip"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should rstrip a string" do
16
+ result = scope.function_rstrip(["asdf "])
17
+ result.should(eq('asdf'))
18
+ end
19
+
20
+ it "should rstrip each element in an array" do
21
+ result = scope.function_rstrip([["a ","b ", "c "]])
22
+ result.should(eq(['a','b','c']))
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the shuffle function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("shuffle").should == "function_shuffle"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should shuffle a string and the result should be the same size" do
16
+ result = scope.function_shuffle(["asdf"])
17
+ result.size.should(eq(4))
18
+ end
19
+
20
+ it "should shuffle a string but the sorted contents should still be the same" do
21
+ result = scope.function_shuffle(["adfs"])
22
+ result.split("").sort.join("").should(eq("adfs"))
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the size function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("size").should == "function_size"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_size([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should return the size of a string" do
16
+ result = scope.function_size(["asdf"])
17
+ result.should(eq(4))
18
+ end
19
+
20
+ it "should return the size of an array" do
21
+ result = scope.function_size([["a","b","c"]])
22
+ result.should(eq(3))
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the sort function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("sort").should == "function_sort"
9
+ end
10
+
11
+ it "should raise a ParseError if there is not 1 arguments" do
12
+ lambda { scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should sort an array" do
16
+ result = scope.function_sort([["a","c","b"]])
17
+ result.should(eq(['a','b','c']))
18
+ end
19
+
20
+ it "should sort a string" do
21
+ result = scope.function_sort(["acb"])
22
+ result.should(eq('abc'))
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the squeeze function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("squeeze").should == "function_squeeze"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 2 arguments" do
12
+ lambda { scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should squeeze a string" do
16
+ result = scope.function_squeeze(["aaabbbbcccc"])
17
+ result.should(eq('abc'))
18
+ end
19
+
20
+ it "should squeeze all elements in an array" do
21
+ result = scope.function_squeeze([["aaabbbbcccc","dddfff"]])
22
+ result.should(eq(['abc','df']))
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the str2bool function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("str2bool").should == "function_str2bool"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should convert string 'true' to true" do
16
+ result = scope.function_str2bool(["true"])
17
+ result.should(eq(true))
18
+ end
19
+
20
+ it "should convert string 'undef' to false" do
21
+ result = scope.function_str2bool(["undef"])
22
+ result.should(eq(false))
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the str2saltedsha512 function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("str2saltedsha512").should == "function_str2saltedsha512"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 argument" do
12
+ expect { scope.function_str2saltedsha512([]) }.should( raise_error(Puppet::ParseError) )
13
+ end
14
+
15
+ it "should raise a ParseError if there is more than 1 argument" do
16
+ expect { scope.function_str2saltedsha512(['foo', 'bar', 'baz']) }.should( raise_error(Puppet::ParseError) )
17
+ end
18
+
19
+ it "should return a salted-sha512 password hash 136 characters in length" do
20
+ result = scope.function_str2saltedsha512(["password"])
21
+ result.length.should(eq(136))
22
+ end
23
+
24
+ it "should raise an error if you pass a non-string password" do
25
+ expect { scope.function_str2saltedsha512([1234]) }.should( raise_error(Puppet::ParseError) )
26
+ end
27
+
28
+ it "should generate a valid password" do
29
+ # Allow the function to generate a password based on the string 'password'
30
+ password_hash = scope.function_str2saltedsha512(["password"])
31
+
32
+ # Separate the Salt and Password from the Password Hash
33
+ salt = password_hash[0..7]
34
+ password = password_hash[8..-1]
35
+
36
+ # Convert the Salt and Password from Hex to Binary Data
37
+ str_salt = Array(salt.lines).pack('H*')
38
+ str_password = Array(password.lines).pack('H*')
39
+
40
+ # Combine the Binary Salt with 'password' and compare the end result
41
+ saltedpass = Digest::SHA512.digest(str_salt + 'password')
42
+ result = (str_salt + saltedpass).unpack('H*')[0]
43
+ result.should == password_hash
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the strftime function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("strftime").should == "function_strftime"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_strftime([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "using %s should be higher then when I wrote this test" do
16
+ result = scope.function_strftime(["%s"])
17
+ result.to_i.should(be > 1311953157)
18
+ end
19
+
20
+ it "using %s should be lower then 1.5 trillion" do
21
+ result = scope.function_strftime(["%s"])
22
+ result.to_i.should(be < 1500000000)
23
+ end
24
+
25
+ it "should return a date when given %Y-%m-%d" do
26
+ result = scope.function_strftime(["%Y-%m-%d"])
27
+ result.should =~ /^\d{4}-\d{2}-\d{2}$/
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the strip function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+ it "should exist" do
7
+ Puppet::Parser::Functions.function("strip").should == "function_strip"
8
+ end
9
+
10
+ it "should raise a ParseError if there is less than 1 arguments" do
11
+ lambda { scope.function_strip([]) }.should( raise_error(Puppet::ParseError))
12
+ end
13
+
14
+ it "should strip a string" do
15
+ result = scope.function_strip([" ab cd "])
16
+ result.should(eq('ab cd'))
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the swapcase function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("swapcase").should == "function_swapcase"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should swapcase a string" do
16
+ result = scope.function_swapcase(["aaBBccDD"])
17
+ result.should(eq('AAbbCCdd'))
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the time function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("time").should == "function_time"
9
+ end
10
+
11
+ it "should raise a ParseError if there is more than 2 arguments" do
12
+ lambda { scope.function_time(['','']) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should return a number" do
16
+ result = scope.function_time([])
17
+ result.should be_an(Integer)
18
+ end
19
+
20
+ it "should be higher then when I wrote this test" do
21
+ result = scope.function_time([])
22
+ result.should(be > 1311953157)
23
+ end
24
+
25
+ it "should be lower then 1.5 trillion" do
26
+ result = scope.function_time([])
27
+ result.should(be < 1500000000)
28
+ end
29
+ end
@@ -0,0 +1,58 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "the to_bytes function" do
6
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7
+
8
+ it "should exist" do
9
+ Puppet::Parser::Functions.function("to_bytes").should == "function_to_bytes"
10
+ end
11
+
12
+ it "should raise a ParseError if there is less than 1 arguments" do
13
+ lambda { scope.function_to_bytes([]) }.should( raise_error(Puppet::ParseError))
14
+ end
15
+
16
+ it "should convert kB to B" do
17
+ result = scope.function_to_bytes(["4 kB"])
18
+ result.should(eq(4096))
19
+ end
20
+
21
+ it "should work without B in unit" do
22
+ result = scope.function_to_bytes(["4 k"])
23
+ result.should(eq(4096))
24
+ end
25
+
26
+ it "should work without a space before unit" do
27
+ result = scope.function_to_bytes(["4k"])
28
+ result.should(eq(4096))
29
+ end
30
+
31
+ it "should work without a unit" do
32
+ result = scope.function_to_bytes(["5678"])
33
+ result.should(eq(5678))
34
+ end
35
+
36
+ it "should convert fractions" do
37
+ result = scope.function_to_bytes(["1.5 kB"])
38
+ result.should(eq(1536))
39
+ end
40
+
41
+ it "should convert scientific notation" do
42
+ result = scope.function_to_bytes(["1.5e2 B"])
43
+ result.should(eq(150))
44
+ end
45
+
46
+ it "should do nothing with a positive number" do
47
+ result = scope.function_to_bytes([5678])
48
+ result.should(eq(5678))
49
+ end
50
+
51
+ it "should should raise a ParseError if input isn't a number" do
52
+ lambda { scope.function_to_bytes(["foo"]) }.should( raise_error(Puppet::ParseError))
53
+ end
54
+
55
+ it "should should raise a ParseError if prefix is unknown" do
56
+ lambda { scope.function_to_bytes(["5 uB"]) }.should( raise_error(Puppet::ParseError))
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the type function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+ it "should exist" do
7
+ Puppet::Parser::Functions.function("type").should == "function_type"
8
+ end
9
+
10
+ it "should raise a ParseError if there is less than 1 arguments" do
11
+ lambda { scope.function_type([]) }.should( raise_error(Puppet::ParseError))
12
+ end
13
+
14
+ it "should return string when given a string" do
15
+ result = scope.function_type(["aaabbbbcccc"])
16
+ result.should(eq('string'))
17
+ end
18
+
19
+ it "should return array when given an array" do
20
+ result = scope.function_type([["aaabbbbcccc","asdf"]])
21
+ result.should(eq('array'))
22
+ end
23
+
24
+ it "should return hash when given a hash" do
25
+ result = scope.function_type([{"a"=>1,"b"=>2}])
26
+ result.should(eq('hash'))
27
+ end
28
+
29
+ it "should return integer when given an integer" do
30
+ result = scope.function_type(["1"])
31
+ result.should(eq('integer'))
32
+ end
33
+
34
+ it "should return float when given a float" do
35
+ result = scope.function_type(["1.34"])
36
+ result.should(eq('float'))
37
+ end
38
+
39
+ it "should return boolean when given a boolean" do
40
+ result = scope.function_type([true])
41
+ result.should(eq('boolean'))
42
+ end
43
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the unique function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("unique").should == "function_unique"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_unique([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should remove duplicate elements in a string" do
16
+ result = scope.function_unique(["aabbc"])
17
+ result.should(eq('abc'))
18
+ end
19
+
20
+ it "should remove duplicate elements in an array" do
21
+ result = scope.function_unique([["a","a","b","b","c"]])
22
+ result.should(eq(['a','b','c']))
23
+ end
24
+ end