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,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'puppet/module_tool'
3
3
 
4
- describe Puppet::Module::Tool::Applications::Application do
4
+ describe Puppet::ModuleTool::Applications::Application, :fails_on_windows => true do
5
5
  describe 'app' do
6
6
 
7
7
  good_versions = %w{ 1.2.4 0.0.1 0.0.0 0.0.2-git-8-g3d316d1 0.0.3-b1 10.100.10000
@@ -14,15 +14,13 @@ describe Puppet::Module::Tool::Applications::Application do
14
14
 
15
15
  good_versions.each do |ver|
16
16
  it "should accept version string #{ver}" do
17
- @app.instance_eval("@filename=%q{puppetlabs-ntp-#{ver}}")
18
- @app.parse_filename!
17
+ @app.parse_filename("puppetlabs-ntp-#{ver}")
19
18
  end
20
19
  end
21
20
 
22
21
  bad_versions.each do |ver|
23
22
  it "should not accept version string #{ver}" do
24
- @app.instance_eval("@filename=%q{puppetlabs-ntp-#{ver}}")
25
- lambda { @app.parse_filename! }.should raise_error
23
+ lambda { @app.parse_filename("puppetlabs-ntp-#{ver}") }.should raise_error
26
24
  end
27
25
  end
28
26
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'puppet/module_tool/applications'
3
+
4
+ describe Puppet::ModuleTool::Applications do
5
+ module Puppet::ModuleTool
6
+ module Applications
7
+ class Fake < Application
8
+ end
9
+ end
10
+ end
11
+
12
+ it "should raise an error on microsoft windows" do
13
+ Puppet.features.stubs(:microsoft_windows?).returns true
14
+ expect { Puppet::ModuleTool::Applications::Fake.new }.to raise_error(
15
+ Puppet::Error,
16
+ "`puppet module` actions are currently not supported on Microsoft Windows"
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,205 @@
1
+ require 'spec_helper'
2
+ require 'puppet/module_tool/applications'
3
+ require 'puppet_spec/modules'
4
+ require 'semver'
5
+
6
+ describe Puppet::ModuleTool::Applications::Installer, :fails_on_windows => true do
7
+ include PuppetSpec::Files
8
+
9
+ before do
10
+ FileUtils.mkdir_p(modpath1)
11
+ fake_env.modulepath = [modpath1]
12
+ FileUtils.touch(stdlib_pkg)
13
+ Puppet.settings[:modulepath] = modpath1
14
+ Puppet::Forge.stubs(:remote_dependency_info).returns(remote_dependency_info)
15
+ Puppet::Forge.stubs(:repository).returns(repository)
16
+ end
17
+
18
+ let(:unpacker) { stub(:run) }
19
+ let(:installer_class) { Puppet::ModuleTool::Applications::Installer }
20
+ let(:modpath1) { File.join(tmpdir("installer"), "modpath1") }
21
+ let(:stdlib_pkg) { File.join(modpath1, "pmtacceptance-stdlib-0.0.1.tar.gz") }
22
+ let(:fake_env) { Puppet::Node::Environment.new('fake_env') }
23
+ let(:options) { Hash[:target_dir => modpath1] }
24
+
25
+ let(:repository) do
26
+ repository = mock()
27
+ repository.stubs(:uri => 'forge-dev.puppetlabs.com')
28
+
29
+ releases = remote_dependency_info.each_key do |mod|
30
+ remote_dependency_info[mod].each do |release|
31
+ repository.stubs(:retrieve).with(release['file'])\
32
+ .returns("/fake_cache#{release['file']}")
33
+ end
34
+ end
35
+
36
+ repository
37
+ end
38
+
39
+ let(:remote_dependency_info) do
40
+ {
41
+ "pmtacceptance/stdlib" => [
42
+ { "dependencies" => [],
43
+ "version" => "0.0.1",
44
+ "file" => "/pmtacceptance-stdlib-0.0.1.tar.gz" },
45
+ { "dependencies" => [],
46
+ "version" => "0.0.2",
47
+ "file" => "/pmtacceptance-stdlib-0.0.2.tar.gz" },
48
+ { "dependencies" => [],
49
+ "version" => "1.0.0",
50
+ "file" => "/pmtacceptance-stdlib-1.0.0.tar.gz" }
51
+ ],
52
+ "pmtacceptance/java" => [
53
+ { "dependencies" => [["pmtacceptance/stdlib", ">= 0.0.1"]],
54
+ "version" => "1.7.0",
55
+ "file" => "/pmtacceptance-java-1.7.0.tar.gz" },
56
+ { "dependencies" => [["pmtacceptance/stdlib", "1.0.0"]],
57
+ "version" => "1.7.1",
58
+ "file" => "/pmtacceptance-java-1.7.1.tar.gz" }
59
+ ],
60
+ "pmtacceptance/apollo" => [
61
+ { "dependencies" => [
62
+ ["pmtacceptance/java", "1.7.1"],
63
+ ["pmtacceptance/stdlib", "0.0.1"]
64
+ ],
65
+ "version" => "0.0.1",
66
+ "file" => "/pmtacceptance-apollo-0.0.1.tar.gz" },
67
+ { "dependencies" => [
68
+ ["pmtacceptance/java", ">= 1.7.0"],
69
+ ["pmtacceptance/stdlib", ">= 1.0.0"]
70
+ ],
71
+ "version" => "0.0.2",
72
+ "file" => "/pmtacceptance-apollo-0.0.2.tar.gz" }
73
+ ]
74
+ }
75
+ end
76
+
77
+ describe "the behavior of .is_module_package?" do
78
+ it "should return true when file is a module package" do
79
+ installer = installer_class.new("foo", options)
80
+ installer.send(:is_module_package?, stdlib_pkg).should be_true
81
+ end
82
+
83
+ it "should return false when file is not a module package" do
84
+ installer = installer_class.new("foo", options)
85
+ installer.send(:is_module_package?, "pmtacceptance-apollo-0.0.2.tar").should be_false
86
+ end
87
+ end
88
+
89
+ context "when the source is a repository" do
90
+ it "should require a valid name" do
91
+ lambda { installer_class.run('puppet', params) }.should
92
+ raise_error(ArgumentError, "Could not install module with invalid name: puppet")
93
+ end
94
+
95
+ it "should install the requested module" do
96
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
97
+ .with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options)\
98
+ .returns(unpacker)
99
+ results = installer_class.run('pmtacceptance-stdlib', options)
100
+ results[:installed_modules].length == 1
101
+ results[:installed_modules][0][:module].should == "pmtacceptance-stdlib"
102
+ results[:installed_modules][0][:version][:vstring].should == "1.0.0"
103
+ end
104
+
105
+ context "when the requested module has dependencies" do
106
+ it "should install dependencies" do
107
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
108
+ .with('/fake_cache/pmtacceptance-stdlib-1.0.0.tar.gz', options)\
109
+ .returns(unpacker)
110
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
111
+ .with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options)\
112
+ .returns(unpacker)
113
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
114
+ .with('/fake_cache/pmtacceptance-java-1.7.1.tar.gz', options)\
115
+ .returns(unpacker)
116
+
117
+ results = installer_class.run('pmtacceptance-apollo', options)
118
+ installed_dependencies = results[:installed_modules][0][:dependencies]
119
+
120
+ dependencies = installed_dependencies.inject({}) do |result, dep|
121
+ result[dep[:module]] = dep[:version][:vstring]
122
+ result
123
+ end
124
+
125
+ dependencies.length.should == 2
126
+ dependencies['pmtacceptance-java'].should == '1.7.1'
127
+ dependencies['pmtacceptance-stdlib'].should == '1.0.0'
128
+ end
129
+
130
+ it "should install requested module if the '--force' flag is used" do
131
+ options = { :force => true, :target_dir => modpath1 }
132
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
133
+ .with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options)\
134
+ .returns(unpacker)
135
+ results = installer_class.run('pmtacceptance-apollo', options)
136
+ results[:installed_modules][0][:module].should == "pmtacceptance-apollo"
137
+ end
138
+
139
+ it "should not install dependencies if the '--force' flag is used" do
140
+ options = { :force => true, :target_dir => modpath1 }
141
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
142
+ .with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options)\
143
+ .returns(unpacker)
144
+ results = installer_class.run('pmtacceptance-apollo', options)
145
+ dependencies = results[:installed_modules][0][:dependencies]
146
+ dependencies.should == []
147
+ end
148
+
149
+ it "should not install dependencies if the '--ignore-dependencies' flag is used" do
150
+ options = { :ignore_dependencies => true, :target_dir => modpath1 }
151
+ Puppet::ModuleTool::Applications::Unpacker.expects(:new)\
152
+ .with('/fake_cache/pmtacceptance-apollo-0.0.2.tar.gz', options)\
153
+ .returns(unpacker)
154
+ results = installer_class.run('pmtacceptance-apollo', options)
155
+ dependencies = results[:installed_modules][0][:dependencies]
156
+ dependencies.should == []
157
+ end
158
+
159
+ it "should set an error if dependencies can't be resolved" do
160
+ options = { :version => '0.0.1', :target_dir => modpath1 }
161
+ oneline = "'pmtacceptance-apollo' (v0.0.1) requested; Invalid dependency cycle"
162
+ multiline = <<-MSG.strip
163
+ Could not install module 'pmtacceptance-apollo' (v0.0.1)
164
+ No version of 'pmtacceptance-stdlib' will satisfy dependencies
165
+ You specified 'pmtacceptance-apollo' (v0.0.1),
166
+ which depends on 'pmtacceptance-java' (v1.7.1),
167
+ which depends on 'pmtacceptance-stdlib' (v1.0.0)
168
+ Use `puppet module install --force` to install this module anyway
169
+ MSG
170
+
171
+ results = installer_class.run('pmtacceptance-apollo', options)
172
+ results[:result].should == :failure
173
+ results[:error][:oneline].should == oneline
174
+ results[:error][:multiline].should == multiline
175
+ end
176
+ end
177
+
178
+ context "when there are modules installed" do
179
+ it "should use local version when already exists and satisfies constraints"
180
+ it "should reinstall the local version if force is used"
181
+ it "should upgrade local version when necessary to satisfy constraints"
182
+ it "should error when a local version can't be upgraded to satisfy constraints"
183
+ end
184
+
185
+ context "when a local module needs upgrading to satisfy constraints but has changes" do
186
+ it "should error"
187
+ it "should warn and continue if force is used"
188
+ end
189
+
190
+ it "should error when a local version of a dependency has no version metadata"
191
+ it "should error when a local version of a dependency has a non-semver version"
192
+ it "should error when a local version of a dependency has a different forge name"
193
+ it "should error when a local version of a dependency has no metadata"
194
+ end
195
+
196
+ context "when the source is a filesystem" do
197
+ before do
198
+ @sourcedir = tmpdir('sourcedir')
199
+ end
200
+
201
+ it "should error if it can't parse the name"
202
+
203
+ it "should try to get_release_package_from_filesystem if it has a valid name"
204
+ end
205
+ end
@@ -0,0 +1,206 @@
1
+ require 'spec_helper'
2
+ require 'puppet/module_tool'
3
+ require 'tmpdir'
4
+ require 'puppet_spec/modules'
5
+
6
+ describe Puppet::ModuleTool::Applications::Uninstaller, :fails_on_windows => true do
7
+ include PuppetSpec::Files
8
+
9
+ def mkmod(name, path, metadata=nil)
10
+ modpath = File.join(path, name)
11
+ FileUtils.mkdir_p(modpath)
12
+
13
+ if metadata
14
+ File.open(File.join(modpath, 'metadata.json'), 'w') do |f|
15
+ f.write(metadata.to_pson)
16
+ end
17
+ end
18
+
19
+ modpath
20
+ end
21
+
22
+ describe "the behavior of the instances" do
23
+
24
+ before do
25
+ @uninstaller = Puppet::ModuleTool::Applications::Uninstaller
26
+ FileUtils.mkdir_p(modpath1)
27
+ FileUtils.mkdir_p(modpath2)
28
+ fake_env.modulepath = [modpath1, modpath2]
29
+ end
30
+
31
+ let(:modpath1) { File.join(tmpdir("uninstaller"), "modpath1") }
32
+ let(:modpath2) { File.join(tmpdir("uninstaller"), "modpath2") }
33
+ let(:fake_env) { Puppet::Node::Environment.new('fake_env') }
34
+ let(:options) { {:environment => "fake_env"} }
35
+
36
+ let(:foo_metadata) do
37
+ {
38
+ :author => "puppetlabs",
39
+ :name => "puppetlabs/foo",
40
+ :version => "1.0.0",
41
+ :source => "http://dummyurl/foo",
42
+ :license => "Apache2",
43
+ :dependencies => [],
44
+ }
45
+ end
46
+
47
+ let(:bar_metadata) do
48
+ {
49
+ :author => "puppetlabs",
50
+ :name => "puppetlabs/bar",
51
+ :version => "1.0.0",
52
+ :source => "http://dummyurl/bar",
53
+ :license => "Apache2",
54
+ :dependencies => [],
55
+ }
56
+ end
57
+
58
+ context "when the module is not installed" do
59
+ it "should fail" do
60
+ @uninstaller.new('fakemod_not_installed', options).run[:result].should == :failure
61
+ end
62
+ end
63
+
64
+ context "when the module is installed" do
65
+
66
+ it "should uninstall the module" do
67
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
68
+
69
+ results = @uninstaller.new("puppetlabs-foo", options).run
70
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
71
+ end
72
+
73
+ it "should only uninstall the requested module" do
74
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
75
+ PuppetSpec::Modules.create('bar', modpath1, :metadata => bar_metadata)
76
+
77
+ results = @uninstaller.new("puppetlabs-foo", options).run
78
+ results[:affected_modules].length == 1
79
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
80
+ end
81
+
82
+ it "should uninstall fail if a module exists twice in the modpath" do
83
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
84
+ PuppetSpec::Modules.create('foo', modpath2, :metadata => foo_metadata)
85
+
86
+ @uninstaller.new('puppetlabs-foo', options).run[:result].should == :failure
87
+ end
88
+
89
+ context "when options[:version] is specified" do
90
+
91
+ it "should uninstall the module if the version matches" do
92
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
93
+
94
+ options[:version] = "1.0.0"
95
+
96
+ results = @uninstaller.new("puppetlabs-foo", options).run
97
+ results[:affected_modules].length.should == 1
98
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
99
+ results[:affected_modules].first.version.should == "1.0.0"
100
+ end
101
+
102
+ it "should not uninstall the module if the version does not match" do
103
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
104
+
105
+ options[:version] = "2.0.0"
106
+
107
+ @uninstaller.new("puppetlabs-foo", options).run[:result].should == :failure
108
+ end
109
+ end
110
+
111
+ context "when the module metadata is missing" do
112
+
113
+ it "should not uninstall the module" do
114
+ PuppetSpec::Modules.create('foo', modpath1)
115
+
116
+ @uninstaller.new("puppetlabs-foo", options).run[:result].should == :failure
117
+ end
118
+ end
119
+
120
+ context "when the module has local changes" do
121
+
122
+ it "should not uninstall the module" do
123
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
124
+ Puppet::Module.any_instance.stubs(:has_local_changes?).returns(true)
125
+
126
+ @uninstaller.new("puppetlabs-foo", options).run[:result].should == :failure
127
+ end
128
+
129
+ end
130
+
131
+ context "when the module does not have local changes" do
132
+
133
+ it "should uninstall the module" do
134
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
135
+
136
+ results = @uninstaller.new("puppetlabs-foo", options).run
137
+ results[:affected_modules].length.should == 1
138
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
139
+ end
140
+ end
141
+
142
+ context "when uninstalling the module will cause broken dependencies" do
143
+ it "should not uninstall the module" do
144
+ Puppet.settings[:modulepath] = modpath1
145
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
146
+
147
+ PuppetSpec::Modules.create(
148
+ 'needy',
149
+ modpath1,
150
+ :metadata => {
151
+ :author => 'beggar',
152
+ :dependencies => [{
153
+ "version_requirement" => ">= 1.0.0",
154
+ "name" => "puppetlabs/foo"
155
+ }]
156
+ }
157
+ )
158
+
159
+ @uninstaller.new("puppetlabs-foo", options).run[:result].should == :failure
160
+ end
161
+ end
162
+
163
+ context "when using the --force flag" do
164
+
165
+ let(:fakemod) do
166
+ stub(
167
+ :forge_name => 'puppetlabs/fakemod',
168
+ :version => '0.0.1',
169
+ :has_local_changes? => true
170
+ )
171
+ end
172
+
173
+ it "should ignore local changes" do
174
+ foo = mkmod("foo", modpath1, foo_metadata)
175
+ options[:force] = true
176
+
177
+ results = @uninstaller.new("puppetlabs-foo", options).run
178
+ results[:affected_modules].length.should == 1
179
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
180
+ end
181
+
182
+ it "should ignore broken dependencies" do
183
+ Puppet.settings[:modulepath] = modpath1
184
+ PuppetSpec::Modules.create('foo', modpath1, :metadata => foo_metadata)
185
+
186
+ PuppetSpec::Modules.create(
187
+ 'needy',
188
+ modpath1,
189
+ :metadata => {
190
+ :author => 'beggar',
191
+ :dependencies => [{
192
+ "version_requirement" => ">= 1.0.0",
193
+ "name" => "puppetlabs/foo"
194
+ }]
195
+ }
196
+ )
197
+ options[:force] = true
198
+
199
+ results = @uninstaller.new("puppetlabs-foo", options).run
200
+ results[:affected_modules].length.should == 1
201
+ results[:affected_modules].first.forge_name.should == "puppetlabs/foo"
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end