puppet 2.7.13 → 2.7.14

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (215) hide show
  1. data/CHANGELOG +144 -1
  2. data/conf/osx/preflight +1 -1
  3. data/conf/redhat/puppet.spec +9 -5
  4. data/conf/suse/puppet.spec +4 -1
  5. data/conf/windows/eventlog/Rakefile +32 -0
  6. data/conf/windows/eventlog/puppetres.dll +0 -0
  7. data/conf/windows/eventlog/puppetres.mc +18 -0
  8. data/ext/rack/files/apache2.conf +3 -0
  9. data/install.rb +23 -1
  10. data/lib/puppet.rb +1 -1
  11. data/lib/puppet/agent.rb +1 -14
  12. data/lib/puppet/application/kick.rb +1 -1
  13. data/lib/puppet/application/module.rb +11 -0
  14. data/lib/puppet/daemon.rb +74 -3
  15. data/lib/puppet/defaults.rb +1 -1
  16. data/lib/puppet/face/certificate.rb +1 -1
  17. data/lib/puppet/face/help/man.erb +1 -1
  18. data/lib/puppet/face/module.rb +17 -0
  19. data/lib/puppet/face/module/build.rb +10 -4
  20. data/lib/puppet/face/module/changes.rb +5 -5
  21. data/lib/puppet/face/module/generate.rb +6 -4
  22. data/lib/puppet/face/module/install.rb +122 -32
  23. data/lib/puppet/face/module/list.rb +234 -33
  24. data/lib/puppet/face/module/search.rb +56 -23
  25. data/lib/puppet/face/module/uninstall.rb +33 -38
  26. data/lib/puppet/face/module/upgrade.rb +84 -0
  27. data/lib/puppet/feature/eventlog.rb +6 -0
  28. data/lib/puppet/forge.rb +67 -122
  29. data/lib/puppet/forge/cache.rb +1 -1
  30. data/lib/puppet/forge/repository.rb +6 -25
  31. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  32. data/lib/puppet/interface/action.rb +1 -1
  33. data/lib/puppet/module.rb +79 -28
  34. data/lib/puppet/module_tool.rb +72 -34
  35. data/lib/puppet/module_tool/applications.rb +12 -14
  36. data/lib/puppet/module_tool/applications/application.rb +21 -19
  37. data/lib/puppet/module_tool/applications/builder.rb +4 -4
  38. data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
  39. data/lib/puppet/module_tool/applications/generator.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +163 -34
  41. data/lib/puppet/module_tool/applications/searcher.rb +2 -3
  42. data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
  43. data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
  44. data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
  45. data/lib/puppet/module_tool/checksums.rb +2 -2
  46. data/lib/puppet/module_tool/contents_description.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +2 -2
  48. data/lib/puppet/module_tool/errors.rb +9 -0
  49. data/lib/puppet/module_tool/errors/base.rb +15 -0
  50. data/lib/puppet/module_tool/errors/installer.rb +90 -0
  51. data/lib/puppet/module_tool/errors/shared.rb +115 -0
  52. data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
  53. data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
  54. data/lib/puppet/module_tool/metadata.rb +2 -2
  55. data/lib/puppet/module_tool/modulefile.rb +7 -7
  56. data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
  57. data/lib/puppet/module_tool/skeleton.rb +1 -1
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/parser/ast/leaf.rb +1 -1
  60. data/lib/puppet/parser/functions/create_resources.rb +3 -2
  61. data/lib/puppet/parser/scope.rb +44 -9
  62. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  63. data/lib/puppet/provider/exec.rb +8 -3
  64. data/lib/puppet/provider/exec/shell.rb +1 -2
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
  66. data/lib/puppet/provider/package/gem.rb +1 -1
  67. data/lib/puppet/provider/package/pkg.rb +10 -21
  68. data/lib/puppet/provider/selmodule/semodule.rb +1 -2
  69. data/lib/puppet/provider/service/upstart.rb +33 -17
  70. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  71. data/lib/puppet/rails/inventory_node.rb +7 -7
  72. data/lib/puppet/reports/http.rb +4 -1
  73. data/lib/puppet/reports/tagmail.rb +8 -1
  74. data/lib/puppet/resource/type.rb +1 -1
  75. data/lib/puppet/test/test_helper.rb +138 -0
  76. data/lib/puppet/type.rb +9 -1
  77. data/lib/puppet/type/file.rb +18 -10
  78. data/lib/puppet/type/package.rb +13 -9
  79. data/lib/puppet/type/resources.rb +1 -1
  80. data/lib/puppet/type/ssh_authorized_key.rb +3 -4
  81. data/lib/puppet/type/sshkey.rb +4 -4
  82. data/lib/puppet/type/user.rb +1 -0
  83. data/lib/puppet/type/vlan.rb +1 -1
  84. data/lib/puppet/util.rb +31 -14
  85. data/lib/puppet/util/autoload.rb +1 -1
  86. data/lib/puppet/util/command_line.rb +2 -6
  87. data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
  88. data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
  89. data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
  90. data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
  91. data/lib/puppet/util/log.rb +3 -1
  92. data/lib/puppet/util/log/destinations.rb +38 -0
  93. data/lib/puppet/util/monkey_patches.rb +45 -0
  94. data/lib/puppet/util/network_device/base.rb +1 -1
  95. data/lib/puppet/util/network_device/cisco.rb +1 -1
  96. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  97. data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
  98. data/lib/puppet/util/network_device/config.rb +1 -1
  99. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  100. data/lib/puppet/util/network_device/transport.rb +1 -1
  101. data/lib/puppet/util/network_device/transport/base.rb +1 -1
  102. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  103. data/lib/puppet/util/settings.rb +2 -11
  104. data/lib/puppet/util/settings/file_setting.rb +3 -5
  105. data/lib/puppet/util/terminal.rb +16 -0
  106. data/lib/puppet/util/zaml.rb +3 -1
  107. data/lib/semver.rb +15 -7
  108. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
  109. data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
  110. data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
  111. data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
  112. data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
  113. data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
  114. data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
  115. data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
  116. data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
  117. data/spec/integration/faces/documentation_spec.rb +1 -1
  118. data/spec/integration/network/rest_authconfig_spec.rb +1 -1
  119. data/spec/lib/puppet_spec/compiler.rb +6 -0
  120. data/spec/lib/puppet_spec/database.rb +30 -0
  121. data/spec/lib/puppet_spec/files.rb +4 -2
  122. data/spec/shared_behaviours/path_parameters.rb +2 -29
  123. data/spec/shared_contexts/platform.rb +43 -0
  124. data/spec/spec_helper.rb +36 -65
  125. data/spec/unit/agent_spec.rb +0 -32
  126. data/spec/unit/application/kick_spec.rb +2 -2
  127. data/spec/unit/daemon_spec.rb +1 -17
  128. data/spec/unit/face/module/install_spec.rb +158 -0
  129. data/spec/unit/face/module/list_spec.rb +182 -0
  130. data/spec/unit/face/module/search_spec.rb +163 -0
  131. data/spec/unit/face/module/uninstall_spec.rb +77 -0
  132. data/spec/unit/face/module/upgrade_spec.rb +26 -0
  133. data/spec/unit/forge/repository_spec.rb +0 -30
  134. data/spec/unit/forge_spec.rb +28 -86
  135. data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
  136. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
  137. data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
  138. data/spec/unit/indirector/resource/ral_spec.rb +7 -2
  139. data/spec/unit/module_spec.rb +240 -107
  140. data/spec/unit/module_tool/application_spec.rb +3 -5
  141. data/spec/unit/module_tool/applications/application_spec.rb +19 -0
  142. data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
  143. data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
  144. data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
  145. data/spec/unit/module_tool/metadata_spec.rb +2 -2
  146. data/spec/unit/module_tool_spec.rb +109 -1
  147. data/spec/unit/node/environment_spec.rb +16 -1
  148. data/spec/unit/parser/ast/leaf_spec.rb +16 -1
  149. data/spec/unit/parser/collector_spec.rb +2 -12
  150. data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
  151. data/spec/unit/parser/functions/generate_spec.rb +2 -10
  152. data/spec/unit/parser/scope_spec.rb +345 -16
  153. data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
  154. data/spec/unit/provider/exec/shell_spec.rb +17 -14
  155. data/spec/unit/provider/exec/windows_spec.rb +1 -7
  156. data/spec/unit/provider/exec_spec.rb +35 -0
  157. data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
  158. data/spec/unit/provider/package/dpkg_spec.rb +2 -1
  159. data/spec/unit/provider/package/gem_spec.rb +15 -0
  160. data/spec/unit/provider/package/openbsd_spec.rb +5 -4
  161. data/spec/unit/provider/package/pacman_spec.rb +3 -2
  162. data/spec/unit/provider/package/pkg_spec.rb +56 -33
  163. data/spec/unit/provider/selmodule_spec.rb +11 -4
  164. data/spec/unit/provider/service/redhat_spec.rb +1 -3
  165. data/spec/unit/provider/service/smf_spec.rb +1 -3
  166. data/spec/unit/provider/service/upstart_spec.rb +38 -0
  167. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
  168. data/spec/unit/rails/host_spec.rb +6 -12
  169. data/spec/unit/rails/param_value_spec.rb +3 -8
  170. data/spec/unit/rails/resource_spec.rb +2 -8
  171. data/spec/unit/reports/http_spec.rb +47 -31
  172. data/spec/unit/reports/tagmail_spec.rb +77 -0
  173. data/spec/unit/resource/type_spec.rb +2 -2
  174. data/spec/unit/resource_spec.rb +18 -20
  175. data/spec/unit/semver_spec.rb +31 -13
  176. data/spec/unit/type/exec_spec.rb +8 -15
  177. data/spec/unit/type/group_spec.rb +0 -9
  178. data/spec/unit/type/package_spec.rb +10 -0
  179. data/spec/unit/type/resources_spec.rb +4 -5
  180. data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
  181. data/spec/unit/type/sshkey_spec.rb +9 -11
  182. data/spec/unit/type/user_spec.rb +123 -127
  183. data/spec/unit/type_spec.rb +20 -0
  184. data/spec/unit/util/command_line_spec.rb +2 -2
  185. data/spec/unit/util/instrumentation/data_spec.rb +1 -1
  186. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
  187. data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
  188. data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
  189. data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
  190. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
  191. data/spec/unit/util/instrumentation_spec.rb +1 -1
  192. data/spec/unit/util/log/destinations_spec.rb +4 -8
  193. data/spec/unit/util/log_spec.rb +47 -0
  194. data/spec/unit/util/reference_spec.rb +1 -1
  195. data/spec/unit/util/settings/file_setting_spec.rb +9 -0
  196. data/spec/unit/util/settings_spec.rb +0 -53
  197. data/spec/unit/util/terminal_spec.rb +42 -0
  198. data/spec/unit/util/zaml_spec.rb +7 -0
  199. data/spec/unit/util_spec.rb +63 -20
  200. data/tasks/rake/manpages.rake +1 -1
  201. data/test/data/snippets/arithmetic_expression.pp +1 -1
  202. data/test/other/puppet.rb +0 -1
  203. data/test/util/log.rb +6 -6
  204. metadata +41 -16
  205. data/lib/puppet/external/event-loop.rb +0 -1
  206. data/lib/puppet/external/event-loop/better-definers.rb +0 -367
  207. data/lib/puppet/external/event-loop/event-loop.rb +0 -355
  208. data/lib/puppet/external/event-loop/signal-system.rb +0 -218
  209. data/lib/puppet/face/module/clean.rb +0 -30
  210. data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
  211. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
  212. data/lib/puppet/module_tool/utils.rb +0 -5
  213. data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
  214. data/spec/integration/module_tool_spec.rb +0 -475
  215. data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -1,30 +0,0 @@
