puppet 2.7.8 → 2.7.9
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.
- data/CHANGELOG +6 -0
- data/README_DEVELOPER.md +63 -0
- data/conf/redhat/puppet.spec +4 -1
- data/ext/puppetstoredconfigclean.rb +39 -27
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +33 -25
- data/lib/puppet/application/apply.rb +15 -1
- data/lib/puppet/application/module.rb +3 -0
- data/lib/puppet/defaults.rb +4 -0
- data/lib/puppet/face/module.rb +12 -0
- data/lib/puppet/face/module/build.rb +31 -0
- data/lib/puppet/face/module/changes.rb +38 -0
- data/lib/puppet/face/module/clean.rb +30 -0
- data/lib/puppet/face/module/generate.rb +40 -0
- data/lib/puppet/face/module/install.rb +83 -0
- data/lib/puppet/face/module/search.rb +66 -0
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/module_tool.rb +97 -0
- data/lib/puppet/module_tool/applications.rb +12 -0
- data/lib/puppet/module_tool/applications/application.rb +83 -0
- data/lib/puppet/module_tool/applications/builder.rb +91 -0
- data/lib/puppet/module_tool/applications/checksummer.rb +47 -0
- data/lib/puppet/module_tool/applications/cleaner.rb +16 -0
- data/lib/puppet/module_tool/applications/generator.rb +141 -0
- data/lib/puppet/module_tool/applications/installer.rb +89 -0
- data/lib/puppet/module_tool/applications/searcher.rb +40 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +70 -0
- data/lib/puppet/module_tool/cache.rb +56 -0
- data/lib/puppet/module_tool/checksums.rb +52 -0
- data/lib/puppet/module_tool/contents_description.rb +82 -0
- data/lib/puppet/module_tool/dependency.rb +24 -0
- data/lib/puppet/module_tool/metadata.rb +141 -0
- data/lib/puppet/module_tool/modulefile.rb +75 -0
- data/lib/puppet/module_tool/repository.rb +79 -0
- data/lib/puppet/module_tool/skeleton.rb +34 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +11 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +16 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +41 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +12 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +17 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +11 -0
- data/lib/puppet/module_tool/utils.rb +5 -0
- data/lib/puppet/module_tool/utils/interrogation.rb +25 -0
- data/lib/puppet/network/http/api/v1.rb +2 -1
- data/lib/puppet/parser/functions/create_resources.rb +19 -4
- data/lib/puppet/rails.rb +1 -1
- data/lib/puppet/rails/database/schema.rb +1 -1
- data/lib/puppet/ssl/host.rb +16 -8
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/type/file.rb +7 -2
- data/lib/puppet/type/file/ctime.rb +1 -1
- data/lib/puppet/type/file/mtime.rb +1 -1
- data/lib/puppet/type/file/type.rb +1 -1
- data/lib/puppet/util/queue/stomp.rb +19 -6
- data/lib/puppet/util/zaml.rb +39 -5
- data/spec/fixtures/releases/jamtur01-apache/Modulefile +2 -0
- data/spec/fixtures/releases/jamtur01-apache/files/httpd +24 -0
- data/spec/fixtures/releases/jamtur01-apache/files/test.vhost +18 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +21 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb +12 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/init.pp +34 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/params.pp +17 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/php.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -0
- data/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb +20 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/apache.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/dev.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/init.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/php.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp +2 -0
- data/spec/integration/module_tool_spec.rb +477 -0
- data/spec/integration/util/windows/security_spec.rb +1 -1
- data/spec/unit/application/agent_spec.rb +26 -0
- data/spec/unit/application/apply_spec.rb +12 -1
- data/spec/unit/face/module/build_spec.rb +30 -0
- data/spec/unit/face/module/changes_spec.rb +30 -0
- data/spec/unit/face/module/clean_spec.rb +30 -0
- data/spec/unit/face/module/generate_spec.rb +30 -0
- data/spec/unit/face/module/install_spec.rb +75 -0
- data/spec/unit/face/module/search_spec.rb +40 -0
- data/spec/unit/face/module_spec.rb +3 -0
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/module_tool/application_spec.rb +29 -0
- data/spec/unit/module_tool/metadata_spec.rb +11 -0
- data/spec/unit/module_tool/repository_spec.rb +52 -0
- data/spec/unit/module_tool_spec.rb +38 -0
- data/spec/unit/network/http/api/v1_spec.rb +4 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +21 -4
- data/spec/unit/rails_spec.rb +89 -158
- data/spec/unit/ssl/host_spec.rb +10 -33
- data/spec/unit/type/file_spec.rb +30 -0
- data/spec/unit/util/queue/stomp_spec.rb +9 -4
- data/spec/unit/util/zaml_spec.rb +37 -0
- metadata +77 -11
@@ -123,7 +123,7 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
|
|
123
123
|
end
|
124
124
|
|
125
125
|
describe "#mode=" do
|
126
|
-
(0000..0700).step(0100)
|
126
|
+
(0000..0700).step(0100) do |mode|
|
127
127
|
it "should enforce mode #{mode.to_s(8)}" do
|
128
128
|
winsec.set_mode(mode, path)
|
129
129
|
|
@@ -437,6 +437,32 @@ describe Puppet::Application::Agent do
|
|
437
437
|
@puppetd.setup_listen
|
438
438
|
end
|
439
439
|
end
|
440
|
+
|
441
|
+
describe "when setting up for fingerprint" do
|
442
|
+
before(:each) do
|
443
|
+
@puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should not setup as an agent" do
|
447
|
+
@puppetd.expects(:setup_agent).never
|
448
|
+
@puppetd.setup
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should not create an agent" do
|
452
|
+
Puppet::Agent.stubs(:new).with(Puppet::Configurer).never
|
453
|
+
@puppetd.setup
|
454
|
+
end
|
455
|
+
|
456
|
+
it "should not daemonize" do
|
457
|
+
@daemon.expects(:daemonize).never
|
458
|
+
@puppetd.setup
|
459
|
+
end
|
460
|
+
|
461
|
+
it "should setup our certificate host" do
|
462
|
+
@puppetd.expects(:setup_host)
|
463
|
+
@puppetd.setup
|
464
|
+
end
|
465
|
+
end
|
440
466
|
end
|
441
467
|
|
442
468
|
|
@@ -20,7 +20,7 @@ describe Puppet::Application::Apply do
|
|
20
20
|
Puppet::Node.indirection.cache_class = nil
|
21
21
|
end
|
22
22
|
|
23
|
-
[:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option|
|
23
|
+
[:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes,:catalog].each do |option|
|
24
24
|
it "should declare handle_#{option} method" do
|
25
25
|
@apply.should respond_to("handle_#{option}".to_sym)
|
26
26
|
end
|
@@ -53,6 +53,17 @@ describe Puppet::Application::Apply do
|
|
53
53
|
|
54
54
|
@apply.handle_logdest("console")
|
55
55
|
end
|
56
|
+
|
57
|
+
it "should deprecate --apply" do
|
58
|
+
Puppet.expects(:warning).with do |arg|
|
59
|
+
arg.match(/--apply is deprecated/)
|
60
|
+
end
|
61
|
+
|
62
|
+
command_line = Puppet::Util::CommandLine.new('puppet', ['apply', '--apply', 'catalog.json'])
|
63
|
+
apply = Puppet::Application::Apply.new(command_line)
|
64
|
+
apply.stubs(:run_command)
|
65
|
+
apply.run
|
66
|
+
end
|
56
67
|
end
|
57
68
|
|
58
69
|
describe "during setup" do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
|
4
|
+
describe "puppet module build" do
|
5
|
+
subject { Puppet::Face[:module, :current] }
|
6
|
+
|
7
|
+
describe "option validation" do
|
8
|
+
context "without any options" do
|
9
|
+
it "should require a path" do
|
10
|
+
pattern = /wrong number of arguments/
|
11
|
+
expect { subject.build }.to raise_error ArgumentError, pattern
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "inline documentation" do
|
17
|
+
subject { Puppet::Face[:module, :current].get_action :build }
|
18
|
+
|
19
|
+
its(:summary) { should =~ /build.*module/im }
|
20
|
+
its(:description) { should =~ /build.*module/im }
|
21
|
+
its(:returns) { should =~ /pathname/i }
|
22
|
+
its(:examples) { should_not be_empty }
|
23
|
+
|
24
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
25
|
+
context "of the" do
|
26
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
|
4
|
+
describe "puppet module changes" do
|
5
|
+
subject { Puppet::Face[:module, :current] }
|
6
|
+
|
7
|
+
describe "option validation" do
|
8
|
+
context "without any options" do
|
9
|
+
it "should require a path" do
|
10
|
+
pattern = /wrong number of arguments/
|
11
|
+
expect { subject.changes }.to raise_error ArgumentError, pattern
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "inline documentation" do
|
17
|
+
subject { Puppet::Face[:module, :current].get_action :changes }
|
18
|
+
|
19
|
+
its(:summary) { should =~ /modified.*module/im }
|
20
|
+
its(:description) { should =~ /modified.*module/im }
|
21
|
+
its(:returns) { should =~ /array/i }
|
22
|
+
its(:examples) { should_not be_empty }
|
23
|
+
|
24
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
25
|
+
context "of the" do
|
26
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
|
4
|
+
describe "puppet module clean" do
|
5
|
+
subject { Puppet::Face[:module, :current] }
|
6
|
+
|
7
|
+
describe "option validation" do
|
8
|
+
context "without any options" do
|
9
|
+
it "should not require any arguments" do
|
10
|
+
Puppet::Module::Tool::Applications::Cleaner.expects(:run).once
|
11
|
+
subject.clean
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "inline documentation" do
|
17
|
+
subject { Puppet::Face[:module, :current].get_action :clean }
|
18
|
+
|
19
|
+
its(:summary) { should =~ /clean.*module/im }
|
20
|
+
its(:description) { should =~ /clean.*module/im }
|
21
|
+
its(:returns) { should =~ /hash/i }
|
22
|
+
its(:examples) { should_not be_empty }
|
23
|
+
|
24
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
25
|
+
context "of the" do
|
26
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
|
4
|
+
describe "puppet module generate" do
|
5
|
+
subject { Puppet::Face[:module, :current] }
|
6
|
+
|
7
|
+
describe "option validation" do
|
8
|
+
context "without any options" do
|
9
|
+
it "should require name" do
|
10
|
+
pattern = /wrong number of arguments/
|
11
|
+
expect { subject.generate }.to raise_error ArgumentError, pattern
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "inline documentation" do
|
17
|
+
subject { Puppet::Face[:module, :current].get_action :generate }
|
18
|
+
|
19
|
+
its(:summary) { should =~ /generate.*module/im }
|
20
|
+
its(:description) { should =~ /generate.*module/im }
|
21
|
+
its(:returns) { should =~ /array/i }
|
22
|
+
its(:examples) { should_not be_empty }
|
23
|
+
|
24
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
25
|
+
context "of the" do
|
26
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
require 'puppet/module_tool'
|
4
|
+
|
5
|
+
describe "puppet module install" do
|
6
|
+
subject { Puppet::Face[:module, :current] }
|
7
|
+
|
8
|
+
let(:options) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "option validation" do
|
13
|
+
let(:expected_options) do
|
14
|
+
{
|
15
|
+
:install_dir => File.expand_path("/dev/null/modules"),
|
16
|
+
:module_repository => "http://forge.puppetlabs.com",
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
context "without any options" do
|
21
|
+
it "should require a name" do
|
22
|
+
pattern = /wrong number of arguments/
|
23
|
+
expect { subject.install }.to raise_error ArgumentError, pattern
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not require any options" do
|
27
|
+
Puppet::Module::Tool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
28
|
+
subject.install("puppetlabs-apache")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should accept the --force option" do
|
33
|
+
options[:force] = true
|
34
|
+
expected_options.merge!(options)
|
35
|
+
Puppet::Module::Tool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
36
|
+
subject.install("puppetlabs-apache", options)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should accept the --install-dir option" do
|
40
|
+
options[:install_dir] = "/foo/puppet/modules"
|
41
|
+
expected_options.merge!(options)
|
42
|
+
Puppet::Module::Tool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
43
|
+
subject.install("puppetlabs-apache", options)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should accept the --module-repository option" do
|
47
|
+
options[:module_repository] = "http://forge.example.com"
|
48
|
+
expected_options.merge!(options)
|
49
|
+
Puppet::Module::Tool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
50
|
+
subject.install("puppetlabs-apache", options)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should accept the --version option" do
|
54
|
+
options[:version] = "0.0.1"
|
55
|
+
expected_options.merge!(options)
|
56
|
+
Puppet::Module::Tool::Applications::Installer.expects(:run).with("puppetlabs-apache", expected_options).once
|
57
|
+
subject.install("puppetlabs-apache", options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "inline documentation" do
|
62
|
+
subject { Puppet::Face[:module, :current].get_action :install }
|
63
|
+
|
64
|
+
its(:summary) { should =~ /install.*module/im }
|
65
|
+
its(:description) { should =~ /install.*module/im }
|
66
|
+
its(:returns) { should =~ /pathname/i }
|
67
|
+
its(:examples) { should_not be_empty }
|
68
|
+
|
69
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
70
|
+
context "of the" do
|
71
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
|
4
|
+
describe "puppet module search" do
|
5
|
+
subject { Puppet::Face[:module, :current] }
|
6
|
+
|
7
|
+
let(:options) do
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "option validation" do
|
12
|
+
context "without any options" do
|
13
|
+
it "should require a search term" do
|
14
|
+
pattern = /wrong number of arguments/
|
15
|
+
expect { subject.search }.to raise_error ArgumentError, pattern
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should accept the --module-repository option" do
|
20
|
+
options[:module_repository] = "http://forge.example.com"
|
21
|
+
Puppet::Module::Tool::Applications::Searcher.expects(:run).with("puppetlabs-apache", options).once
|
22
|
+
subject.search("puppetlabs-apache", options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "inline documentation" do
|
27
|
+
subject { Puppet::Face[:module, :current].get_action :search }
|
28
|
+
|
29
|
+
its(:summary) { should =~ /search.*module/im }
|
30
|
+
its(:description) { should =~ /search.*module/im }
|
31
|
+
its(:returns) { should =~ /array/i }
|
32
|
+
its(:examples) { should_not be_empty }
|
33
|
+
|
34
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
35
|
+
context "of the" do
|
36
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -123,7 +123,7 @@ describe Puppet::FileBucket::Dipper do
|
|
123
123
|
klass.any_instance.expects(:find).with { |r| request = r }.returns(Puppet::FileBucket::File.new(contents))
|
124
124
|
|
125
125
|
dipper.restore(dest, md5).should == md5
|
126
|
-
Digest::MD5.
|
126
|
+
Digest::MD5.hexdigest(Puppet::Util.binread(dest)).should == md5
|
127
127
|
|
128
128
|
request.key.should == "md5/#{md5}"
|
129
129
|
request.server.should == server
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/module_tool'
|
3
|
+
|
4
|
+
describe Puppet::Module::Tool::Applications::Application do
|
5
|
+
describe 'app' do
|
6
|
+
|
7
|
+
good_versions = %w{ 1.2.4 0.0.1 0.0.0 0.0.2git-8-g3d316d1 0.0.3b1 10.100.10000
|
8
|
+
0.1.2rc1 0.1.2dev-1 0.1.2svn12345 }
|
9
|
+
bad_versions = %w{ 0.1.2-3 0.1 0 0.1.2.3 dev }
|
10
|
+
|
11
|
+
before do
|
12
|
+
@app = Class.new(described_class).new
|
13
|
+
end
|
14
|
+
|
15
|
+
good_versions.each do |ver|
|
16
|
+
it "should accept version string #{ver}" do
|
17
|
+
@app.instance_eval("@filename=%q{puppetlabs-ntp-#{ver}}")
|
18
|
+
@app.parse_filename!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
bad_versions.each do |ver|
|
23
|
+
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
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/module_tool'
|
3
|
+
|
4
|
+
describe Puppet::Module::Tool::Metadata do
|
5
|
+
context "when using default values" do
|
6
|
+
it "should set license to 'Apache License, Version 2.0'" do
|
7
|
+
metadata = Puppet::Module::Tool::Metadata.new
|
8
|
+
metadata.license.should == "Apache License, Version 2.0"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/http'
|
3
|
+
require 'puppet/module_tool'
|
4
|
+
|
5
|
+
describe Puppet::Module::Tool::Repository do
|
6
|
+
describe 'instances' do
|
7
|
+
before do
|
8
|
+
@repository = described_class.new('http://fake.com')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#make_http_request' do
|
12
|
+
before do
|
13
|
+
# Do a mock of the Proxy call so we can do proper expects for
|
14
|
+
# Net::HTTP
|
15
|
+
Net::HTTP.expects(:Proxy).returns(Net::HTTP)
|
16
|
+
Net::HTTP.expects(:start)
|
17
|
+
end
|
18
|
+
context "when not given an :authenticate option" do
|
19
|
+
it "should authenticate" do
|
20
|
+
@repository.expects(:authenticate).never
|
21
|
+
@repository.make_http_request(nil)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context "when given an :authenticate option" do
|
25
|
+
it "should authenticate" do
|
26
|
+
@repository.expects(:authenticate)
|
27
|
+
@repository.make_http_request(nil, :authenticate => true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#authenticate' do
|
33
|
+
it "should set basic auth on the request" do
|
34
|
+
authenticated_request = stub
|
35
|
+
authenticated_request.expects(:basic_auth)
|
36
|
+
@repository.expects(:prompt).twice
|
37
|
+
@repository.authenticate(authenticated_request)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#retrieve' do
|
42
|
+
before do
|
43
|
+
@uri = URI.parse('http://some.url.com')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should access the cache" do
|
47
|
+
@repository.cache.expects(:retrieve).with(@uri)
|
48
|
+
@repository.retrieve(@uri)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/module_tool'
|
3
|
+
|
4
|
+
describe Puppet::Module::Tool do
|
5
|
+
describe 'http_proxy support' do
|
6
|
+
before :each do
|
7
|
+
ENV["http_proxy"] = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
after :each do
|
11
|
+
ENV["http_proxy"] = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should support environment variable for port and host" do
|
15
|
+
ENV["http_proxy"] = "http://test.com:8011"
|
16
|
+
described_class.http_proxy_host.should == "test.com"
|
17
|
+
described_class.http_proxy_port.should == 8011
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should support puppet configuration for port and host" do
|
21
|
+
ENV["http_proxy"] = nil
|
22
|
+
Puppet.settings.stubs(:[]).with(:http_proxy_host).returns('test.com')
|
23
|
+
Puppet.settings.stubs(:[]).with(:http_proxy_port).returns(7456)
|
24
|
+
|
25
|
+
described_class.http_proxy_port.should == 7456
|
26
|
+
described_class.http_proxy_host.should == "test.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should use environment variable before puppet settings" do
|
30
|
+
ENV["http_proxy"] = "http://test1.com:8011"
|
31
|
+
Puppet.settings.stubs(:[]).with(:http_proxy_host).returns('test2.com')
|
32
|
+
Puppet.settings.stubs(:[]).with(:http_proxy_port).returns(7456)
|
33
|
+
|
34
|
+
described_class.http_proxy_host.should == "test1.com"
|
35
|
+
described_class.http_proxy_port.should == 8011
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|