puppet 2.7.11 → 2.7.12
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 +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -4,9 +4,9 @@ require 'puppet/module_tool'
|
|
4
4
|
describe Puppet::Module::Tool::Applications::Application do
|
5
5
|
describe 'app' do
|
6
6
|
|
7
|
-
good_versions = %w{ 1.2.4 0.0.1 0.0.0 0.0.
|
8
|
-
0.1.
|
9
|
-
bad_versions = %w{ 0.1
|
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
|
8
|
+
0.1.2-rc1 0.1.2-dev-1 0.1.2-svn12345 0.1.2-3 }
|
9
|
+
bad_versions = %w{ 0.1 0 0.1.2.3 dev 0.1.2beta }
|
10
10
|
|
11
11
|
before do
|
12
12
|
@app = Class.new(described_class).new
|
@@ -5,40 +5,120 @@ require 'tmpdir'
|
|
5
5
|
describe Puppet::Module::Tool::Applications::Uninstaller do
|
6
6
|
include PuppetSpec::Files
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
let(:options) do
|
12
|
-
{ :target_directories => [ tmp_module_path1, tmp_module_path2 ] }
|
13
|
-
end
|
8
|
+
def mkmod(name, path, metadata=nil)
|
9
|
+
modpath = File.join(path, name)
|
10
|
+
FileUtils.mkdir_p(modpath)
|
14
11
|
|
15
|
-
|
16
|
-
|
12
|
+
# For some tests we need the metadata to be present, mainly
|
13
|
+
# when testing against specific versions of a module.
|
14
|
+
if metadata
|
15
|
+
File.open(File.join(modpath, 'metadata.json'), 'w') do |f|
|
16
|
+
f.write(metadata.to_pson)
|
17
|
+
end
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
Dir.mkdir(foo_module_path)
|
22
|
-
described_class.new('foo', options).run.should == [ foo_module_path ]
|
23
|
-
end
|
20
|
+
modpath
|
21
|
+
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
describe "the behavior of the instances" do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@uninstaller = Puppet::Module::Tool::Applications::Uninstaller
|
27
|
+
FileUtils.mkdir_p(modpath1)
|
28
|
+
FileUtils.mkdir_p(modpath2)
|
29
|
+
fake_env.modulepath = [modpath1, modpath2]
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
let(:modpath1) { File.join(tmpdir("uninstaller"), "modpath1") }
|
33
|
+
let(:modpath2) { File.join(tmpdir("uninstaller"), "modpath2") }
|
34
|
+
let(:fake_env) { Puppet::Node::Environment.new('fake_env') }
|
35
|
+
let(:options) { {:environment => "fake_env"} }
|
36
|
+
|
37
|
+
context "when the module is not installed" do
|
38
|
+
it "should return an empty list" do
|
39
|
+
results = @uninstaller.new('fakemod_not_installed', options).run
|
40
|
+
results[:removed_mods].should == []
|
41
|
+
end
|
39
42
|
end
|
40
43
|
|
41
|
-
|
42
|
-
|
44
|
+
context "when the module is installed" do
|
45
|
+
it "should uninstall the module" do
|
46
|
+
foo = mkmod("foo", modpath1)
|
47
|
+
|
48
|
+
results = @uninstaller.new("foo", options).run
|
49
|
+
results[:removed_mods].should == [
|
50
|
+
Puppet::Module.new('foo', :environment => fake_env, :path => foo)
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should only uninstall the requested module" do
|
55
|
+
foo = mkmod("foo", modpath1)
|
56
|
+
|
57
|
+
results = @uninstaller.new("foo", options).run
|
58
|
+
results[:removed_mods].should == [
|
59
|
+
Puppet::Module.new("foo", :environment => fake_env, :path => foo)
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should uninstall the module from every path in the modpath" do
|
64
|
+
foo1 = mkmod('foo', modpath1)
|
65
|
+
foo2 = mkmod('foo', modpath2)
|
66
|
+
|
67
|
+
results = @uninstaller.new('foo', options).run
|
68
|
+
results[:removed_mods].length.should == 2
|
69
|
+
results[:removed_mods].should include(
|
70
|
+
Puppet::Module.new('foo', :environment => fake_env, :path => foo1),
|
71
|
+
Puppet::Module.new('foo', :environment => fake_env, :path => foo2)
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when options[:version] is specified" do
|
76
|
+
let(:metadata) do
|
77
|
+
{
|
78
|
+
"author" => "",
|
79
|
+
"name" => "foo",
|
80
|
+
"version" => "1.0.0",
|
81
|
+
"source" => "http://dummyurl",
|
82
|
+
"license" => "Apache2",
|
83
|
+
"dependencies" => [],
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should uninstall the module if the version matches" do
|
88
|
+
foo = mkmod('foo', modpath1, metadata)
|
89
|
+
|
90
|
+
options[:version] = "1.0.0"
|
91
|
+
|
92
|
+
results = @uninstaller.new("foo", options).run
|
93
|
+
results[:removed_mods].length.should == 1
|
94
|
+
results[:removed_mods].first.name.should == "foo"
|
95
|
+
results[:removed_mods].first.version.should == "1.0.0"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should not uninstall the module if the version does not match" do
|
99
|
+
foo = mkmod("foo", modpath1, metadata)
|
100
|
+
|
101
|
+
options[:version] = "2.0.0"
|
102
|
+
|
103
|
+
results = @uninstaller.new("foo", options).run
|
104
|
+
results[:removed_mods].should == []
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when the module metadata is missing" do
|
108
|
+
it "should not uninstall the module" do
|
109
|
+
foo = mkmod("foo", modpath1)
|
110
|
+
|
111
|
+
options[:version] = "2.0.0"
|
112
|
+
|
113
|
+
results = @uninstaller.new("foo", options).run
|
114
|
+
results[:removed_mods].should == []
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# This test is pending work in #11803 to which will add
|
120
|
+
# dependency resolution.
|
121
|
+
it "should check for broken dependencies"
|
122
|
+
end
|
43
123
|
end
|
44
124
|
end
|
@@ -2,37 +2,4 @@ require 'spec_helper'
|
|
2
2
|
require 'puppet/module_tool'
|
3
3
|
|
4
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
5
|
end
|
@@ -97,13 +97,14 @@ describe Puppet::Network::AuthConfig do
|
|
97
97
|
describe "when parsing authconfig file" do
|
98
98
|
before :each do
|
99
99
|
@fd = stub 'fd'
|
100
|
+
@fd.expects(:each).never
|
100
101
|
File.stubs(:open).yields(@fd)
|
101
102
|
@rights.stubs(:include?).returns(false)
|
102
103
|
@rights.stubs(:[])
|
103
104
|
end
|
104
105
|
|
105
106
|
it "should skip comments" do
|
106
|
-
@fd.stubs(:
|
107
|
+
@fd.stubs(:each_line).yields(' # comment')
|
107
108
|
|
108
109
|
@rights.expects(:newright).never
|
109
110
|
|
@@ -111,7 +112,7 @@ describe Puppet::Network::AuthConfig do
|
|
111
112
|
end
|
112
113
|
|
113
114
|
it "should increment line number even on commented lines" do
|
114
|
-
@fd.stubs(:
|
115
|
+
@fd.stubs(:each_line).multiple_yields(' # comment','[puppetca]')
|
115
116
|
|
116
117
|
@rights.expects(:newright).with('[puppetca]', 2, 'dummy')
|
117
118
|
|
@@ -119,7 +120,7 @@ describe Puppet::Network::AuthConfig do
|
|
119
120
|
end
|
120
121
|
|
121
122
|
it "should skip blank lines" do
|
122
|
-
@fd.stubs(:
|
123
|
+
@fd.stubs(:each_line).yields(' ')
|
123
124
|
|
124
125
|
@rights.expects(:newright).never
|
125
126
|
|
@@ -127,7 +128,7 @@ describe Puppet::Network::AuthConfig do
|
|
127
128
|
end
|
128
129
|
|
129
130
|
it "should increment line number even on blank lines" do
|
130
|
-
@fd.stubs(:
|
131
|
+
@fd.stubs(:each_line).multiple_yields(' ','[puppetca]')
|
131
132
|
|
132
133
|
@rights.expects(:newright).with('[puppetca]', 2, 'dummy')
|
133
134
|
|
@@ -135,7 +136,7 @@ describe Puppet::Network::AuthConfig do
|
|
135
136
|
end
|
136
137
|
|
137
138
|
it "should throw an error if the current namespace right already exist" do
|
138
|
-
@fd.stubs(:
|
139
|
+
@fd.stubs(:each_line).yields('[puppetca]')
|
139
140
|
|
140
141
|
@rights.stubs(:include?).with("puppetca").returns(true)
|
141
142
|
|
@@ -143,7 +144,7 @@ describe Puppet::Network::AuthConfig do
|
|
143
144
|
end
|
144
145
|
|
145
146
|
it "should not throw an error if the current path right already exist" do
|
146
|
-
@fd.stubs(:
|
147
|
+
@fd.stubs(:each_line).yields('path /hello')
|
147
148
|
|
148
149
|
@rights.stubs(:newright).with("/hello",1, 'dummy')
|
149
150
|
@rights.stubs(:include?).with("/hello").returns(true)
|
@@ -152,7 +153,7 @@ describe Puppet::Network::AuthConfig do
|
|
152
153
|
end
|
153
154
|
|
154
155
|
it "should create a new right for found namespaces" do
|
155
|
-
@fd.stubs(:
|
156
|
+
@fd.stubs(:each_line).yields('[puppetca]')
|
156
157
|
|
157
158
|
@rights.expects(:newright).with("[puppetca]", 1, 'dummy')
|
158
159
|
|
@@ -160,7 +161,7 @@ describe Puppet::Network::AuthConfig do
|
|
160
161
|
end
|
161
162
|
|
162
163
|
it "should create a new right for each found namespace line" do
|
163
|
-
@fd.stubs(:
|
164
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', '[fileserver]')
|
164
165
|
|
165
166
|
@rights.expects(:newright).with("[puppetca]", 1, 'dummy')
|
166
167
|
@rights.expects(:newright).with("[fileserver]", 2, 'dummy')
|
@@ -169,7 +170,7 @@ describe Puppet::Network::AuthConfig do
|
|
169
170
|
end
|
170
171
|
|
171
172
|
it "should create a new right for each found path line" do
|
172
|
-
@fd.stubs(:
|
173
|
+
@fd.stubs(:each_line).multiple_yields('path /certificates')
|
173
174
|
|
174
175
|
@rights.expects(:newright).with("/certificates", 1, 'dummy')
|
175
176
|
|
@@ -177,7 +178,7 @@ describe Puppet::Network::AuthConfig do
|
|
177
178
|
end
|
178
179
|
|
179
180
|
it "should create a new right for each found regex line" do
|
180
|
-
@fd.stubs(:
|
181
|
+
@fd.stubs(:each_line).multiple_yields('path ~ .rb$')
|
181
182
|
|
182
183
|
@rights.expects(:newright).with("~ .rb$", 1, 'dummy')
|
183
184
|
|
@@ -187,7 +188,7 @@ describe Puppet::Network::AuthConfig do
|
|
187
188
|
it "should strip whitespace around ACE" do
|
188
189
|
acl = stub 'acl', :info
|
189
190
|
|
190
|
-
@fd.stubs(:
|
191
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0 ')
|
191
192
|
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
192
193
|
|
193
194
|
acl.expects(:allow).with('127.0.0.1')
|
@@ -199,7 +200,7 @@ describe Puppet::Network::AuthConfig do
|
|
199
200
|
it "should allow ACE inline comments" do
|
200
201
|
acl = stub 'acl', :info
|
201
202
|
|
202
|
-
@fd.stubs(:
|
203
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
|
203
204
|
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
204
205
|
|
205
206
|
acl.expects(:allow).with('127.0.0.1')
|
@@ -210,7 +211,7 @@ describe Puppet::Network::AuthConfig do
|
|
210
211
|
it "should create an allow ACE on each subsequent allow" do
|
211
212
|
acl = stub 'acl', :info
|
212
213
|
|
213
|
-
@fd.stubs(:
|
214
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', 'allow 127.0.0.1')
|
214
215
|
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
215
216
|
|
216
217
|
acl.expects(:allow).with('127.0.0.1')
|
@@ -221,7 +222,7 @@ describe Puppet::Network::AuthConfig do
|
|
221
222
|
it "should create a deny ACE on each subsequent deny" do
|
222
223
|
acl = stub 'acl', :info
|
223
224
|
|
224
|
-
@fd.stubs(:
|
225
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', 'deny 127.0.0.1')
|
225
226
|
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
226
227
|
|
227
228
|
acl.expects(:deny).with('127.0.0.1')
|
@@ -233,7 +234,7 @@ describe Puppet::Network::AuthConfig do
|
|
233
234
|
acl = stub 'acl', :info
|
234
235
|
acl.stubs(:acl_type).returns(:regex)
|
235
236
|
|
236
|
-
@fd.stubs(:
|
237
|
+
@fd.stubs(:each_line).multiple_yields('path /certificates', 'method search,find')
|
237
238
|
@rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
|
238
239
|
|
239
240
|
acl.expects(:restrict_method).with('search')
|
@@ -246,7 +247,7 @@ describe Puppet::Network::AuthConfig do
|
|
246
247
|
acl = stub 'acl', :info
|
247
248
|
acl.stubs(:acl_type).returns(:regex)
|
248
249
|
|
249
|
-
@fd.stubs(:
|
250
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', 'method search,find')
|
250
251
|
@rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
|
251
252
|
|
252
253
|
lambda { @authconfig.read }.should raise_error
|
@@ -256,7 +257,7 @@ describe Puppet::Network::AuthConfig do
|
|
256
257
|
acl = stub 'acl', :info
|
257
258
|
acl.stubs(:acl_type).returns(:regex)
|
258
259
|
|
259
|
-
@fd.stubs(:
|
260
|
+
@fd.stubs(:each_line).multiple_yields('path /certificates', 'environment production,development')
|
260
261
|
@rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
|
261
262
|
|
262
263
|
acl.expects(:restrict_environment).with('production')
|
@@ -269,7 +270,7 @@ describe Puppet::Network::AuthConfig do
|
|
269
270
|
acl = stub 'acl', :info
|
270
271
|
acl.stubs(:acl_type).returns(:regex)
|
271
272
|
|
272
|
-
@fd.stubs(:
|
273
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', 'environment env')
|
273
274
|
@rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
|
274
275
|
|
275
276
|
lambda { @authconfig.read }.should raise_error
|
@@ -279,7 +280,7 @@ describe Puppet::Network::AuthConfig do
|
|
279
280
|
acl = stub 'acl', :info
|
280
281
|
acl.stubs(:acl_type).returns(:regex)
|
281
282
|
|
282
|
-
@fd.stubs(:
|
283
|
+
@fd.stubs(:each_line).multiple_yields('path /certificates', 'auth yes')
|
283
284
|
@rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
|
284
285
|
|
285
286
|
acl.expects(:restrict_authenticated).with('yes')
|
@@ -291,7 +292,7 @@ describe Puppet::Network::AuthConfig do
|
|
291
292
|
acl = stub 'acl', :info
|
292
293
|
acl.stubs(:acl_type).returns(:regex)
|
293
294
|
|
294
|
-
@fd.stubs(:
|
295
|
+
@fd.stubs(:each_line).multiple_yields('path /certificates', 'authenticated yes')
|
295
296
|
@rights.stubs(:newright).with("/certificates", 1, 'dummy').returns(acl)
|
296
297
|
|
297
298
|
acl.expects(:restrict_authenticated).with('yes')
|
@@ -303,7 +304,7 @@ describe Puppet::Network::AuthConfig do
|
|
303
304
|
acl = stub 'acl', :info
|
304
305
|
acl.stubs(:acl_type).returns(:regex)
|
305
306
|
|
306
|
-
@fd.stubs(:
|
307
|
+
@fd.stubs(:each_line).multiple_yields('[puppetca]', 'auth yes')
|
307
308
|
@rights.stubs(:newright).with("puppetca", 1, 'dummy').returns(acl)
|
308
309
|
|
309
310
|
lambda { @authconfig.read }.should raise_error
|
@@ -4,13 +4,13 @@ require 'puppet/network/handler'
|
|
4
4
|
require 'puppet/network/http'
|
5
5
|
require 'puppet/network/http/webrick'
|
6
6
|
|
7
|
-
describe Puppet::Network::HTTP::WEBrick, "after initializing"
|
7
|
+
describe Puppet::Network::HTTP::WEBrick, "after initializing" do
|
8
8
|
it "should not be listening" do
|
9
9
|
Puppet::Network::HTTP::WEBrick.new.should_not be_listening
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe Puppet::Network::HTTP::WEBrick, "when turning on listening"
|
13
|
+
describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
|
14
14
|
before do
|
15
15
|
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
|
16
16
|
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
|
@@ -139,7 +139,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening", :unless =>
|
|
139
139
|
end
|
140
140
|
|
141
141
|
|
142
|
-
describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol"
|
142
|
+
describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol" do
|
143
143
|
it "should require a protocol" do
|
144
144
|
lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should raise_error(ArgumentError)
|
145
145
|
end
|
@@ -157,7 +157,7 @@ describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
describe Puppet::Network::HTTP::WEBrick, "when turning off listening"
|
160
|
+
describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
|
161
161
|
before do
|
162
162
|
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
|
163
163
|
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
|
@@ -184,7 +184,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning off listening", :unless =
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
describe Puppet::Network::HTTP::WEBrick
|
187
|
+
describe Puppet::Network::HTTP::WEBrick do
|
188
188
|
before do
|
189
189
|
@mock_webrick = stub('webrick', :[] => {})
|
190
190
|
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
|
@@ -196,7 +196,7 @@ describe Puppet::Network::HTTP::WEBrick, :unless => Puppet.features.microsoft_wi
|
|
196
196
|
before do
|
197
197
|
Puppet.settings.stubs(:value).returns "something"
|
198
198
|
Puppet.settings.stubs(:use)
|
199
|
-
@filehandle = stub 'handle', :fcntl => nil, :sync => nil
|
199
|
+
@filehandle = stub 'handle', :fcntl => nil, :sync= => nil
|
200
200
|
|
201
201
|
File.stubs(:open).returns @filehandle
|
202
202
|
end
|
@@ -227,14 +227,18 @@ describe Puppet::Network::HTTP::WEBrick, :unless => Puppet.features.microsoft_wi
|
|
227
227
|
end
|
228
228
|
|
229
229
|
describe "and creating the logging filehandle" do
|
230
|
-
it "should set
|
231
|
-
|
230
|
+
it "should set the close-on-exec flag if supported" do
|
231
|
+
if defined? Fcntl::FD_CLOEXEC
|
232
|
+
@filehandle.expects(:fcntl).with(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
233
|
+
else
|
234
|
+
@filehandle.expects(:fcntl).never
|
235
|
+
end
|
232
236
|
|
233
237
|
@server.setup_logger
|
234
238
|
end
|
235
239
|
|
236
240
|
it "should sync the filehandle" do
|
237
|
-
@filehandle.expects(:sync)
|
241
|
+
@filehandle.expects(:sync=).with(true)
|
238
242
|
|
239
243
|
@server.setup_logger
|
240
244
|
end
|