1
- Puppet::Face.define(:module, '1.0.0') do
2
- action(:clean) do
3
- summary "Clean the module download cache."
4
- description <<-EOT
5
- Clean the module download cache.
6
- EOT
7
-
8
- returns <<-EOT
9
- Return a status Hash:
10
-
11
- { :status => "success", :msg => "Cleaned module cache." }
12
- EOT
13
-
14
- examples <<-EOT
15
- Clean the module download cache:
16
-
17
- $ puppet module clean
18
- Cleaned module cache.
19
- EOT
20
-
21
- when_invoked do |options|
22
- Puppet::Module::Tool::Applications::Cleaner.run(options)
23
- end
24
-
25
- when_rendering :console do |return_value|
26
- # Print the status message to the console.
27
- return_value[:msg]
28
- end
29
- end
30
- end
@@ -1,16 +0,0 @@
1
- module Puppet::Module::Tool
2
- module Applications
3
- class Cleaner < Application
4
- def run
5
- Puppet::Forge::Cache.clean
6
-
7
- # Return a status Hash containing the status of the clean command
8
- # and a status message. This return value is used by the module_tool
9
- # face clean action, and the status message, return_value[:msg], is
10
- # displayed on the console.
11
- #
12
- { :status => "success", :msg => "Cleaned module cache." }
13
- end
14
- end
15
- end
16
- end
@@ -1,12 +0,0 @@
1
- /*
2
- +-----------------------------------------------------------------------+
3
- | |
4
- | ==> DO NOT EDIT THIS FILE! <== |
5
- | |
6
- | You should edit the `Modulefile` and run `puppet-module build` |
7
- | to generate the `metadata.json` file for your releases. |
8
- | |
9
- +-----------------------------------------------------------------------+
10
- */
11
-
12
- {}
@@ -1,5 +0,0 @@
1
- module Puppet::Module::Tool
2
- module Utils
3
- require 'puppet/module_tool/utils/interrogation'
4
- end
5
- end
@@ -1,25 +0,0 @@
1
- module Puppet::Module::Tool
2
- module Utils
3
-
4
- # = Interrogation
5
- #
6
- # This module contains methods to emit questions to the console.
7
- module Interrogation
8
- def confirms?(question)
9
- $stderr.print "#{question} [y/N]: "
10
- $stdin.gets =~ /y/i
11
- end
12
-
13
- def prompt(question, quiet = false)
14
- $stderr.print "#{question}: "
15
- system 'stty -echo' if quiet
16
- $stdin.gets.strip
17
- ensure
18
- if quiet
19
- system 'stty echo'
20
- say "\n---------"
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,475 +0,0 @@
1
- require 'spec_helper'
2
- require 'tmpdir'
3
- require 'fileutils'
4
-
5
- # FIXME This are helper methods that could be used by other tests in the
6
- # future, should we move these to a more central location
7
- def stub_repository_read(code, body)
8
- kind = Net::HTTPResponse.send(:response_class, code.to_s)
9
- response = kind.new('1.0', code.to_s, 'HTTP MESSAGE')
10
- response.stubs(:read_body).returns(body)
11
- Puppet::Forge::Repository.any_instance.stubs(:read_response).returns(response)
12
- end
13
-
14
- def stub_installer_read(body)
15
- Puppet::Module::Tool::Applications::Installer.any_instance.stubs(:read_match).returns(body)
16
- end
17
-
18
- def stub_cache_read(body)
19
- Puppet::Forge::Cache.any_instance.stubs(:read_retrieve).returns(body)
20
- end
21
-
22
- # Return path to temparory directory for testing.
23
- def testdir
24
- return @testdir ||= tmpdir("module_tool_testdir")
25
- end
26
-
27
- # Create a temporary testing directory, change into it, and execute the
28
- # +block+. When the block exists, remove the test directory and change back
29
- # to the previous directory.
30
- def mktestdircd(&block)
31
- previousdir = Dir.pwd
32
- rmtestdir
33
- FileUtils.mkdir_p(testdir)
34
- Dir.chdir(testdir)
35
- block.call
36
- ensure
37
- rmtestdir
38
- Dir.chdir previousdir
39
- end
40
-
41
- # Remove the temporary test directory.
42
- def rmtestdir
43
- FileUtils.rm_rf(testdir) if File.directory?(testdir)
44
- end
45
- # END helper methods
46
-
47
-
48
- # Directory that contains sample releases.
49
- RELEASE_FIXTURES_DIR = File.join(PuppetSpec::FIXTURE_DIR, "releases")
50
-
51
- # Return the pathname string to the directory containing the release fixture called +name+.
52
- def release_fixture(name)
53
- return File.join(RELEASE_FIXTURES_DIR, name)
54
- end
55
-
56
- # Copy the release fixture called +name+ into the current working directory.
57
- def install_release_fixture(name)
58
- release_fixture(name)
59
- FileUtils.cp_r(release_fixture(name), name)
60
- end
61
-
62
- describe "module_tool", :fails_on_windows => true do
63
- include PuppetSpec::Files
64
- before do
65
- @tmp_confdir = Puppet[:confdir] = tmpdir("module_tool_test_confdir")
66
- @tmp_vardir = Puppet[:vardir] = tmpdir("module_tool_test_vardir")
67
- Puppet[:module_repository] = "http://forge.puppetlabs.com"
68
- @mytmpdir = Pathname.new(tmpdir("module_tool_test"))
69
- @options = {}
70
- @options[:install_dir] = @mytmpdir
71
- @options[:module_repository] = "http://forge.puppetlabs.com"
72
- end
73
-
74
- def build_and_install_module
75
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
76
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
77
-
78
- FileUtils.mv("#{@full_module_name}/pkg/#{@release_name}.tar.gz", "#{@release_name}.tar.gz")
79
- FileUtils.rm_rf(@full_module_name)
80
-
81
- Puppet::Module::Tool::Applications::Installer.run("#{@release_name}.tar.gz", @options)
82
- end
83
-
84
- # Return STDOUT and STDERR output generated from +block+ as it's run within a temporary test directory.
85
- def run(&block)
86
- mktestdircd do
87
- block.call
88
- end
89
- end
90
-
91
- before :all do
92
- @username = "myuser"
93
- @module_name = "mymodule"
94
- @full_module_name = "#{@username}-#{@module_name}"
95
- @version = "0.0.1"
96
- @release_name = "#{@full_module_name}-#{@version}"
97
- end
98
-
99
- before :each do
100
- Puppet.settings.stubs(:parse)
101
- Puppet::Forge::Cache.clean
102
- end
103
-
104
- after :each do
105
- Puppet::Forge::Cache.clean
106
- end
107
-
108
- describe "generate" do
109
- it "should generate a module if given a dashed name" do
110
- run do
111
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
112
-
113
- File.directory?(@full_module_name).should == true
114
- modulefile = File.join(@full_module_name, "Modulefile")
115
- File.file?(modulefile).should == true
116
- metadata = Puppet::Module::Tool::Metadata.new
117
- Puppet::Module::Tool::ModulefileReader.evaluate(metadata, modulefile)
118
- metadata.full_module_name.should == @full_module_name
119
- metadata.username.should == @username
120
- metadata.name.should == @module_name
121
- end
122
- end
123
-
124
- it "should fail if given an undashed name" do
125
- run do
126
- lambda { Puppet::Module::Tool::Applications::Generator.run("invalid") }.should raise_error(RuntimeError)
127
- end
128
- end
129
-
130
- it "should fail if directory already exists" do
131
- run do
132
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
133
- lambda { Puppet::Module::Tool::Applications::Generator.run(@full_module_name) }.should raise_error(ArgumentError)
134
- end
135
- end
136
-
137
- it "should return an array of Pathname objects representing paths of generated files" do
138
- run do
139
- return_value = Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
140
- return_value.each do |generated_file|
141
- generated_file.should be_kind_of(Pathname)
142
- end
143
- return_value.should be_kind_of(Array)
144
- end
145
- end
146
- end
147
-
148
- describe "build" do
149
- it "should build a module in a directory" do
150
- run do
151
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
152
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
153
-
154
- File.directory?(File.join(@full_module_name, "pkg", @release_name)).should == true
155
- File.file?(File.join(@full_module_name, "pkg", @release_name + ".tar.gz")).should == true
156
- metadata_file = File.join(@full_module_name, "pkg", @release_name, "metadata.json")
157
- File.file?(metadata_file).should == true
158
- metadata = PSON.parse(File.read(metadata_file))
159
- metadata["name"].should == @full_module_name
160
- metadata["version"].should == @version
161
- metadata["checksums"].should be_a_kind_of(Hash)
162
- metadata["dependencies"].should == []
163
- metadata["types"].should == []
164
- end
165
- end
166
-
167
- it "should build a module's checksums" do
168
- run do
169
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
170
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
171
-
172
- metadata_file = File.join(@full_module_name, "pkg", @release_name, "metadata.json")
173
- metadata = PSON.parse(File.read(metadata_file))
174
- metadata["checksums"].should be_a_kind_of(Hash)
175
-
176
- modulefile_path = Pathname.new(File.join(@full_module_name, "Modulefile"))
177
- metadata["checksums"]["Modulefile"].should == Digest::MD5.hexdigest(modulefile_path.read)
178
- end
179
- end
180
-
181
- it "should build a module's types and providers" do
182
- run do
183
- name = "jamtur01-apache"
184
- install_release_fixture name
185
- Puppet::Module::Tool::Applications::Builder.run(name)
186
-
187
- metadata_file = File.join(name, "pkg", "#{name}-0.0.1", "metadata.json")
188
- metadata = PSON.parse(File.read(metadata_file))
189
-
190
- metadata["types"].size.should == 1
191
- type = metadata["types"].first
192
- type["name"].should == "a2mod"
193
- type["doc"].should == "Manage Apache 2 modules"
194
-
195
-
196
- type["parameters"].size.should == 1
197
- type["parameters"].first.tap do |o|
198
- o["name"].should == "name"
199
- o["doc"].should == "The name of the module to be managed"
200
- end
201
-
202
- type["properties"].size.should == 1
203
- type["properties"].first.tap do |o|
204
- o["name"].should == "ensure"
205
- o["doc"].should =~ /present.+absent/
206
- end
207
-
208
- type["providers"].size.should == 1
209
- type["providers"].first.tap do |o|
210
- o["name"].should == "debian"
211
- o["doc"].should =~ /Manage Apache 2 modules on Debian-like OSes/
212
- end
213
- end
214
- end
215
-
216
- it "should build a module's dependencies" do
217
- run do
218
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
219
- modulefile = File.join(@full_module_name, "Modulefile")
220
-
221
- dependency1_name = "anotheruser-anothermodule"
222
- dependency1_requirement = ">= 1.2.3"
223
- dependency2_name = "someuser-somemodule"
224
- dependency2_requirement = "4.2"
225
- dependency2_repository = "http://some.repo"
226
-
227
- File.open(modulefile, "a") do |handle|
228
- handle.puts "dependency '#{dependency1_name}', '#{dependency1_requirement}'"
229
- handle.puts "dependency '#{dependency2_name}', '#{dependency2_requirement}', '#{dependency2_repository}'"
230
- end
231
-
232
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
233
-
234
- metadata_file = File.join(@full_module_name, "pkg", "#{@full_module_name}-#{@version}", "metadata.json")
235
- metadata = PSON.parse(File.read(metadata_file))
236
-
237
- metadata['dependencies'].size.should == 2
238
- metadata['dependencies'].sort_by{|t| t['name']}.tap do |dependencies|
239
- dependencies[0].tap do |dependency1|
240
- dependency1['name'].should == dependency1_name
241
- dependency1['version_requirement'].should == dependency1_requirement
242
- dependency1['repository'].should be_nil
243
- end
244
-
245
- dependencies[1].tap do |dependency2|
246
- dependency2['name'].should == dependency2_name
247
- dependency2['version_requirement'].should == dependency2_requirement
248
- dependency2['repository'].should == dependency2_repository
249
- end
250
- end
251
- end
252
- end
253
-
254
- it "should rebuild a module in a directory" do
255
- run do
256
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
257
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
258
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
259
- end
260
- end
261
-
262
- it "should build a module in the current directory" do
263
- run do
264
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
265
- Dir.chdir(@full_module_name)
266
- Puppet::Module::Tool::Applications::Builder.run(Puppet::Module::Tool.find_module_root(nil))
267
-
268
- File.file?(File.join("pkg", @release_name + ".tar.gz")).should == true
269
- end
270
- end
271
-
272
- it "should fail to build a module without a Modulefile" do
273
- run do
274
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
275
- FileUtils.rm(File.join(@full_module_name, "Modulefile"))
276
-
277
- lambda { Puppet::Module::Tool::Applications::Builder.run(Puppet::Module::Tool.find_module_root(@full_module_name)) }.should raise_error(ArgumentError)
278
- end
279
- end
280
-
281
- it "should fail to build a module directory that doesn't exist" do
282
- run do
283
- lambda { Puppet::Module::Tool::Applications::Builder.run(Puppet::Module::Tool.find_module_root(@full_module_name)) }.should raise_error(ArgumentError)
284
- end
285
- end
286
-
287
- it "should fail to build a module in the current directory that's not a module" do
288
- run do
289
- lambda { Puppet::Module::Tool::Applications::Builder.run(Puppet::Module::Tool.find_module_root(nil)) }.should raise_error(ArgumentError)
290
- end
291
- end
292
-
293
- it "should return a Pathname object representing the path to the release archive." do
294
- run do
295
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
296
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name).should be_kind_of(Pathname)
297
- end
298
- end
299
- end
300
-
301
- describe "search" do
302
- it "should display matching modules" do
303
- run do
304
- stub_repository_read 200, <<-HERE
305
- [
306
- {"full_module_name": "cli", "version": "1.0"},
307
- {"full_module_name": "web", "version": "2.0"}
308
- ]
309
- HERE
310
- Puppet::Module::Tool::Applications::Searcher.run("mymodule", @options).size.should == 2
311
- end
312
- end
313
-
314
- it "should display no matches" do
315
- run do
316
- stub_repository_read 200, "[]"
317
- Puppet::Module::Tool::Applications::Searcher.run("mymodule", @options).should == []
318
- end
319
- end
320
-
321
- it "should fail if can't get a connection" do
322
- run do
323
- stub_repository_read 500, "OH NOES!!1!"
324
- lambda { Puppet::Module::Tool::Applications::Searcher.run("mymodule", @options) }.should raise_error(RuntimeError)
325
- end
326
- end
327
-
328
- it "should return an array of module metadata hashes" do
329
- run do
330
- results = <<-HERE
331
- [
332
- {"full_module_name": "cli", "version": "1.0"},
333
- {"full_module_name": "web", "version": "2.0"}
334
- ]
335
- HERE
336
- expected = [
337
- {"version"=>"1.0", "full_module_name"=>"cli"},
338
- {"version"=>"2.0", "full_module_name"=>"web"}
339
- ]
340
- stub_repository_read 200, results
341
- return_value = Puppet::Module::Tool::Applications::Searcher.run("mymodule", @options)
342
- return_value.should == expected
343
- return_value.should be_kind_of(Array)
344
- end
345
- end
346
- end
347
-
348
- describe "install" do
349
- it "should install a module to the puppet modulepath by default" do
350
- myothertmpdir = Pathname.new(tmpdir("module_tool_test_myothertmpdir"))
351
- run do
352
- @options[:install_dir] = myothertmpdir
353
- Puppet::Module::Tool.unstub(:install_dir)
354
-
355
- build_and_install_module
356
-
357
- File.directory?(myothertmpdir + @module_name).should == true
358
- File.file?(myothertmpdir + @module_name + 'metadata.json').should == true
359
- end
360
- end
361
-
362
- it "should install a module from a filesystem path" do
363
- run do
364
- build_and_install_module
365
-
366
- File.directory?(@mytmpdir + @module_name).should == true
367
- File.file?(@mytmpdir + @module_name + 'metadata.json').should == true
368
- end
369
- end
370
-
371
- it "should install a module from a webserver URL" do
372
- run do
373
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
374
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
375
-
376
- stub_cache_read File.read("#{@full_module_name}/pkg/#{@release_name}.tar.gz")
377
- FileUtils.rm_rf(@full_module_name)
378
-
379
- release = {"file" => "/foo/bar/#{@release_name}.tar.gz", "version" => "#{@version}"}
380
- Puppet::Forge::Forge.any_instance.stubs(:get_release).returns(release)
381
-
382
- Puppet::Module::Tool::Applications::Installer.run(@full_module_name, @options)
383
-
384
- File.directory?(@mytmpdir + @module_name).should == true
385
- File.file?(@mytmpdir + @module_name + 'metadata.json').should == true
386
- end
387
- end
388
-
389
- it "should install a module from a webserver URL using a version requirement" # TODO
390
-
391
- it "should fail if module isn't a slashed name" do
392
- run do
393
- lambda { Puppet::Module::Tool::Applications::Installer.run("invalid") }.should raise_error(RuntimeError)
394
- end
395
- end
396
-
397
- it "should fail if module doesn't exist on webserver" do
398
- run do
399
- stub_installer_read "{}"
400
- lambda { Puppet::Module::Tool::Applications::Installer.run("not-found", @options) }.should raise_error(RuntimeError)
401
- end
402
- end
403
-
404
- it "should fail gracefully when receiving invalid PSON" do
405
- pending "Implement PSON error wrapper" # TODO
406
- run do
407
- stub_installer_read "1/0"
408
- lambda { Puppet::Module::Tool::Applications::Installer.run("not-found") }.should raise_error(SystemExit)
409
- end
410
- end
411
-
412
- it "should fail if installing a module that's already installed" do
413
- run do
414
- name = "myuser-mymodule"
415
- Dir.mkdir name
416
- lambda { Puppet::Module::Tool::Applications::Installer.run(name) }.should raise_error(ArgumentError)
417
- end
418
- end
419
-
420
- it "should return a Pathname object representing the path to the installed module" do
421
- run do
422
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
423
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
424
-
425
- stub_cache_read File.read("#{@full_module_name}/pkg/#{@release_name}.tar.gz")
426
- FileUtils.rm_rf(@full_module_name)
427
-
428
- release = {"file" => "/foo/bar/#{@release_name}.tar.gz", "version" => "#{@version}"}
429
- Puppet::Forge::Forge.any_instance.stubs(:get_release).returns(release)
430
-
431
- Puppet::Module::Tool::Applications::Installer.run(@full_module_name, @options).should be_kind_of(Pathname)
432
- end
433
- end
434
-
435
- end
436
-
437
- describe "clean" do
438
- require 'puppet/module_tool'
439
- it "should clean cache" do
440
- run do
441
- build_and_install_module
442
- Puppet::Forge::Cache.base_path.directory?.should == true
443
- Puppet::Module::Tool::Applications::Cleaner.run
444
- Puppet::Forge::Cache.base_path.directory?.should == false
445
- end
446
- end
447
-
448
- it "should return a status Hash" do
449
- run do
450
- build_and_install_module
451
- return_value = Puppet::Module::Tool::Applications::Cleaner.run
452
- return_value.should include(:msg)
453
- return_value.should include(:status)
454
- return_value.should be_kind_of(Hash)
455
- end
456
- end
457
- end
458
-
459
- describe "changes" do
460
- it "should return an array of modified files" do
461
- run do
462
- Puppet::Module::Tool::Applications::Generator.run(@full_module_name)
463
- Puppet::Module::Tool::Applications::Builder.run(@full_module_name)
464
- Dir.chdir("#{@full_module_name}/pkg/#{@release_name}")
465
- File.open("Modulefile", "a") do |handle|
466
- handle.puts
467
- handle.puts "# Added"
468
- end
469
- return_value = Puppet::Module::Tool::Applications::Checksummer.run(".")
470
- return_value.should include("Modulefile")
471
- return_value.should be_kind_of(Array)
472
- end
473
- end
474
- end
475
- end