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,8 @@
1
+ require 'rspec'
2
+
3
+ class Object
4
+ # This is necessary because the RAL has a 'should'
5
+ # method.
6
+ alias :must :should
7
+ alias :must_not :should_not
8
+ end
@@ -0,0 +1,10 @@
1
+ # Some monkey-patching to allow us to test private methods.
2
+ class Class
3
+ def publicize_methods(*methods)
4
+ saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
5
+
6
+ self.class_eval { public(*saved_private_instance_methods) }
7
+ yield
8
+ self.class_eval { private(*saved_private_instance_methods) }
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ --format
2
+ s
3
+ --colour
4
+ --loadby
5
+ mtime
6
+ --backtrace
@@ -0,0 +1,28 @@
1
+ dir = File.expand_path(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift File.join(dir, 'lib')
3
+
4
+ # Don't want puppet getting the command line arguments for rake or autotest
5
+ ARGV.clear
6
+
7
+ require 'puppet'
8
+ require 'facter'
9
+ require 'mocha'
10
+ gem 'rspec', '>=2.0.0'
11
+ require 'rspec/expectations'
12
+
13
+ require 'puppetlabs_spec_helper/module_spec_helper'
14
+
15
+ RSpec.configure do |config|
16
+ # FIXME REVISIT - We may want to delegate to Facter like we do in
17
+ # Puppet::PuppetSpecInitializer.initialize_via_testhelper(config) because
18
+ # this behavior is a duplication of the spec_helper in Facter.
19
+ config.before :each do
20
+ # Ensure that we don't accidentally cache facts and environment between
21
+ # test cases. This requires each example group to explicitly load the
22
+ # facts being exercised with something like
23
+ # Facter.collection.loader.load(:ipaddress)
24
+ Facter::Util::Loader.any_instance.stubs(:load_all)
25
+ Facter.clear
26
+ Facter.clear_messages
27
+ end
28
+ end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "PE Version specs" do
6
+ before :each do
7
+ # Explicitly load the pe_version.rb file which contains generated facts
8
+ # that cannot be automatically loaded. Puppet 2.x implements
9
+ # Facter.collection.load while Facter 1.x markes Facter.collection.load as
10
+ # a private method.
11
+ if Facter.collection.respond_to? :load
12
+ Facter.collection.load(:pe_version)
13
+ else
14
+ Facter.collection.loader.load(:pe_version)
15
+ end
16
+ end
17
+
18
+ context "If PE is installed" do
19
+ %w{ 2.6.1 2.10.300 }.each do |version|
20
+ puppetversion = "2.7.19 (Puppet Enterprise #{version})"
21
+ context "puppetversion => #{puppetversion}" do
22
+ before :each do
23
+ Facter.fact(:puppetversion).stubs(:value).returns(puppetversion)
24
+ end
25
+
26
+ (major,minor,patch) = version.split(".")
27
+
28
+ it "Should return true" do
29
+ Facter.fact(:is_pe).value.should == true
30
+ end
31
+
32
+ it "Should have a version of #{version}" do
33
+ Facter.fact(:pe_version).value.should == version
34
+ end
35
+
36
+ it "Should have a major version of #{major}" do
37
+ Facter.fact(:pe_major_version).value.should == major
38
+ end
39
+
40
+ it "Should have a minor version of #{minor}" do
41
+ Facter.fact(:pe_minor_version).value.should == minor
42
+ end
43
+
44
+ it "Should have a patch version of #{patch}" do
45
+ Facter.fact(:pe_patch_version).value.should == patch
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ context "When PE is not installed" do
52
+ before :each do
53
+ Facter.fact(:puppetversion).stubs(:value).returns("2.7.19")
54
+ end
55
+
56
+ it "is_pe is false" do
57
+ Facter.fact(:is_pe).value.should == false
58
+ end
59
+
60
+ it "pe_version is nil" do
61
+ Facter.fact(:pe_version).value.should be_nil
62
+ end
63
+
64
+ it "pe_major_version is nil" do
65
+ Facter.fact(:pe_major_version).value.should be_nil
66
+ end
67
+
68
+ it "pe_minor_version is nil" do
69
+ Facter.fact(:pe_minor_version).value.should be_nil
70
+ end
71
+
72
+ it "Should have a patch version" do
73
+ Facter.fact(:pe_patch_version).value.should be_nil
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'facter/root_home'
3
+
4
+ describe Facter::Util::RootHome do
5
+ context "solaris" do
6
+ let(:root_ent) { "root:x:0:0:Super-User:/:/sbin/sh" }
7
+ let(:expected_root_home) { "/" }
8
+
9
+ it "should return /" do
10
+ Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
11
+ Facter::Util::RootHome.get_root_home.should == expected_root_home
12
+ end
13
+ end
14
+ context "linux" do
15
+ let(:root_ent) { "root:x:0:0:root:/root:/bin/bash" }
16
+ let(:expected_root_home) { "/root" }
17
+
18
+ it "should return /root" do
19
+ Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
20
+ Facter::Util::RootHome.get_root_home.should == expected_root_home
21
+ end
22
+ end
23
+ context "macosx" do
24
+ let(:root_ent) { "root:*:0:0:System Administrator:/var/root:/bin/sh" }
25
+ let(:expected_root_home) { "/var/root" }
26
+
27
+ it "should return /var/root" do
28
+ Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
29
+ Facter::Util::RootHome.get_root_home.should == expected_root_home
30
+ end
31
+ end
32
+ context "windows" do
33
+ before :each do
34
+ Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
35
+ end
36
+ it "should be nil on windows" do
37
+ Facter::Util::RootHome.get_root_home.should be_nil
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'facter/util/puppet_settings'
3
+
4
+ describe Facter::Util::PuppetSettings do
5
+
6
+ describe "#with_puppet" do
7
+ context "Without Puppet loaded" do
8
+ before(:each) do
9
+ Module.expects(:const_get).with("Puppet").raises(NameError)
10
+ end
11
+
12
+ it 'should be nil' do
13
+ subject.with_puppet { Puppet[:vardir] }.should be_nil
14
+ end
15
+ it 'should not yield to the block' do
16
+ Puppet.expects(:[]).never
17
+ subject.with_puppet { Puppet[:vardir] }.should be_nil
18
+ end
19
+ end
20
+ context "With Puppet loaded" do
21
+ module Puppet; end
22
+ let(:vardir) { "/var/lib/puppet" }
23
+
24
+ before :each do
25
+ Puppet.expects(:[]).with(:vardir).returns vardir
26
+ end
27
+ it 'should yield to the block' do
28
+ subject.with_puppet { Puppet[:vardir] }
29
+ end
30
+ it 'should return the nodes vardir' do
31
+ subject.with_puppet { Puppet[:vardir] }.should eq vardir
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "the abs function" do
6
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7
+
8
+ it "should exist" do
9
+ Puppet::Parser::Functions.function("abs").should == "function_abs"
10
+ end
11
+
12
+ it "should raise a ParseError if there is less than 1 arguments" do
13
+ lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError))
14
+ end
15
+
16
+ it "should convert a negative number into a positive" do
17
+ result = scope.function_abs(["-34"])
18
+ result.should(eq(34))
19
+ end
20
+
21
+ it "should do nothing with a positive number" do
22
+ result = scope.function_abs(["5678"])
23
+ result.should(eq(5678))
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the bool2num function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("bool2num").should == "function_bool2num"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should convert true to 1" do
16
+ result = scope.function_bool2num([true])
17
+ result.should(eq(1))
18
+ end
19
+
20
+ it "should convert false to 0" do
21
+ result = scope.function_bool2num([false])
22
+ result.should(eq(0))
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the capitalize function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("capitalize").should == "function_capitalize"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should capitalize the beginning of a string" do
16
+ result = scope.function_capitalize(["abc"])
17
+ result.should(eq("Abc"))
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the chomp function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("chomp").should == "function_chomp"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should chomp the end of a string" do
16
+ result = scope.function_chomp(["abc\n"])
17
+ result.should(eq("abc"))
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the chop function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("chop").should == "function_chop"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should chop the end of a string" do
16
+ result = scope.function_chop(["asdf\n"])
17
+ result.should(eq("asdf"))
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the delete_at function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("delete_at").should == "function_delete_at"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should delete an item at specified location from an array" do
16
+ result = scope.function_delete_at([['a','b','c'],1])
17
+ result.should(eq(['a','c']))
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the delete function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("delete").should == "function_delete"
9
+ end
10
+
11
+ it "should raise a ParseError if there are fewer than 2 arguments" do
12
+ lambda { scope.function_delete([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should raise a ParseError if there are greater than 2 arguments" do
16
+ lambda { scope.function_delete([[], 'foo', 'bar']) }.should( raise_error(Puppet::ParseError))
17
+ end
18
+
19
+ it "should raise a TypeError if a number is passed as the first argument" do
20
+ lambda { scope.function_delete([1, 'bar']) }.should( raise_error(TypeError))
21
+ end
22
+
23
+ it "should delete all instances of an element from an array" do
24
+ result = scope.function_delete([['a','b','c','b'],'b'])
25
+ result.should(eq(['a','c']))
26
+ end
27
+
28
+ it "should delete all instances of a substring from a string" do
29
+ result = scope.function_delete(['foobarbabarz','bar'])
30
+ result.should(eq('foobaz'))
31
+ end
32
+
33
+ it "should delete a key from a hash" do
34
+ result = scope.function_delete([{ 'a' => 1, 'b' => 2, 'c' => 3 },'b'])
35
+ result.should(eq({ 'a' => 1, 'c' => 3 }))
36
+ end
37
+
38
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the downcase function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("downcase").should == "function_downcase"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should downcase a string" do
16
+ result = scope.function_downcase(["ASFD"])
17
+ result.should(eq("asfd"))
18
+ end
19
+
20
+ it "should do nothing to a string that is already downcase" do
21
+ result = scope.function_downcase(["asdf asdf"])
22
+ result.should(eq("asdf asdf"))
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the empty function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+ it "should exist" do
7
+ Puppet::Parser::Functions.function("empty").should == "function_empty"
8
+ end
9
+
10
+ it "should raise a ParseError if there is less than 1 arguments" do
11
+ lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError))
12
+ end
13
+
14
+ it "should return a true for an empty string" do
15
+ result = scope.function_empty([''])
16
+ result.should(eq(true))
17
+ end
18
+
19
+ it "should return a false for a non-empty string" do
20
+ result = scope.function_empty(['asdf'])
21
+ result.should(eq(false))
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the flatten function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+ it "should exist" do
7
+ Puppet::Parser::Functions.function("flatten").should == "function_flatten"
8
+ end
9
+
10
+ it "should raise a ParseError if there is less than 1 arguments" do
11
+ lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError))
12
+ end
13
+
14
+ it "should flatten a complex data structure" do
15
+ result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]])
16
+ result.should(eq(["a","b","c","d","e","f","g"]))
17
+ end
18
+
19
+ it "should do nothing to a structure that is already flat" do
20
+ result = scope.function_flatten([["a","b","c","d"]])
21
+ result.should(eq(["a","b","c","d"]))
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the fqdn_rotate function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("fqdn_rotate").should == "function_fqdn_rotate"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_fqdn_rotate([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should rotate a string and the result should be the same size" do
16
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
17
+ result = scope.function_fqdn_rotate(["asdf"])
18
+ result.size.should(eq(4))
19
+ end
20
+
21
+ it "should rotate a string to give the same results for one host" do
22
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
23
+ scope.function_fqdn_rotate(["abcdefg"]).should eql(scope.function_fqdn_rotate(["abcdefg"]))
24
+ end
25
+
26
+ it "should rotate a string to give different values on different hosts" do
27
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
28
+ val1 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"])
29
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2")
30
+ val2 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"])
31
+ val1.should_not eql(val2)
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Parser::Functions.function(:get_module_path) do
5
+ Internals = PuppetlabsSpec::PuppetInternals
6
+ class StubModule
7
+ attr_reader :path
8
+ def initialize(path)
9
+ @path = path
10
+ end
11
+ end
12
+
13
+ def scope(environment = "production")
14
+ Internals.scope(:compiler => Internals.compiler(:node => Internals.node(:environment => environment)))
15
+ end
16
+
17
+ it 'should only allow one argument' do
18
+ expect { scope.function_get_module_path([]) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/)
19
+ expect { scope.function_get_module_path(['1','2','3']) }.should raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/)
20
+ end
21
+ it 'should raise an exception when the module cannot be found' do
22
+ expect { scope.function_get_module_path(['foo']) }.should raise_error(Puppet::ParseError, /Could not find module/)
23
+ end
24
+ describe 'when locating a module' do
25
+ let(:modulepath) { "/tmp/does_not_exist" }
26
+ let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") }
27
+
28
+ before(:each) { Puppet[:modulepath] = modulepath }
29
+
30
+ it 'should be able to find module paths from the modulepath setting' do
31
+ Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo)
32
+ scope.function_get_module_path(['foo']).should == path_of_module_foo.path
33
+ end
34
+ it 'should be able to find module paths when the modulepath is a list' do
35
+ Puppet[:modulepath] = modulepath + ":/tmp"
36
+ Puppet::Module.expects(:find).with('foo', 'production').returns(path_of_module_foo)
37
+ scope.function_get_module_path(['foo']).should == path_of_module_foo.path
38
+ end
39
+ it 'should respect the environment' do
40
+ pending("Disabled on Puppet 2.6.x") if Puppet.version =~ /^2\.6\b/
41
+ Puppet.settings[:environment] = 'danstestenv'
42
+ Puppet::Module.expects(:find).with('foo', 'danstestenv').returns(path_of_module_foo)
43
+ scope('danstestenv').function_get_module_path(['foo']).should == path_of_module_foo.path
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,37 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Parser::Functions.function(:getvar) do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+ describe 'when calling getvar from puppet' do
7
+
8
+ it "should not compile when no arguments are passed" do
9
+ pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
10
+ Puppet[:code] = '$foo = getvar()'
11
+ expect {
12
+ scope.compiler.compile
13
+ }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
14
+ end
15
+
16
+ it "should not compile when too many arguments are passed" do
17
+ pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
18
+ Puppet[:code] = '$foo = getvar("foo::bar", "baz")'
19
+ expect {
20
+ scope.compiler.compile
21
+ }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
22
+ end
23
+
24
+ it "should lookup variables in other namespaces" do
25
+ pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
26
+ Puppet[:code] = <<-'ENDofPUPPETcode'
27
+ class site::data { $foo = 'baz' }
28
+ include site::data
29
+ $foo = getvar("site::data::foo")
30
+ if $foo != 'baz' {
31
+ fail('getvar did not return what we expect')
32
+ }
33
+ ENDofPUPPETcode
34
+ scope.compiler.compile
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe "the grep function" do
5
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
+
7
+ it "should exist" do
8
+ Puppet::Parser::Functions.function("grep").should == "function_grep"
9
+ end
10
+
11
+ it "should raise a ParseError if there is less than 1 arguments" do
12
+ lambda { scope.function_grep([]) }.should( raise_error(Puppet::ParseError))
13
+ end
14
+
15
+ it "should grep contents from an array" do
16
+ result = scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"])
17
+ result.should(eq(["aaabbb","bbbccc"]))
18
+ end
19
+ end
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Parser::Functions.function(:has_interface_with) do
5
+
6
+ let(:scope) do
7
+ PuppetlabsSpec::PuppetInternals.scope
8
+ end
9
+
10
+ # The subject of these examples is the method itself.
11
+ subject do
12
+ function_name = Puppet::Parser::Functions.function(:has_interface_with)
13
+ scope.method(function_name)
14
+ end
15
+
16
+ # We need to mock out the Facts so we can specify how we expect this function
17
+ # to behave on different platforms.
18
+ context "On Mac OS X Systems" do
19
+ before :each do
20
+ scope.stubs(:lookupvar).with("interfaces").returns('lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0')
21
+ end
22
+ it 'should have loopback (lo0)' do
23
+ subject.call(['lo0']).should be_true
24
+ end
25
+ it 'should not have loopback (lo)' do
26
+ subject.call(['lo']).should be_false
27
+ end
28
+ end
29
+ context "On Linux Systems" do
30
+ before :each do
31
+ scope.stubs(:lookupvar).with("interfaces").returns('eth0,lo')
32
+ scope.stubs(:lookupvar).with("ipaddress").returns('10.0.0.1')
33
+ scope.stubs(:lookupvar).with("ipaddress_lo").returns('127.0.0.1')
34
+ scope.stubs(:lookupvar).with("ipaddress_eth0").returns('10.0.0.1')
35
+ scope.stubs(:lookupvar).with('muppet').returns('kermit')
36
+ scope.stubs(:lookupvar).with('muppet_lo').returns('mspiggy')
37
+ scope.stubs(:lookupvar).with('muppet_eth0').returns('kermit')
38
+ end
39
+ it 'should have loopback (lo)' do
40
+ subject.call(['lo']).should be_true
41
+ end
42
+ it 'should not have loopback (lo0)' do
43
+ subject.call(['lo0']).should be_false
44
+ end
45
+ it 'should have ipaddress with 127.0.0.1' do
46
+ subject.call(['ipaddress', '127.0.0.1']).should be_true
47
+ end
48
+ it 'should have ipaddress with 10.0.0.1' do
49
+ subject.call(['ipaddress', '10.0.0.1']).should be_true
50
+ end
51
+ it 'should not have ipaddress with 10.0.0.2' do
52
+ subject.call(['ipaddress', '10.0.0.2']).should be_false
53
+ end
54
+ it 'should have muppet named kermit' do
55
+ subject.call(['muppet', 'kermit']).should be_true
56
+ end
57
+ it 'should have muppet named mspiggy' do
58
+ subject.call(['muppet', 'mspiggy']).should be_true
59
+ end
60
+ it 'should not have muppet named bigbird' do
61
+ subject.call(['muppet', 'bigbird']).should be_false
62
+ end
63
+ end
64
+ end