chef 11.14.6-x86-mingw32 → 11.16.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/exceptions.rb +4 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +16 -0
- data/lib/chef/platform/query_helpers.rb +5 -1
- data/lib/chef/provider/dsc_script.rb +148 -0
- data/lib/chef/provider/user/dscl.rb +32 -28
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/dsc_script.rb +140 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/util/dsc/configuration_generator.rb +115 -0
- data/lib/chef/util/dsc/lcm_output_parser.rb +133 -0
- data/lib/chef/util/dsc/local_configuration_manager.rb +137 -0
- data/lib/chef/util/dsc/resource_info.rb +26 -0
- data/lib/chef/util/path_helper.rb +2 -2
- data/lib/chef/util/powershell/cmdlet.rb +136 -0
- data/lib/chef/util/powershell/cmdlet_result.rb +46 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +337 -0
- data/spec/functional/resource/group_spec.rb +5 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +114 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/platform_helpers.rb +24 -0
- data/spec/unit/platform/query_helpers_spec.rb +23 -0
- data/spec/unit/provider/dsc_script_spec.rb +145 -0
- data/spec/unit/provider/user/dscl_spec.rb +2 -1
- data/spec/unit/resource/dsc_script_spec.rb +127 -0
- data/spec/unit/util/dsc/configuration_generator_spec.rb +171 -0
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +169 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +134 -0
- data/spec/unit/util/powershell/cmdlet_spec.rb +106 -0
- metadata +20 -4
@@ -0,0 +1,169 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/util/dsc/lcm_output_parser'
|
20
|
+
|
21
|
+
describe Chef::Util::DSC::LocalConfigurationManager::Parser do
|
22
|
+
context 'empty input parameter' do
|
23
|
+
it 'returns an empty array for a 0 length string' do
|
24
|
+
Chef::Util::DSC::LocalConfigurationManager::Parser::parse('').should be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns an empty array for a nil input' do
|
28
|
+
Chef::Util::DSC::LocalConfigurationManager::Parser::parse('').should be_empty
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'correctly formatted output from lcm' do
|
33
|
+
it 'returns an empty array for a log with no resources' do
|
34
|
+
str = <<EOF
|
35
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
36
|
+
logtype: [machinename]: LCM: [ End Set ]
|
37
|
+
EOF
|
38
|
+
Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str).should be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns a single resource when only 1 logged with the correct name' do
|
42
|
+
str = <<EOF
|
43
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
44
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
45
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
46
|
+
logtype: [machinename]: LCM: [ End Set ]
|
47
|
+
EOF
|
48
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
49
|
+
resources.length.should eq(1)
|
50
|
+
resources[0].name.should eq('[name]')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'identifies when a resource changes the state of the system' do
|
54
|
+
str = <<EOF
|
55
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
56
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
57
|
+
logtype: [machinename]: LCM: [ Start Set ] [name]
|
58
|
+
logtype: [machinename]: LCM: [ End Set ] [name]
|
59
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
60
|
+
logtype: [machinename]: LCM: [ End Set ]
|
61
|
+
EOF
|
62
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
63
|
+
resources[0].changes_state?.should be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'preserves the log provided for how the system changed the state' do
|
67
|
+
str = <<EOF
|
68
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
69
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
70
|
+
logtype: [machinename]: LCM: [ Start Set ] [name]
|
71
|
+
logtype: [machinename]: [message]
|
72
|
+
logtype: [machinename]: LCM: [ End Set ] [name]
|
73
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
74
|
+
logtype: [machinename]: LCM: [ End Set ]
|
75
|
+
EOF
|
76
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
77
|
+
resources[0].change_log.should match_array(["[name]","[message]","[name]"])
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should return false for changes_state?' do
|
81
|
+
str = <<EOF
|
82
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
83
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
84
|
+
logtype: [machinename]: LCM: [ Skip Set ] [name]
|
85
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
86
|
+
logtype: [machinename]: LCM: [ End Set ]
|
87
|
+
EOF
|
88
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
89
|
+
resources[0].changes_state?.should be_false
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return an empty array for change_log if changes_state? is false' do
|
93
|
+
str = <<EOF
|
94
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
95
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
96
|
+
logtype: [machinename]: LCM: [ Skip Set ] [name]
|
97
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
98
|
+
logtype: [machinename]: LCM: [ End Set ]
|
99
|
+
EOF
|
100
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
101
|
+
resources[0].change_log.should be_empty
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'Incorrectly formatted output from LCM' do
|
106
|
+
it 'should allow missing a [End Resource] when its the last one and still find all the resource' do
|
107
|
+
str = <<-EOF
|
108
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
109
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
110
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
111
|
+
logtype: [machinename]: LCM: [ End Test ]
|
112
|
+
logtype: [machinename]: LCM: [ Skip Set ]
|
113
|
+
logtype: [machinename]: LCM: [ End Resource ]
|
114
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name2]
|
115
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
116
|
+
logtype: [machinename]: LCM: [ End Test ]
|
117
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
118
|
+
logtype: [machinename]: LCM: [ End Set ]
|
119
|
+
logtype: [machinename]: LCM: [ End Set ]
|
120
|
+
EOF
|
121
|
+
|
122
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
123
|
+
resources[0].changes_state?.should be_false
|
124
|
+
resources[1].changes_state?.should be_true
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should allow missing a [End Resource] when its the first one and still find all the resource' do
|
128
|
+
str = <<-EOF
|
129
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
130
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
131
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
132
|
+
logtype: [machinename]: LCM: [ End Test ]
|
133
|
+
logtype: [machinename]: LCM: [ Skip Set ]
|
134
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name2]
|
135
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
136
|
+
logtype: [machinename]: LCM: [ End Test ]
|
137
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
138
|
+
logtype: [machinename]: LCM: [ End Set ]
|
139
|
+
logtype: [machinename]: LCM: [ End Resource ]
|
140
|
+
logtype: [machinename]: LCM: [ End Set ]
|
141
|
+
EOF
|
142
|
+
|
143
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
144
|
+
resources[0].changes_state?.should be_false
|
145
|
+
resources[1].changes_state?.should be_true
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should allow missing set and end resource and assume an unconverged resource in this case' do
|
149
|
+
str = <<-EOF
|
150
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
151
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
152
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
153
|
+
logtype: [machinename]: LCM: [ End Test ]
|
154
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name2]
|
155
|
+
logtype: [machinename]: LCM: [ Start Test ]
|
156
|
+
logtype: [machinename]: LCM: [ End Test ]
|
157
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
158
|
+
logtype: [machinename]: LCM: [ End Set ]
|
159
|
+
logtype: [machinename]: LCM: [ End Resource ]
|
160
|
+
logtype: [machinename]: LCM: [ End Set ]
|
161
|
+
EOF
|
162
|
+
resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
|
163
|
+
resources[0].changes_state?.should be_true
|
164
|
+
resources[0].name.should eql('[name]')
|
165
|
+
resources[1].changes_state?.should be_true
|
166
|
+
resources[1].name.should eql('[name2]')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Edwards <adamed@getchef.com>
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef'
|
20
|
+
require 'chef/util/dsc/local_configuration_manager'
|
21
|
+
|
22
|
+
describe Chef::Util::DSC::LocalConfigurationManager do
|
23
|
+
|
24
|
+
let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, 'tmp') }
|
25
|
+
|
26
|
+
let(:normal_lcm_output) { <<-EOH
|
27
|
+
logtype: [machinename]: LCM: [ Start Set ]
|
28
|
+
logtype: [machinename]: LCM: [ Start Resource ] [name]
|
29
|
+
logtype: [machinename]: LCM: [ End Resource ] [name]
|
30
|
+
logtype: [machinename]: LCM: [ End Set ]
|
31
|
+
EOH
|
32
|
+
}
|
33
|
+
|
34
|
+
let(:no_whatif_lcm_output) { <<-EOH
|
35
|
+
Start-DscConfiguration : A parameter cannot be found that matches parameter name 'whatif'.
|
36
|
+
At line:1 char:123
|
37
|
+
+ run-somecommand -whatif
|
38
|
+
+ ~~~~~~~~
|
39
|
+
+ CategoryInfo : InvalidArgument: (:) [Start-DscConfiguration], ParameterBindingException
|
40
|
+
+ FullyQualifiedErrorId : NamedParameterNotFound,SomeCompany.SomeAssembly.Commands.RunSomeCommand
|
41
|
+
EOH
|
42
|
+
}
|
43
|
+
|
44
|
+
let(:dsc_resource_import_failure_output) { <<-EOH
|
45
|
+
PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . PowerShell provider MSFT_xWebsite failed to execute Test-TargetResource functionality with error message: Please ensure that WebAdministration module is installed. + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : . The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : .
|
46
|
+
EOH
|
47
|
+
}
|
48
|
+
|
49
|
+
let(:lcm_status) {
|
50
|
+
double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success)
|
51
|
+
}
|
52
|
+
|
53
|
+
describe 'test_configuration method invocation' do
|
54
|
+
context 'when interacting with the LCM using a PowerShell cmdlet' do
|
55
|
+
before(:each) do
|
56
|
+
allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
|
57
|
+
end
|
58
|
+
context 'that returns successfully' do
|
59
|
+
before(:each) do
|
60
|
+
allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status)
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:lcm_standard_output) { normal_lcm_output }
|
64
|
+
let(:lcm_standard_error) { nil }
|
65
|
+
let(:lcm_cmdlet_success) { true }
|
66
|
+
|
67
|
+
it 'should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds' do
|
68
|
+
test_configuration_result = lcm.test_configuration('config')
|
69
|
+
expect(test_configuration_result.class).to be(Array)
|
70
|
+
expect(test_configuration_result.length).to be > 0
|
71
|
+
expect(Chef::Log).not_to receive(:warn)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'that fails due to missing what-if switch in DSC resource cmdlet implementation' do
|
76
|
+
let(:lcm_standard_output) { '' }
|
77
|
+
let(:lcm_standard_error) { no_whatif_lcm_output }
|
78
|
+
let(:lcm_cmdlet_success) { false }
|
79
|
+
|
80
|
+
it 'should should return a (possibly empty) array of ResourceInfo instances' do
|
81
|
+
expect(Chef::Log).to receive(:warn)
|
82
|
+
test_configuration_result = nil
|
83
|
+
expect {test_configuration_result = lcm.test_configuration('config')}.not_to raise_error
|
84
|
+
expect(test_configuration_result.class).to be(Array)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'that fails due to a DSC resource not being imported before StartDSCConfiguration -whatif is executed' do
|
89
|
+
let(:lcm_standard_output) { '' }
|
90
|
+
let(:lcm_standard_error) { dsc_resource_import_failure_output }
|
91
|
+
let(:lcm_cmdlet_success) { false }
|
92
|
+
|
93
|
+
it 'should log a warning if the message is formatted as expected when a resource import failure occurs' do
|
94
|
+
expect(Chef::Log).to receive(:warn)
|
95
|
+
expect(lcm).to receive(:output_has_dsc_module_failure?).and_call_original
|
96
|
+
test_configuration_result = nil
|
97
|
+
expect {test_configuration_result = lcm.test_configuration('config')}.not_to raise_error
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should return a (possibly empty) array of ResourceInfo instances' do
|
101
|
+
expect(Chef::Log).to receive(:warn)
|
102
|
+
test_configuration_result = nil
|
103
|
+
expect {test_configuration_result = lcm.test_configuration('config')}.not_to raise_error
|
104
|
+
expect(test_configuration_result.class).to be(Array)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'that fails due to an PowerShell cmdlet error that cannot be handled' do
|
109
|
+
let(:lcm_standard_output) { 'some output' }
|
110
|
+
let(:lcm_standard_error) { 'Abort, Retry, Fail?' }
|
111
|
+
let(:lcm_cmdlet_success) { false }
|
112
|
+
|
113
|
+
it 'should raise a Chef::Exceptions::PowershellCmdletException' do
|
114
|
+
expect(Chef::Log).not_to receive(:warn)
|
115
|
+
expect(lcm).to receive(:output_has_dsc_module_failure?).and_call_original
|
116
|
+
expect {lcm.test_configuration('config')}.to raise_error(Chef::Exceptions::PowershellCmdletException)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should identify a correctly formatted error message as a resource import failure' do
|
122
|
+
expect(lcm.send(:output_has_dsc_module_failure?, dsc_resource_import_failure_output)).to be(true)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should not identify an incorrectly formatted error message as a resource import failure' do
|
126
|
+
expect(lcm.send(:output_has_dsc_module_failure?, dsc_resource_import_failure_output.gsub('module', 'gibberish'))).to be(false)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should not identify a message without a CimException reference as a resource import failure' do
|
130
|
+
expect(lcm.send(:output_has_dsc_module_failure?, dsc_resource_import_failure_output.gsub('CimException', 'ArgumentException'))).to be(false)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Jay Mundrawala <jdm@getchef.com>
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef'
|
20
|
+
require 'chef/util/powershell/cmdlet'
|
21
|
+
|
22
|
+
describe Chef::Util::Powershell::Cmdlet do
|
23
|
+
before (:all) do
|
24
|
+
@node = Chef::Node.new
|
25
|
+
@cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, 'Some-Commandlet')
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#validate_switch_name!' do
|
29
|
+
it 'should not raise an error if a name contains all upper case letters' do
|
30
|
+
@cmdlet.send(:validate_switch_name!, "HELLO")
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not raise an error if the name contains all lower case letters' do
|
34
|
+
@cmdlet.send(:validate_switch_name!, "hello")
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should not raise an error if no special characters are used except _' do
|
38
|
+
@cmdlet.send(:validate_switch_name!, "hello_world")
|
39
|
+
end
|
40
|
+
|
41
|
+
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
|
42
|
+
it "raises an Argument error if it configuration name contains #{sym}" do
|
43
|
+
expect {
|
44
|
+
@cmdlet.send(:validate_switch_name!, "Hello#{sym}")
|
45
|
+
}.to raise_error(ArgumentError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#escape_parameter_value' do
|
51
|
+
# Is this list really complete?
|
52
|
+
%w{` " # '}.each do |c|
|
53
|
+
it "escapse #{c}" do
|
54
|
+
@cmdlet.send(:escape_parameter_value, "stuff #{c}").should eql("stuff `#{c}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'does not do anything to a string without special characters' do
|
59
|
+
@cmdlet.send(:escape_parameter_value, 'stuff').should eql('stuff')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#escape_string_parameter_value' do
|
64
|
+
it "surrounds a string with ''" do
|
65
|
+
@cmdlet.send(:escape_string_parameter_value, 'stuff').should eql("'stuff'")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#command_switches_string' do
|
70
|
+
it 'raises an ArgumentError if the key is not a symbol' do
|
71
|
+
expect {
|
72
|
+
@cmdlet.send(:command_switches_string, {'foo' => 'bar'})
|
73
|
+
}.to raise_error(ArgumentError)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does not allow invalid switch names' do
|
77
|
+
expect {
|
78
|
+
@cmdlet.send(:command_switches_string, {:foo! => 'bar'})
|
79
|
+
}.to raise_error(ArgumentError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'ignores switches with a false value' do
|
83
|
+
@cmdlet.send(:command_switches_string, {:foo => false}).should eql('')
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should correctly handle a value type of string' do
|
87
|
+
@cmdlet.send(:command_switches_string, {:foo => 'bar'}).should eql("-foo 'bar'")
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should correctly handle a value type of string even when it is 0 length' do
|
91
|
+
@cmdlet.send(:command_switches_string, {:foo => ''}).should eql("-foo ''")
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should not quote integers' do
|
95
|
+
@cmdlet.send(:command_switches_string, {:foo => 1}).should eql("-foo 1")
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should not quote floats' do
|
99
|
+
@cmdlet.send(:command_switches_string, {:foo => 1.0}).should eql("-foo 1.0")
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'has just the switch when the value is true' do
|
103
|
+
@cmdlet.send(:command_switches_string, {:foo => true}).should eql("-foo")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.
|
4
|
+
version: 11.16.0
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-config
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '7.
|
89
|
+
version: '7.4'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '7.
|
96
|
+
version: '7.4'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rest-client
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1077,6 +1077,7 @@ files:
|
|
1077
1077
|
- lib/chef/provider/deploy/revision.rb
|
1078
1078
|
- lib/chef/provider/deploy/timestamped.rb
|
1079
1079
|
- lib/chef/provider/directory.rb
|
1080
|
+
- lib/chef/provider/dsc_script.rb
|
1080
1081
|
- lib/chef/provider/env.rb
|
1081
1082
|
- lib/chef/provider/env/windows.rb
|
1082
1083
|
- lib/chef/provider/erl_call.rb
|
@@ -1193,6 +1194,7 @@ files:
|
|
1193
1194
|
- lib/chef/resource/deploy_revision.rb
|
1194
1195
|
- lib/chef/resource/directory.rb
|
1195
1196
|
- lib/chef/resource/dpkg_package.rb
|
1197
|
+
- lib/chef/resource/dsc_script.rb
|
1196
1198
|
- lib/chef/resource/easy_install_package.rb
|
1197
1199
|
- lib/chef/resource/env.rb
|
1198
1200
|
- lib/chef/resource/erl_call.rb
|
@@ -1273,9 +1275,15 @@ files:
|
|
1273
1275
|
- lib/chef/user.rb
|
1274
1276
|
- lib/chef/util/backup.rb
|
1275
1277
|
- lib/chef/util/diff.rb
|
1278
|
+
- lib/chef/util/dsc/configuration_generator.rb
|
1279
|
+
- lib/chef/util/dsc/lcm_output_parser.rb
|
1280
|
+
- lib/chef/util/dsc/local_configuration_manager.rb
|
1281
|
+
- lib/chef/util/dsc/resource_info.rb
|
1276
1282
|
- lib/chef/util/editor.rb
|
1277
1283
|
- lib/chef/util/file_edit.rb
|
1278
1284
|
- lib/chef/util/path_helper.rb
|
1285
|
+
- lib/chef/util/powershell/cmdlet.rb
|
1286
|
+
- lib/chef/util/powershell/cmdlet_result.rb
|
1279
1287
|
- lib/chef/util/selinux.rb
|
1280
1288
|
- lib/chef/util/threaded_job_queue.rb
|
1281
1289
|
- lib/chef/util/windows.rb
|
@@ -1595,6 +1603,7 @@ files:
|
|
1595
1603
|
- spec/functional/resource/cron_spec.rb
|
1596
1604
|
- spec/functional/resource/deploy_revision_spec.rb
|
1597
1605
|
- spec/functional/resource/directory_spec.rb
|
1606
|
+
- spec/functional/resource/dsc_script_spec.rb
|
1598
1607
|
- spec/functional/resource/env_spec.rb
|
1599
1608
|
- spec/functional/resource/file_spec.rb
|
1600
1609
|
- spec/functional/resource/git_spec.rb
|
@@ -1616,6 +1625,7 @@ files:
|
|
1616
1625
|
- spec/functional/run_lock_spec.rb
|
1617
1626
|
- spec/functional/shell_spec.rb
|
1618
1627
|
- spec/functional/tiny_server_spec.rb
|
1628
|
+
- spec/functional/util/powershell/cmdlet_spec.rb
|
1619
1629
|
- spec/functional/version_spec.rb
|
1620
1630
|
- spec/functional/win32/registry_helper_spec.rb
|
1621
1631
|
- spec/functional/win32/security_spec.rb
|
@@ -1859,6 +1869,7 @@ files:
|
|
1859
1869
|
- spec/unit/provider/deploy/timestamped_spec.rb
|
1860
1870
|
- spec/unit/provider/deploy_spec.rb
|
1861
1871
|
- spec/unit/provider/directory_spec.rb
|
1872
|
+
- spec/unit/provider/dsc_script_spec.rb
|
1862
1873
|
- spec/unit/provider/env/windows_spec.rb
|
1863
1874
|
- spec/unit/provider/env_spec.rb
|
1864
1875
|
- spec/unit/provider/erl_call_spec.rb
|
@@ -1965,6 +1976,7 @@ files:
|
|
1965
1976
|
- spec/unit/resource/deploy_spec.rb
|
1966
1977
|
- spec/unit/resource/directory_spec.rb
|
1967
1978
|
- spec/unit/resource/dpkg_package_spec.rb
|
1979
|
+
- spec/unit/resource/dsc_script_spec.rb
|
1968
1980
|
- spec/unit/resource/easy_install_package_spec.rb
|
1969
1981
|
- spec/unit/resource/env_spec.rb
|
1970
1982
|
- spec/unit/resource/erl_call_spec.rb
|
@@ -2035,9 +2047,13 @@ files:
|
|
2035
2047
|
- spec/unit/user_spec.rb
|
2036
2048
|
- spec/unit/util/backup_spec.rb
|
2037
2049
|
- spec/unit/util/diff_spec.rb
|
2050
|
+
- spec/unit/util/dsc/configuration_generator_spec.rb
|
2051
|
+
- spec/unit/util/dsc/lcm_output_parser_spec.rb
|
2052
|
+
- spec/unit/util/dsc/local_configuration_manager_spec.rb
|
2038
2053
|
- spec/unit/util/editor_spec.rb
|
2039
2054
|
- spec/unit/util/file_edit_spec.rb
|
2040
2055
|
- spec/unit/util/path_helper_spec.rb
|
2056
|
+
- spec/unit/util/powershell/cmdlet_spec.rb
|
2041
2057
|
- spec/unit/util/selinux_spec.rb
|
2042
2058
|
- spec/unit/util/threaded_job_queue_spec.rb
|
2043
2059
|
- spec/unit/version/platform_spec.rb
|