puppet 2.7.1 → 2.7.3
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 +225 -1
- data/CONTRIBUTING.md +299 -0
- data/README.md +0 -1
- data/conf/redhat/puppet.spec +132 -25
- data/conf/solaris/pkginfo +1 -1
- data/conf/suse/puppet.spec +5 -2
- data/ext/envpuppet +56 -3
- data/ext/vim/README +2 -1
- data/ext/vim/ftplugin/puppet.vim +94 -0
- data/ext/vim/indent/puppet.vim +76 -0
- data/lib/puppet.rb +2 -3
- data/lib/puppet/application/agent.rb +7 -7
- data/lib/puppet/application/apply.rb +20 -8
- data/lib/puppet/application/ca.rb +5 -0
- data/lib/puppet/application/cert.rb +2 -1
- data/lib/puppet/application/certificate.rb +0 -5
- data/lib/puppet/application/device.rb +4 -4
- data/lib/puppet/application/doc.rb +23 -12
- data/lib/puppet/application/face_base.rb +2 -1
- data/lib/puppet/application/inspect.rb +5 -2
- data/lib/puppet/configurer.rb +60 -56
- data/lib/puppet/configurer/fact_handler.rb +6 -1
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/face/ca.rb +233 -0
- data/lib/puppet/face/certificate.rb +15 -11
- data/lib/puppet/face/certificate_request.rb +9 -11
- data/lib/puppet/face/certificate_revocation_list.rb +5 -7
- data/lib/puppet/face/node/clean.rb +154 -0
- data/lib/puppet/face/status.rb +1 -0
- data/lib/puppet/file_serving/configuration/parser.rb +6 -13
- data/lib/puppet/indirector/exec.rb +3 -3
- data/lib/puppet/indirector/face.rb +17 -7
- data/lib/puppet/indirector/report/processor.rb +29 -16
- data/lib/puppet/indirector/rest.rb +42 -7
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/interface.rb +7 -2
- data/lib/puppet/interface/action.rb +57 -23
- data/lib/puppet/interface/action_manager.rb +10 -5
- data/lib/puppet/interface/face_collection.rb +43 -52
- data/lib/puppet/interface/option.rb +19 -0
- data/lib/puppet/interface/option_builder.rb +13 -0
- data/lib/puppet/interface/option_manager.rb +2 -1
- data/lib/puppet/metatype/manager.rb +7 -20
- data/lib/puppet/module.rb +4 -1
- data/lib/puppet/network/authconfig.rb +3 -1
- data/lib/puppet/network/authstore.rb +14 -5
- data/lib/puppet/network/handler/fileserver.rb +3 -0
- data/lib/puppet/network/http/webrick.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +6 -1
- data/lib/puppet/network/rest_authorization.rb +1 -1
- data/lib/puppet/parser/compiler.rb +8 -11
- data/lib/puppet/parser/functions.rb +1 -6
- data/lib/puppet/parser/functions/create_resources.rb +6 -5
- data/lib/puppet/parser/functions/regsubst.rb +26 -0
- data/lib/puppet/parser/functions/shellquote.rb +26 -0
- data/lib/puppet/parser/functions/sprintf.rb +26 -0
- data/lib/puppet/parser/grammar.ra +34 -60
- data/lib/puppet/parser/lexer.rb +5 -5
- data/lib/puppet/parser/parser.rb +913 -1196
- data/lib/puppet/parser/resource.rb +18 -1
- data/lib/puppet/parser/scope.rb +2 -2
- data/lib/puppet/provider/augeas/augeas.rb +42 -17
- data/lib/puppet/provider/mount/parsed.rb +19 -1
- data/lib/puppet/provider/naginator.rb +9 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +11 -8
- data/lib/puppet/provider/network_device.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +1 -0
- data/lib/puppet/provider/package/pacman.rb +94 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -6
- data/lib/puppet/rails/host.rb +7 -0
- data/lib/puppet/reports/store.rb +15 -0
- data/lib/puppet/resource/catalog.rb +15 -6
- data/lib/puppet/ssl/certificate.rb +6 -0
- data/lib/puppet/ssl/inventory.rb +2 -0
- data/lib/puppet/transaction.rb +9 -17
- data/lib/puppet/transaction/report.rb +3 -3
- data/lib/puppet/type.rb +13 -24
- data/lib/puppet/type/file.rb +8 -2
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/service.rb +20 -24
- data/lib/puppet/type/ssh_authorized_key.rb +12 -0
- data/lib/puppet/type/user.rb +8 -0
- data/lib/puppet/util.rb +0 -1
- data/lib/puppet/util/network_device.rb +3 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/settings/file_setting.rb +1 -0
- data/lib/semver.rb +65 -0
- data/spec/integration/defaults_spec.rb +23 -1
- data/spec/integration/network/rest_authconfig_spec.rb +145 -0
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/parser/functions_spec.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +31 -0
- data/spec/integration/provider/ssh_authorized_key_spec.rb +207 -0
- data/spec/integration/type_spec.rb +11 -0
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +8 -0
- data/spec/lib/puppet/face/huzzah.rb +1 -0
- data/spec/lib/puppet/face/huzzah/obsolete.rb +6 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +115 -3
- data/spec/unit/application/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +74 -56
- data/spec/unit/application/cert_spec.rb +10 -0
- data/spec/unit/application/device_spec.rb +2 -3
- data/spec/unit/application/face_base_spec.rb +1 -0
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +5 -0
- data/spec/unit/configurer/fact_handler_spec.rb +45 -37
- data/spec/unit/configurer_spec.rb +405 -327
- data/spec/unit/face/ca_spec.rb +355 -0
- data/spec/unit/face/certificate_spec.rb +16 -4
- data/spec/unit/face/node_spec.rb +261 -1
- data/spec/unit/file_serving/configuration/parser_spec.rb +8 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +1 -0
- data/spec/unit/indirector/certificate_status/file_spec.rb +4 -0
- data/spec/unit/indirector/exec_spec.rb +4 -4
- data/spec/unit/indirector/face_spec.rb +3 -1
- data/spec/unit/indirector/facts/couch_spec.rb +2 -2
- data/spec/unit/indirector/facts/network_device_spec.rb +2 -6
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/report/processor_spec.rb +31 -8
- data/spec/unit/indirector/rest_spec.rb +53 -5
- data/spec/unit/indirector/yaml_spec.rb +18 -0
- data/spec/unit/interface/action_spec.rb +112 -8
- data/spec/unit/interface/face_collection_spec.rb +46 -36
- data/spec/unit/interface/option_spec.rb +44 -0
- data/spec/unit/interface_spec.rb +11 -6
- data/spec/unit/module_spec.rb +38 -9
- data/spec/unit/network/authconfig_spec.rb +23 -0
- data/spec/unit/network/authstore_spec.rb +36 -4
- data/spec/unit/network/handler/fileserver_spec.rb +32 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/node_spec.rb +1 -0
- data/spec/unit/parser/compiler_spec.rb +8 -46
- data/spec/unit/parser/lexer_spec.rb +27 -17
- data/spec/unit/parser/resource_spec.rb +61 -3
- data/spec/unit/parser/scope_spec.rb +5 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +106 -1
- data/spec/unit/provider/cisco_spec.rb +3 -4
- data/spec/unit/provider/interface/cisco_spec.rb +1 -2
- data/spec/unit/provider/mount/parsed_spec.rb +41 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +60 -0
- data/spec/unit/provider/network_device_spec.rb +1 -2
- data/spec/unit/provider/package/pacman_spec.rb +237 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +2 -3
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +21 -32
- data/spec/unit/provider/vlan/cisco_spec.rb +1 -2
- data/spec/unit/rails/host_spec.rb +8 -0
- data/spec/unit/resource/catalog_spec.rb +55 -8
- data/spec/unit/semver_spec.rb +187 -0
- data/spec/unit/ssl/certificate_spec.rb +25 -0
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +8 -2
- data/spec/unit/type/file_spec.rb +57 -0
- data/spec/unit/type/interface_spec.rb +1 -2
- data/spec/unit/type/schedule_spec.rb +73 -42
- data/spec/unit/type/ssh_authorized_key_spec.rb +180 -70
- data/spec/unit/type/user_spec.rb +8 -0
- data/spec/unit/type/vlan_spec.rb +1 -2
- data/spec/unit/type_spec.rb +66 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -2
- data/spec/unit/util/network_device/cisco/facts_spec.rb +2 -3
- data/spec/unit/util/network_device/cisco/interface_spec.rb +1 -2
- data/spec/unit/util/network_device/config_spec.rb +3 -4
- data/spec/unit/util/network_device/ipcalc_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/base_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/telnet_spec.rb +1 -2
- data/spec/unit/util/network_device_spec.rb +2 -2
- data/spec/unit/util/settings/file_setting_spec.rb +4 -0
- data/spec/unit/util/settings_spec.rb +11 -0
- data/test/lib/puppettest/railstesting.rb +0 -34
- metadata +19 -4
@@ -25,39 +25,9 @@ describe Puppet::Interface::FaceCollection do
|
|
25
25
|
@original_required.each {|f| $".push f unless $".include? f }
|
26
26
|
end
|
27
27
|
|
28
|
-
describe "::prefix_match?" do
|
29
|
-
# want have
|
30
|
-
{ ['1.0.0', '1.0.0'] => true,
|
31
|
-
['1.0', '1.0.0'] => true,
|
32
|
-
['1', '1.0.0'] => true,
|
33
|
-
['1.0.0', '1.1.0'] => false,
|
34
|
-
['1.0', '1.1.0'] => false,
|
35
|
-
['1', '1.1.0'] => true,
|
36
|
-
['1.0.1', '1.0.0'] => false,
|
37
|
-
}.each do |data, result|
|
38
|
-
it "should return #{result.inspect} for prefix_match?(#{data.join(', ')})" do
|
39
|
-
subject.prefix_match?(*data).should == result
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "::validate_version" do
|
45
|
-
{ '10.10.10' => true,
|
46
|
-
'1.2.3.4' => false,
|
47
|
-
'10.10.10beta' => true,
|
48
|
-
'10.10' => false,
|
49
|
-
'123' => false,
|
50
|
-
'v1.1.1' => false,
|
51
|
-
}.each do |input, result|
|
52
|
-
it "should#{result ? '' : ' not'} permit #{input.inspect}" do
|
53
|
-
subject.validate_version(input).should(result ? be_true : be_false)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
28
|
describe "::[]" do
|
59
29
|
before :each do
|
60
|
-
subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
|
30
|
+
subject.instance_variable_get("@faces")[:foo][SemVer.new('0.0.1')] = 10
|
61
31
|
end
|
62
32
|
|
63
33
|
it "should return the face with the given name" do
|
@@ -65,7 +35,8 @@ describe Puppet::Interface::FaceCollection do
|
|
65
35
|
end
|
66
36
|
|
67
37
|
it "should attempt to load the face if it isn't found" do
|
68
|
-
subject.expects(:require).with('puppet/face/bar')
|
38
|
+
subject.expects(:require).once.with('puppet/face/bar')
|
39
|
+
subject.expects(:require).once.with('puppet/face/0.0.1/bar')
|
69
40
|
subject["bar", '0.0.1']
|
70
41
|
end
|
71
42
|
|
@@ -75,13 +46,13 @@ describe Puppet::Interface::FaceCollection do
|
|
75
46
|
end
|
76
47
|
|
77
48
|
it "should return true if the face specified is registered" do
|
78
|
-
subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10
|
49
|
+
subject.instance_variable_get("@faces")[:foo][SemVer.new('0.0.1')] = 10
|
79
50
|
subject["foo", '0.0.1'].should == 10
|
80
51
|
end
|
81
52
|
|
82
53
|
it "should attempt to require the face if it is not registered" do
|
83
54
|
subject.expects(:require).with do |file|
|
84
|
-
subject.instance_variable_get("@faces")[:bar]['0.0.1'] = true
|
55
|
+
subject.instance_variable_get("@faces")[:bar][SemVer.new('0.0.1')] = true
|
85
56
|
file == 'puppet/face/bar'
|
86
57
|
end
|
87
58
|
subject["bar", '0.0.1'].should be_true
|
@@ -94,7 +65,8 @@ describe Puppet::Interface::FaceCollection do
|
|
94
65
|
|
95
66
|
it "should return false if the face file itself is missing" do
|
96
67
|
subject.stubs(:require).
|
97
|
-
raises(LoadError, 'no such file to load -- puppet/face/bar')
|
68
|
+
raises(LoadError, 'no such file to load -- puppet/face/bar').then.
|
69
|
+
raises(LoadError, 'no such file to load -- puppet/face/0.0.1/bar')
|
98
70
|
subject["bar", '0.0.1'].should be_false
|
99
71
|
end
|
100
72
|
|
@@ -127,11 +99,49 @@ describe Puppet::Interface::FaceCollection do
|
|
127
99
|
end
|
128
100
|
end
|
129
101
|
|
102
|
+
describe "::get_action_for_face" do
|
103
|
+
it "should return an action on the current face" do
|
104
|
+
Puppet::Face::FaceCollection.get_action_for_face(:huzzah, :bar, :current).
|
105
|
+
should be_an_instance_of Puppet::Interface::Action
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return an action on an older version of a face" do
|
109
|
+
action = Puppet::Face::FaceCollection.
|
110
|
+
get_action_for_face(:huzzah, :obsolete, :current)
|
111
|
+
|
112
|
+
action.should be_an_instance_of Puppet::Interface::Action
|
113
|
+
action.face.version.should == SemVer.new('1.0.0')
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should load the full older version of a face" do
|
117
|
+
action = Puppet::Face::FaceCollection.
|
118
|
+
get_action_for_face(:huzzah, :obsolete, :current)
|
119
|
+
|
120
|
+
action.face.version.should == SemVer.new('1.0.0')
|
121
|
+
action.face.should be_action :obsolete_in_core
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not add obsolete actions to the current version" do
|
125
|
+
action = Puppet::Face::FaceCollection.
|
126
|
+
get_action_for_face(:huzzah, :obsolete, :current)
|
127
|
+
|
128
|
+
action.face.version.should == SemVer.new('1.0.0')
|
129
|
+
action.face.should be_action :obsolete_in_core
|
130
|
+
|
131
|
+
current = Puppet::Face[:huzzah, :current]
|
132
|
+
current.version.should == SemVer.new('2.0.1')
|
133
|
+
current.should_not be_action :obsolete_in_core
|
134
|
+
current.should_not be_action :obsolete
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
130
138
|
describe "::register" do
|
131
139
|
it "should store the face by name" do
|
132
140
|
face = Puppet::Face.new(:my_face, '0.0.1')
|
133
141
|
subject.register(face)
|
134
|
-
subject.instance_variable_get("@faces").should == {
|
142
|
+
subject.instance_variable_get("@faces").should == {
|
143
|
+
:my_face => { face.version => face }
|
144
|
+
}
|
135
145
|
end
|
136
146
|
end
|
137
147
|
|
@@ -97,4 +97,48 @@ describe Puppet::Interface::Option do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
context "defaults" do
|
102
|
+
subject { Puppet::Interface::Option.new(face, "--foo") }
|
103
|
+
|
104
|
+
it "should work sanely if member variables are used for state" do
|
105
|
+
subject.default = proc { @foo ||= 0; @foo += 1 }
|
106
|
+
subject.default.should == 1
|
107
|
+
subject.default.should == 2
|
108
|
+
subject.default.should == 3
|
109
|
+
end
|
110
|
+
|
111
|
+
context "with no default" do
|
112
|
+
it { should_not be_has_default }
|
113
|
+
its :default do should be_nil end
|
114
|
+
|
115
|
+
it "should set a proc as default" do
|
116
|
+
expect { subject.default = proc { 12 } }.should_not raise_error
|
117
|
+
end
|
118
|
+
|
119
|
+
[1, {}, [], Object.new, "foo"].each do |input|
|
120
|
+
it "should reject anything but a proc (#{input.class})" do
|
121
|
+
expect { subject.default = input }.to raise_error ArgumentError, /not a proc/
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "with a default" do
|
127
|
+
before :each do subject.default = proc { [:foo] } end
|
128
|
+
|
129
|
+
it { should be_has_default }
|
130
|
+
its :default do should == [:foo] end
|
131
|
+
|
132
|
+
it "should invoke the block every time" do
|
133
|
+
subject.default.object_id.should_not == subject.default.object_id
|
134
|
+
subject.default.should == subject.default
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should allow replacing the default proc" do
|
138
|
+
subject.default.should == [:foo]
|
139
|
+
subject.default = proc { :bar }
|
140
|
+
subject.default.should == :bar
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
100
144
|
end
|
data/spec/unit/interface_spec.rb
CHANGED
@@ -126,14 +126,11 @@ describe Puppet::Interface do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should try to require faces that are not known" do
|
129
|
-
|
130
|
-
subject::FaceCollection.expects(:
|
131
|
-
subject[:foo, '0.0.1']
|
129
|
+
subject::FaceCollection.expects(:load_face).with(:foo, :current)
|
130
|
+
subject::FaceCollection.expects(:load_face).with(:foo, '0.0.1')
|
131
|
+
expect { subject[:foo, '0.0.1'] }.to raise_error Puppet::Error
|
132
132
|
end
|
133
133
|
|
134
|
-
it "should be able to load all actions in all search paths"
|
135
|
-
|
136
|
-
|
137
134
|
it_should_behave_like "things that declare options" do
|
138
135
|
def add_options_to(&block)
|
139
136
|
subject.new(:with_options, '0.0.1', &block)
|
@@ -174,6 +171,14 @@ describe Puppet::Interface do
|
|
174
171
|
face.get_action(:foo).options.should =~ [:quux]
|
175
172
|
face.get_action(:bar).options.should =~ [:quux]
|
176
173
|
end
|
174
|
+
|
175
|
+
it "should only list options and not aliases" do
|
176
|
+
face = subject.new(:face_options, '0.0.1') do
|
177
|
+
option "--bar", "-b", "--foo-bar"
|
178
|
+
end
|
179
|
+
face.options.should =~ [:bar]
|
180
|
+
end
|
181
|
+
|
177
182
|
end
|
178
183
|
|
179
184
|
describe "with inherited options" do
|
data/spec/unit/module_spec.rb
CHANGED
@@ -505,12 +505,38 @@ describe Puppet::Module do
|
|
505
505
|
mod.metadata_file.should == mod.metadata_file
|
506
506
|
end
|
507
507
|
|
508
|
-
it "should
|
508
|
+
it "should have metadata if it has a metadata file and its data is not empty" do
|
509
509
|
FileTest.expects(:exist?).with(@module.metadata_file).returns true
|
510
|
+
File.stubs(:read).with(@module.metadata_file).returns "{\"foo\" : \"bar\"}"
|
510
511
|
|
511
512
|
@module.should be_has_metadata
|
512
513
|
end
|
513
514
|
|
515
|
+
it "should have metadata if it has a metadata file and its data is not empty" do
|
516
|
+
FileTest.expects(:exist?).with(@module.metadata_file).returns true
|
517
|
+
File.stubs(:read).with(@module.metadata_file).returns "{\"foo\" : \"bar\"}"
|
518
|
+
|
519
|
+
@module.should be_has_metadata
|
520
|
+
end
|
521
|
+
|
522
|
+
it "should not have metadata if has a metadata file and its data is empty" do
|
523
|
+
FileTest.expects(:exist?).with(@module.metadata_file).returns true
|
524
|
+
File.stubs(:read).with(@module.metadata_file).returns "/*
|
525
|
+
+-----------------------------------------------------------------------+
|
526
|
+
| |
|
527
|
+
| ==> DO NOT EDIT THIS FILE! <== |
|
528
|
+
| |
|
529
|
+
| You should edit the `Modulefile` and run `puppet-module build` |
|
530
|
+
| to generate the `metadata.json` file for your releases. |
|
531
|
+
| |
|
532
|
+
+-----------------------------------------------------------------------+
|
533
|
+
*/
|
534
|
+
|
535
|
+
{}"
|
536
|
+
|
537
|
+
@module.should_not be_has_metadata
|
538
|
+
end
|
539
|
+
|
514
540
|
it "should know if it is missing a metadata file" do
|
515
541
|
FileTest.expects(:exist?).with(@module.metadata_file).returns false
|
516
542
|
|
@@ -528,16 +554,16 @@ describe Puppet::Module do
|
|
528
554
|
Puppet::Module.new("yay")
|
529
555
|
end
|
530
556
|
|
531
|
-
describe "when loading the medatada file", :if => Puppet.features.
|
557
|
+
describe "when loading the medatada file", :if => Puppet.features.pson? do
|
532
558
|
before do
|
533
559
|
@data = {
|
534
|
-
:license
|
535
|
-
:author
|
536
|
-
:version
|
537
|
-
:source
|
560
|
+
:license => "GPL2",
|
561
|
+
:author => "luke",
|
562
|
+
:version => "1.0",
|
563
|
+
:source => "http://foo/",
|
538
564
|
:puppetversion => "0.25"
|
539
565
|
}
|
540
|
-
@text = @data.
|
566
|
+
@text = @data.to_pson
|
541
567
|
|
542
568
|
@module = Puppet::Module.new("foo")
|
543
569
|
@module.stubs(:metadata_file).returns "/my/file"
|
@@ -552,9 +578,12 @@ describe Puppet::Module do
|
|
552
578
|
|
553
579
|
it "should fail if #{attr} is not present in the metadata file" do
|
554
580
|
@data.delete(attr.to_sym)
|
555
|
-
@text = @data.
|
581
|
+
@text = @data.to_pson
|
556
582
|
File.stubs(:read).with("/my/file").returns @text
|
557
|
-
lambda { @module.load_metadata }.should raise_error(
|
583
|
+
lambda { @module.load_metadata }.should raise_error(
|
584
|
+
Puppet::Module::MissingMetadata,
|
585
|
+
"No #{attr} module metadata provided for foo"
|
586
|
+
)
|
558
587
|
end
|
559
588
|
end
|
560
589
|
|
@@ -184,6 +184,29 @@ describe Puppet::Network::AuthConfig do
|
|
184
184
|
@authconfig.read
|
185
185
|
end
|
186
186
|
|
187
|
+
it "should strip whitespace around ACE" do
|
188
|
+
acl = stub 'acl', :info
|
189
|
+
|
190
|
+
@fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0 ')
|
191
|
+
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
192
|
+
|
193
|
+
acl.expects(:allow).with('127.0.0.1')
|
194
|
+
acl.expects(:allow).with('172.16.10.0')
|
195
|
+
|
196
|
+
@authconfig.read
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should allow ACE inline comments" do
|
200
|
+
acl = stub 'acl', :info
|
201
|
+
|
202
|
+
@fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
|
203
|
+
@rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
|
204
|
+
|
205
|
+
acl.expects(:allow).with('127.0.0.1')
|
206
|
+
|
207
|
+
@authconfig.read
|
208
|
+
end
|
209
|
+
|
187
210
|
it "should create an allow ACE on each subsequent allow" do
|
188
211
|
acl = stub 'acl', :info
|
189
212
|
|
@@ -4,11 +4,12 @@ require 'spec_helper'
|
|
4
4
|
require 'puppet/network/authconfig'
|
5
5
|
|
6
6
|
describe Puppet::Network::AuthStore do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
before :each do
|
8
|
+
@authstore = Puppet::Network::AuthStore.new
|
9
|
+
@authstore.reset_interpolation
|
10
|
+
end
|
11
11
|
|
12
|
+
describe "when checking if the acl has some entries" do
|
12
13
|
it "should be empty if no ACE have been entered" do
|
13
14
|
@authstore.should be_empty
|
14
15
|
end
|
@@ -31,6 +32,37 @@ describe Puppet::Network::AuthStore do
|
|
31
32
|
@authstore.should_not be_empty
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
describe "when checking global allow" do
|
37
|
+
it "should not be enabled by default" do
|
38
|
+
@authstore.should_not be_globalallow
|
39
|
+
@authstore.should_not be_allowed('foo.bar.com', '192.168.1.1')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should always allow when enabled" do
|
43
|
+
@authstore.allow('*')
|
44
|
+
|
45
|
+
@authstore.should be_globalallow
|
46
|
+
@authstore.should be_allowed('foo.bar.com', '192.168.1.1')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when checking a regex type of allow" do
|
51
|
+
before :each do
|
52
|
+
@authstore.allow('/^(test-)?host[0-9]+\.other-domain\.(com|org|net)$|some-domain\.com/')
|
53
|
+
@ip = '192.168.1.1'
|
54
|
+
end
|
55
|
+
['host5.other-domain.com', 'test-host12.other-domain.net', 'foo.some-domain.com'].each { |name|
|
56
|
+
it "should allow the host #{name}" do
|
57
|
+
@authstore.should be_allowed(name, @ip)
|
58
|
+
end
|
59
|
+
}
|
60
|
+
['host0.some-other-domain.com',''].each { |name|
|
61
|
+
it "should not allow the host #{name}" do
|
62
|
+
@authstore.should_not be_allowed(name, @ip)
|
63
|
+
end
|
64
|
+
}
|
65
|
+
end
|
34
66
|
end
|
35
67
|
|
36
68
|
describe Puppet::Network::AuthStore::Declaration do
|
@@ -25,6 +25,38 @@ describe Puppet::Network::Handler::FileServer do
|
|
25
25
|
@mount = Puppet::Network::Handler::FileServer::Mount.new("some_path", @basedir)
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "when parsing the fileserver.conf" do
|
29
|
+
it "should create a valid mount when a valid conf is read" do
|
30
|
+
config_file = tmpfile('fileserver.conf')
|
31
|
+
mountdir = tmpdir('mountdir')
|
32
|
+
|
33
|
+
conf_text = <<-HEREDOC
|
34
|
+
[mymount]
|
35
|
+
path #{mountdir}
|
36
|
+
allow anyone.com
|
37
|
+
deny nobody.com
|
38
|
+
HEREDOC
|
39
|
+
File.open(config_file, 'w') { |f| f.write conf_text }
|
40
|
+
|
41
|
+
fs = Puppet::Network::Handler::FileServer.new(:Config => config_file)
|
42
|
+
mounts = fs.instance_variable_get(:@mounts)
|
43
|
+
mount = mounts["mymount"]
|
44
|
+
mount.path == mountdir
|
45
|
+
mount.instance_variable_get(:@declarations).map {|d| d.pattern}.should =~ [["com", "nobody"], ["com", "anyone"]]
|
46
|
+
end
|
47
|
+
|
48
|
+
['path', 'allow', 'deny'].each do |arg|
|
49
|
+
it "should error if config file doesn't specify a mount for #{arg} argument" do
|
50
|
+
config_file = tmpfile('fileserver.conf')
|
51
|
+
File.open(config_file, 'w') { |f| f.puts "#{arg} 127.0.0.1/24" }
|
52
|
+
|
53
|
+
expect {
|
54
|
+
Puppet::Network::Handler::FileServer.new(:Config => config_file)
|
55
|
+
}.should raise_error(Puppet::Network::Handler::FileServerError, "No mount specified for argument #{arg} 127.0.0.1/24")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
28
60
|
it "should list a single directory" do
|
29
61
|
@mount.list("/", false, false).should == [["/", "directory"]]
|
30
62
|
end
|
@@ -29,7 +29,7 @@ describe Puppet::Network::RestAuthConfig do
|
|
29
29
|
params = {:ip => "127.0.0.1", :node => "me", :environment => :env, :authenticated => true}
|
30
30
|
@acl.expects(:is_request_forbidden_and_why?).with("path", :save, "to/resource", params).returns(nil)
|
31
31
|
|
32
|
-
@authconfig.
|
32
|
+
@authconfig.check_authorization("path", :save, "to/resource", params)
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "when defining an acl with mk_acl" do
|
data/spec/unit/node_spec.rb
CHANGED
@@ -32,6 +32,14 @@ class CompilerTestResource
|
|
32
32
|
|
33
33
|
def evaluate
|
34
34
|
end
|
35
|
+
|
36
|
+
def file
|
37
|
+
"/fake/file/goes/here"
|
38
|
+
end
|
39
|
+
|
40
|
+
def line
|
41
|
+
"42"
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
describe Puppet::Parser::Compiler do
|
@@ -420,52 +428,6 @@ describe Puppet::Parser::Compiler do
|
|
420
428
|
@compiler.catalog.should be_edge(@scope.resource, resource)
|
421
429
|
end
|
422
430
|
|
423
|
-
it "should add an edge to any specified stage for class resources" do
|
424
|
-
other_stage = resource(:stage, "other")
|
425
|
-
@compiler.add_resource(@scope, other_stage)
|
426
|
-
resource = resource(:class, "foo")
|
427
|
-
resource[:stage] = 'other'
|
428
|
-
|
429
|
-
@compiler.add_resource(@scope, resource)
|
430
|
-
|
431
|
-
@compiler.catalog.edge?(other_stage, resource).should be_true
|
432
|
-
end
|
433
|
-
|
434
|
-
it "should fail if a non-class resource attempts to set a stage" do
|
435
|
-
other_stage = resource(:stage, "other")
|
436
|
-
@compiler.add_resource(@scope, other_stage)
|
437
|
-
resource = resource(:file, "foo")
|
438
|
-
resource[:stage] = 'other'
|
439
|
-
|
440
|
-
lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError)
|
441
|
-
end
|
442
|
-
|
443
|
-
it "should fail if an unknown stage is specified" do
|
444
|
-
resource = resource(:class, "foo")
|
445
|
-
resource[:stage] = 'other'
|
446
|
-
|
447
|
-
lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError)
|
448
|
-
end
|
449
|
-
|
450
|
-
it "should add edges from the class resources to the parent's stage if no stage is specified" do
|
451
|
-
main = @compiler.catalog.resource(:stage, :main)
|
452
|
-
foo_stage = resource(:stage, :foo_stage)
|
453
|
-
@compiler.add_resource(@scope, foo_stage)
|
454
|
-
resource = resource(:class, "foo")
|
455
|
-
@scope.stubs(:resource).returns(:stage => :foo_stage)
|
456
|
-
@compiler.add_resource(@scope, resource)
|
457
|
-
|
458
|
-
@compiler.catalog.should be_edge(foo_stage, resource)
|
459
|
-
end
|
460
|
-
|
461
|
-
it "should add edges from top-level class resources to the main stage if no stage is specified" do
|
462
|
-
main = @compiler.catalog.resource(:stage, :main)
|
463
|
-
resource = resource(:class, "foo")
|
464
|
-
@compiler.add_resource(@scope, resource)
|
465
|
-
|
466
|
-
@compiler.catalog.should be_edge(main, resource)
|
467
|
-
end
|
468
|
-
|
469
431
|
it "should not add non-class resources that don't specify a stage to the 'main' stage" do
|
470
432
|
main = @compiler.catalog.resource(:stage, :main)
|
471
433
|
resource = resource(:file, "foo")
|