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
@@ -16,115 +16,223 @@ describe ssh_authorized_key do
|
|
16
16
|
@catalog = Puppet::Resource::Catalog.new
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should have a name parameter" do
|
20
|
-
@class.attrtype(:name).should == :param
|
21
|
-
end
|
22
|
-
|
23
19
|
it "should have :name be its namevar" do
|
24
20
|
@class.key_attributes.should == [:name]
|
25
21
|
end
|
26
22
|
|
27
|
-
|
28
|
-
@class.attrtype(:provider).should == :param
|
29
|
-
end
|
23
|
+
describe "when validating attributes" do
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
[:name, :provider].each do |param|
|
26
|
+
it "should have a #{param} parameter" do
|
27
|
+
@class.attrtype(param).should == :param
|
28
|
+
end
|
29
|
+
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
[:type, :key, :user, :target, :options, :ensure].each do |property|
|
32
|
+
it "should have a #{property} property" do
|
33
|
+
@class.attrtype(property).should == :property
|
34
|
+
end
|
35
|
+
end
|
38
36
|
|
39
|
-
it "should support :absent as a value for :ensure" do
|
40
|
-
proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
|
41
37
|
end
|
42
38
|
|
43
|
-
|
44
|
-
@class.attrtype(:type).should == :property
|
45
|
-
end
|
46
|
-
it "should support ssh-dss as an type value" do
|
47
|
-
proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
|
48
|
-
end
|
49
|
-
it "should support ssh-rsa as an type value" do
|
50
|
-
proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
|
51
|
-
end
|
52
|
-
it "should support :dsa as an type value" do
|
53
|
-
proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
|
54
|
-
end
|
55
|
-
it "should support :rsa as an type value" do
|
56
|
-
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
|
57
|
-
end
|
39
|
+
describe "when validating values" do
|
58
40
|
|
59
|
-
|
60
|
-
proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error)
|
61
|
-
end
|
41
|
+
describe "for name" do
|
62
42
|
|
63
|
-
|
64
|
-
|
65
|
-
|
43
|
+
it "should support valid names" do
|
44
|
+
proc { @class.new(:name => "username", :ensure => :present, :user => "nobody") }.should_not raise_error
|
45
|
+
proc { @class.new(:name => "username@hostname", :ensure => :present, :user => "nobody") }.should_not raise_error
|
46
|
+
end
|
66
47
|
|
67
|
-
|
68
|
-
|
69
|
-
|
48
|
+
it "should not support whitespaces" do
|
49
|
+
proc { @class.new(:name => "my test", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/)
|
50
|
+
proc { @class.new(:name => "my\ttest", :ensure => :present, :user => "nobody") }.should raise_error(Puppet::Error,/Resourcename must not contain whitespace/)
|
51
|
+
end
|
70
52
|
|
71
|
-
|
72
|
-
@class.attrtype(:options).should == :property
|
73
|
-
end
|
53
|
+
end
|
74
54
|
|
75
|
-
|
76
|
-
resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
|
55
|
+
describe "for ensure" do
|
77
56
|
|
78
|
-
|
79
|
-
|
57
|
+
it "should support :present" do
|
58
|
+
proc { @class.new(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
|
59
|
+
end
|
80
60
|
|
81
|
-
|
82
|
-
|
61
|
+
it "should support :absent" do
|
62
|
+
proc { @class.new(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
|
63
|
+
end
|
83
64
|
|
84
|
-
|
85
|
-
|
65
|
+
it "should not support other values" do
|
66
|
+
proc { @class.new(:name => "whev", :ensure => :foo, :user => "nobody") }.should raise_error(Puppet::Error, /Invalid value/)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "for type" do
|
72
|
+
|
73
|
+
|
74
|
+
it "should support ssh-dss" do
|
75
|
+
proc { @class.new(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should support ssh-rsa" do
|
79
|
+
proc { @class.new(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should support :dsa" do
|
83
|
+
proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should support :rsa" do
|
87
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should alias :rsa to :ssh-rsa" do
|
91
|
+
key = @class.new(:name => "whev", :type => :rsa, :user => "nobody")
|
92
|
+
key.should(:type).should == :'ssh-rsa'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should alias :dsa to :ssh-dss" do
|
96
|
+
key = @class.new(:name => "whev", :type => :dsa, :user => "nobody")
|
97
|
+
key.should(:type).should == :'ssh-dss'
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa" do
|
101
|
+
proc { @class.new(:name => "whev", :type => :something) }.should raise_error(Puppet::Error,/Invalid value/)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "for key" do
|
107
|
+
|
108
|
+
it "should support a valid key like a 1024 bit rsa key" do
|
109
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCPfzW2ry7XvMc6E5Kj2e5fF/YofhKEvsNMUogR3PGL/HCIcBlsEjKisrY0aYgD8Ikp7ZidpXLbz5dBsmPy8hJiBWs5px9ZQrB/EOQAwXljvj69EyhEoGawmxQMtYw+OAIKHLJYRuk1QiHAMHLp5piqem8ZCV2mLb9AsJ6f7zUVw==')}.should_not raise_error
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should support a valid key like a 4096 bit rsa key" do
|
113
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAAAB3NzaC1yc2EAAAADAQABAAACAQDEY4pZFyzSfRc9wVWI3DfkgT/EL033UZm/7x1M+d+lBD00qcpkZ6CPT7lD3Z+vylQlJ5S8Wcw6C5Smt6okZWY2WXA9RCjNJMIHQbJAzwuQwgnwU/1VMy9YPp0tNVslg0sUUgpXb13WW4mYhwxyGmIVLJnUrjrQmIFhtfHsJAH8ZVqCWaxKgzUoC/YIu1u1ScH93lEdoBPLlwm6J0aiM7KWXRb7Oq1nEDZtug1zpX5lhgkQWrs0BwceqpUbY+n9sqeHU5e7DCyX/yEIzoPRW2fe2Gx1Iq6JKM/5NNlFfaW8rGxh3Z3S1NpzPHTRjw8js3IeGiV+OPFoaTtM1LsWgPDSBlzIdyTbSQR7gKh0qWYCNV/7qILEfa0yIFB5wIo4667iSPZw2pNgESVtenm8uXyoJdk8iWQ4mecdoposV/znknNb2GPgH+n/2vme4btZ0Sl1A6rev22GQjVgbWOn8zaDglJ2vgCN1UAwmq41RXprPxENGeLnWQppTnibhsngu0VFllZR5kvSIMlekLRSOFLFt92vfd+tk9hZIiKm9exxcbVCGGQPsf6dZ27rTOmg0xM2Sm4J6RRKuz79HQgA4Eg18+bqRP7j/itb89DmtXEtoZFAsEJw8IgIfeGGDtHTkfAlAC92mtK8byeaxGq57XCTKbO/r5gcOMElZHy1AcB8kw==')}.should_not raise_error
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should support a valid key like a 1024 bit dsa key" do
|
117
|
+
proc { @class.new(:name => "whev", :type => :dsa, :user => "nobody", :key => 'AAAAB3NzaC1kc3MAAACBAI80iR78QCgpO4WabVqHHdEDigOjUEHwIjYHIubR/7u7DYrXY+e+TUmZ0CVGkiwB/0yLHK5dix3Y/bpj8ZiWCIhFeunnXccOdE4rq5sT2V3l1p6WP33RpyVYbLmeuHHl5VQ1CecMlca24nHhKpfh6TO/FIwkMjghHBfJIhXK+0w/AAAAFQDYzLupuMY5uz+GVrcP+Kgd8YqMmwAAAIB3SVN71whLWjFPNTqGyyIlMy50624UfNOaH4REwO+Of3wm/cE6eP8n75vzTwQGBpJX3BPaBGW1S1Zp/DpTOxhCSAwZzAwyf4WgW7YyAOdxN3EwTDJZeyiyjWMAOjW9/AOWt9gtKg0kqaylbMHD4kfiIhBzo31ZY81twUzAfN7angAAAIBfva8sTSDUGKsWWIXkdbVdvM4X14K4gFdy0ZJVzaVOtZ6alysW6UQypnsl6jfnbKvsZ0tFgvcX/CPyqNY/gMR9lyh/TCZ4XQcbqeqYPuceGehz+jL5vArfqsW2fJYFzgCcklmr/VxtP5h6J/T0c9YcDgc/xIfWdZAlznOnphI/FA==')}.should_not raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should not support whitespaces" do
|
121
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :key => 'AAA FA==')}.should raise_error(Puppet::Error,/Key must not contain whitespace/)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "for options" do
|
127
|
+
|
128
|
+
it "should support flags as options" do
|
129
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority')}.should_not raise_error
|
130
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'no-port-forwarding')}.should_not raise_error
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should support key-value pairs as options" do
|
134
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'command="command"')}.should_not raise_error
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should support environments as options" do
|
138
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'environment="NAME=value"')}.should_not raise_error
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should support multiple options as an array" do
|
142
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ['cert-authority','environment="NAME=value"'])}.should_not raise_error
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should not support a comma separated lists" do
|
146
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority,no-port-forwarding')}.should raise_error(Puppet::Error, /must be provided as an array/)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should use :absent as a default value" do
|
150
|
+
@class.new(:name => "whev", :type => :rsa, :user => "nobody").should(:options).should == [:absent]
|
151
|
+
end
|
152
|
+
|
153
|
+
it "property should return well formed string of arrays from is_to_s" do
|
154
|
+
resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
|
155
|
+
resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c"
|
156
|
+
end
|
157
|
+
|
158
|
+
it "property should return well formed string of arrays from is_to_s" do
|
159
|
+
resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
|
160
|
+
resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c"
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "for user" do
|
166
|
+
|
167
|
+
it "should support present users" do
|
168
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "root") }.should_not raise_error
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should support absent users" do
|
172
|
+
proc { @class.new(:name => "whev", :type => :rsa, :user => "ihopeimabsent") }.should_not raise_error
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "for target" do
|
178
|
+
|
179
|
+
it "should support absolute paths" do
|
180
|
+
proc { @class.new(:name => "whev", :type => :rsa, :target => "/tmp/here") }.should_not raise_error
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should use the user's path if not explicitly specified" do
|
184
|
+
@class.new(:name => "whev", :user => 'root').should(:target).should == File.expand_path("~root/.ssh/authorized_keys")
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should not consider the user's path if explicitly specified" do
|
188
|
+
@class.new(:name => "whev", :user => 'root', :target => '/tmp/here').should(:target).should == '/tmp/here'
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should inform about an absent user" do
|
192
|
+
Puppet::Log.level = :debug
|
193
|
+
@class.new(:name => "whev", :user => 'idontexist').should(:target)
|
194
|
+
@logs.map(&:message).should include("The required user is not yet present on the system")
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
86
198
|
|
87
|
-
it "should have a target property" do
|
88
|
-
@class.attrtype(:target).should == :property
|
89
199
|
end
|
90
200
|
|
91
201
|
describe "when neither user nor target is specified" do
|
202
|
+
|
92
203
|
it "should raise an error" do
|
93
204
|
proc do
|
94
|
-
|
95
|
-
@class.create(
|
96
|
-
|
205
|
+
@class.new(
|
97
206
|
:name => "Test",
|
98
207
|
:key => "AAA",
|
99
208
|
:type => "ssh-rsa",
|
100
|
-
|
101
209
|
:ensure => :present)
|
102
|
-
end.should raise_error(Puppet::Error)
|
210
|
+
end.should raise_error(Puppet::Error,/user.*or.*target.*mandatory/)
|
103
211
|
end
|
212
|
+
|
104
213
|
end
|
105
214
|
|
106
215
|
describe "when both target and user are specified" do
|
107
|
-
it "should use target" do
|
108
|
-
|
109
|
-
resource = @class.create(
|
110
216
|
|
217
|
+
it "should use target" do
|
218
|
+
resource = @class.new(
|
111
219
|
:name => "Test",
|
112
220
|
:user => "root",
|
113
|
-
|
114
|
-
|
221
|
+
:target => "/tmp/blah"
|
222
|
+
)
|
115
223
|
resource.should(:target).should == "/tmp/blah"
|
116
224
|
end
|
225
|
+
|
117
226
|
end
|
118
227
|
|
119
228
|
|
120
229
|
describe "when user is specified" do
|
121
|
-
it "should determine target" do
|
122
230
|
|
231
|
+
it "should determine target" do
|
123
232
|
resource = @class.create(
|
124
|
-
|
125
233
|
:name => "Test",
|
126
|
-
|
127
|
-
|
234
|
+
:user => "root"
|
235
|
+
)
|
128
236
|
target = File.expand_path("~root/.ssh/authorized_keys")
|
129
237
|
resource.should(:target).should == target
|
130
238
|
end
|
@@ -135,17 +243,19 @@ describe ssh_authorized_key do
|
|
135
243
|
target = File.expand_path("~root/.ssh/authorized_keys")
|
136
244
|
resource.property(:target).safe_insync?(target).should == true
|
137
245
|
end
|
246
|
+
|
138
247
|
end
|
139
248
|
|
140
249
|
describe "when calling validate" do
|
141
|
-
it "should not crash on a non-existant user" do
|
142
250
|
|
251
|
+
it "should not crash on a non-existant user" do
|
143
252
|
resource = @class.create(
|
144
|
-
|
145
253
|
:name => "Test",
|
146
|
-
|
147
|
-
|
254
|
+
:user => "ihopesuchuserdoesnotexist"
|
255
|
+
)
|
148
256
|
proc { resource.validate }.should_not raise_error
|
149
257
|
end
|
258
|
+
|
150
259
|
end
|
260
|
+
|
151
261
|
end
|
data/spec/unit/type/user_spec.rb
CHANGED
@@ -289,6 +289,14 @@ describe user do
|
|
289
289
|
@password.change_to_s("other", "mypass").should_not be_include("mypass")
|
290
290
|
end
|
291
291
|
|
292
|
+
it "should redact the password when displaying the old value" do
|
293
|
+
@password.is_to_s("currentpassword").should =~ /^\[old password hash redacted\]$/
|
294
|
+
end
|
295
|
+
|
296
|
+
it "should redact the password when displaying the new value" do
|
297
|
+
@password.should_to_s("newpassword").should =~ /^\[new password hash redacted\]$/
|
298
|
+
end
|
299
|
+
|
292
300
|
it "should fail if a ':' is included in the password" do
|
293
301
|
lambda { @password.should = "some:thing" }.should raise_error(Puppet::Error)
|
294
302
|
end
|
data/spec/unit/type/vlan_spec.rb
CHANGED
data/spec/unit/type_spec.rb
CHANGED
@@ -164,6 +164,72 @@ describe Puppet::Type do
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
describe "when creating a provider" do
|
168
|
+
before :each do
|
169
|
+
@type = Puppet::Type.newtype(:provider_test_type)
|
170
|
+
end
|
171
|
+
|
172
|
+
after :each do
|
173
|
+
@type.provider_hash.clear
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should create a subclass of Puppet::Provider for the provider" do
|
177
|
+
provider = @type.provide(:test_provider)
|
178
|
+
|
179
|
+
provider.ancestors.should include(Puppet::Provider)
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should use a parent class if specified" do
|
183
|
+
parent_provider = @type.provide(:parent_provider)
|
184
|
+
child_provider = @type.provide(:child_provider, :parent => parent_provider)
|
185
|
+
|
186
|
+
child_provider.ancestors.should include(parent_provider)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should use a parent class if specified by name" do
|
190
|
+
parent_provider = @type.provide(:parent_provider)
|
191
|
+
child_provider = @type.provide(:child_provider, :parent => :parent_provider)
|
192
|
+
|
193
|
+
child_provider.ancestors.should include(parent_provider)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should raise an error when the parent class can't be found" do
|
197
|
+
expect {
|
198
|
+
@type.provide(:child_provider, :parent => :parent_provider)
|
199
|
+
}.to raise_error(Puppet::DevError, /Could not find parent provider.+parent_provider/)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should ensure its type has a 'provider' parameter" do
|
203
|
+
@type.provide(:test_provider)
|
204
|
+
|
205
|
+
@type.parameters.should include(:provider)
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should remove a previously registered provider with the same name" do
|
209
|
+
old_provider = @type.provide(:test_provider)
|
210
|
+
new_provider = @type.provide(:test_provider)
|
211
|
+
|
212
|
+
old_provider.should_not equal(new_provider)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should register itself as a provider for the type" do
|
216
|
+
provider = @type.provide(:test_provider)
|
217
|
+
|
218
|
+
provider.should == @type.provider(:test_provider)
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should create a provider when a provider with the same name previously failed" do
|
222
|
+
@type.provide(:test_provider) do
|
223
|
+
raise "failed to create this provider"
|
224
|
+
end rescue nil
|
225
|
+
|
226
|
+
provider = @type.provide(:test_provider)
|
227
|
+
|
228
|
+
provider.ancestors.should include(Puppet::Provider)
|
229
|
+
provider.should == @type.provider(:test_provider)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
167
233
|
describe "when choosing a default provider" do
|
168
234
|
it "should choose the provider with the highest specificity" do
|
169
235
|
# Make a fake type
|
@@ -1,6 +1,5 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../../spec_helper'
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require 'spec_helper'
|
4
3
|
|
5
4
|
require 'puppet/util/network_device/config'
|
6
5
|
|
@@ -99,4 +98,4 @@ describe Puppet::Util::NetworkDevice::Config do
|
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
102
|
-
end
|
101
|
+
end
|