From aec2017034bcf804430f941a0d41aba290459385 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 8 Dec 2016 15:38:16 -0800 Subject: fix windows tests dsc_script provider needs os defined. Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index e2b58f6432..8afcdbb590 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -76,6 +76,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do let(:env_value2) { "value2" } let(:dsc_test_run_context) do node = Chef::Node.new + node.automatic["os"] = "windows" node.automatic["platform"] = "windows" node.automatic["platform_version"] = "6.1" node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported -- cgit v1.2.1 From 404a9bc88be538769c6c80b3b31f39a6582991d2 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 13 Feb 2017 09:52:10 -0800 Subject: fix specs: RedundantReturn, RedundantSelf, RedundantBegin department of redundancy department Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 8afcdbb590..ce92c468f0 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -65,10 +65,8 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do end def delete_user(target_user) - begin - shell_out!("net user #{target_user} /delete") - rescue Mixlib::ShellOut::ShellCommandFailed - end + shell_out!("net user #{target_user} /delete") + rescue Mixlib::ShellOut::ShellCommandFailed end let(:dsc_env_variable) { "chefenvtest" } -- cgit v1.2.1 From 35603c7ce1bd3ccf35334ed65152140f0ecaf080 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 2 Jul 2018 10:25:16 -0700 Subject: fix Style/HashSyntax Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index ce92c468f0..efda46abbe 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -234,7 +234,7 @@ EOH expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) - expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true) + expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true) end it_should_behave_like "a dsc_script resource with configuration affected by cwd" @@ -314,7 +314,7 @@ EOH expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) - expect(dsc_test_resource.registry_value_exists?(test_registry_key, { :name => test_registry_value, :type => :string, :data => test_registry_data })).to eq(true) + expect(dsc_test_resource.registry_value_exists?(test_registry_key, { name: test_registry_value, type: :string, data: test_registry_data })).to eq(true) end end end -- cgit v1.2.1 From dcac6762380d011f73cf53a50476d31dab0025ee Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 2 Jul 2018 10:27:03 -0700 Subject: fix Layout/IndentHeredoc Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 184 ++++++++++++++-------------- 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index efda46abbe..3b7042610b 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -147,39 +147,39 @@ EOH let(:dsc_user_suffix_code) { dsc_user_suffix } let(:dsc_script_environment_attribute) { nil } let(:dsc_user_resources_code) do - <<-EOH - #{config_param_section} -node localhost -{ -$testuser = #{dsc_user_code} -$testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force -$testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword - -User dsctestusercreate -{ - UserName = $testuser - Password = $testcred - Description = "DSC test user" - Ensure = "Present" - Disabled = $false - PasswordNeverExpires = $true - PasswordChangeRequired = $false -} -} + <<~EOH + #{config_param_section} + node localhost + { + $testuser = #{dsc_user_code} + $testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force + $testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword + + User dsctestusercreate + { + UserName = $testuser + Password = $testcred + Description = "DSC test user" + Ensure = "Present" + Disabled = $false + PasswordNeverExpires = $true + PasswordChangeRequired = $false + } + } EOH end let(:dsc_user_config_data) do - <<-EOH -@{ - AllNodes = @( - @{ - NodeName = "localhost"; - PSDscAllowPlainTextPassword = $true - } - ) -} - + <<~EOH + @{ + AllNodes = @( + @{ + NodeName = "localhost"; + PSDscAllowPlainTextPassword = $true + } + ) + } + EOH end @@ -188,17 +188,17 @@ EOH let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } let(:exception_message_signature) { "LL927-LL928" } let(:dsc_environment_config) do - <<-EOH -if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}'))) -{ - throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}' -} -environment "whatsmydir" -{ - Name = '#{dsc_environment_env_var_name}' - Value = $pwd.path - Ensure = 'Present' -} + <<~EOH + if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}'))) + { + throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}' + } + environment "whatsmydir" + { + Name = '#{dsc_environment_env_var_name}' + Value = $pwd.path + Ensure = 'Present' + } EOH end @@ -243,12 +243,12 @@ EOH shared_examples_for "a dsc_script resource with configuration affected by cwd" do after(:each) do removal_resource = Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context) - removal_resource.code <<-EOH -environment 'removethis' -{ - Name = '#{dsc_environment_env_var_name}' - Ensure = 'Absent' -} + removal_resource.code <<~EOH + environment 'removethis' + { + Name = '#{dsc_environment_env_var_name}' + Ensure = 'Absent' + } EOH removal_resource.run_action(:run) end @@ -409,45 +409,45 @@ EOH end let(:dsc_configuration_script) do - <<-MYCODE -cd c:\\ -configuration LCM -{ - param ($thumbprint) - localconfigurationmanager - { - RebootNodeIfNeeded = $false - ConfigurationMode = 'ApplyOnly' - CertificateID = $thumbprint - } -} -$cert = ls Cert:\\LocalMachine\\My\\ | - Where-Object {$_.Subject -match "ChefTest"} | - Select -first 1 - -if($cert -eq $null) { - $pfxpath = '#{self_signed_cert_path}' - $password = '' - $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath, $password, ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeyset)) - $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "My", ([System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine) - $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) - $store.Add($cert) - $store.Close() -} - -lcm -thumbprint $cert.thumbprint -set-dsclocalconfigurationmanager -path ./LCM -$ConfigurationData = @" -@{ -AllNodes = @( - @{ - NodeName = "localhost"; - CertificateID = '$($cert.thumbprint)'; - }; -); -} -"@ -$ConfigurationData | out-file '#{configuration_data_path}' -force + <<~MYCODE + cd c:\\ + configuration LCM + { + param ($thumbprint) + localconfigurationmanager + { + RebootNodeIfNeeded = $false + ConfigurationMode = 'ApplyOnly' + CertificateID = $thumbprint + } + } + $cert = ls Cert:\\LocalMachine\\My\\ | + Where-Object {$_.Subject -match "ChefTest"} | + Select -first 1 + + if($cert -eq $null) { + $pfxpath = '#{self_signed_cert_path}' + $password = '' + $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath, $password, ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeyset)) + $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "My", ([System.Security.Cryptography.X509Certificates.StoreLocation]::LocalMachine) + $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) + $store.Add($cert) + $store.Close() + } + + lcm -thumbprint $cert.thumbprint + set-dsclocalconfigurationmanager -path ./LCM + $ConfigurationData = @" + @{ + AllNodes = @( + @{ + NodeName = "localhost"; + CertificateID = '$($cert.thumbprint)'; + }; + ); + } + "@ + $ConfigurationData | out-file '#{configuration_data_path}' -force MYCODE end @@ -460,13 +460,13 @@ $ConfigurationData | out-file '#{configuration_data_path}' -force let(:dsc_script_resource) do dsc_test_resource_base.tap do |r| - r.code <<-EOF -User dsctestusercreate -{ - UserName = '#{dsc_user}' - Password = #{r.ps_credential('jf9a8m49jrajf4#')} - Ensure = "Present" -} + r.code <<~EOF + User dsctestusercreate + { + UserName = '#{dsc_user}' + Password = #{r.ps_credential('jf9a8m49jrajf4#')} + Ensure = "Present" + } EOF r.configuration_data_script(configuration_data_path) end -- cgit v1.2.1 From 34a6dd714503abbb0e6d240a4832f245d5c3ab06 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 2 Jul 2018 10:30:53 -0700 Subject: clean up whitespace again Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 3b7042610b..e9301d4231 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -154,7 +154,7 @@ EOH $testuser = #{dsc_user_code} $testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force $testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword - + User dsctestusercreate { UserName = $testuser @@ -179,7 +179,7 @@ EOH } ) } - + EOH end @@ -424,7 +424,7 @@ EOH $cert = ls Cert:\\LocalMachine\\My\\ | Where-Object {$_.Subject -match "ChefTest"} | Select -first 1 - + if($cert -eq $null) { $pfxpath = '#{self_signed_cert_path}' $password = '' @@ -434,7 +434,7 @@ EOH $store.Add($cert) $store.Close() } - + lcm -thumbprint $cert.thumbprint set-dsclocalconfigurationmanager -path ./LCM $ConfigurationData = @" -- cgit v1.2.1 From 0bdd618fc5146dad3fa5a90d10a4b5e608e4663d Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 2 Jul 2018 10:32:45 -0700 Subject: fix Style/UnneededInterpolation Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index e9301d4231..1caa07d105 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -347,7 +347,7 @@ EOH shared_examples_for "a dsc_script with configuration data that takes parameters" do let(:dsc_user_code) { dsc_user_param_code } let(:config_param_section) { config_params } - let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}" } } + let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => (dsc_user_prefix).to_s, :"#{dsc_user_suffix_param_name}" => (dsc_user_suffix).to_s } } it "does not directly contain the user name" do configuration_script_content = ::File.open(dsc_test_resource.command) do |file| file.read -- cgit v1.2.1 From 990974ca5cd44df0c77bb6a12fc57a3c32b92e23 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 15 Jan 2019 13:07:58 -0800 Subject: changes for rubocop engine upgrades. this is the result of changes to rules we already previously had enabled. Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 1caa07d105..04a65acae7 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -103,7 +103,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do ValueData = '#{test_registry_data}' Ensure = 'Present' } -EOH + EOH end let(:dsc_code) { dsc_reg_code } @@ -111,7 +111,7 @@ EOH <<-EOH param($testregkeyname, $testregvaluename) #{dsc_reg_code} -EOH + EOH end let(:dsc_user_prefix) { "dsc" } @@ -138,7 +138,7 @@ EOH $#{dsc_user_prefix_param_name}, $#{dsc_user_suffix_param_name} ) -EOH + EOH end let(:config_param_section) { "" } @@ -166,7 +166,7 @@ EOH PasswordChangeRequired = $false } } -EOH + EOH end let(:dsc_user_config_data) do @@ -180,7 +180,7 @@ EOH ) } -EOH + EOH end let(:dsc_environment_env_var_name) { "dsc_test_cwd" } @@ -199,7 +199,7 @@ EOH Value = $pwd.path Ensure = 'Present' } -EOH + EOH end let(:dsc_config_name) do @@ -249,7 +249,7 @@ EOH Name = '#{dsc_environment_env_var_name}' Ensure = 'Absent' } -EOH + EOH removal_resource.run_action(:run) end @@ -448,7 +448,7 @@ EOH } "@ $ConfigurationData | out-file '#{configuration_data_path}' -force - MYCODE + MYCODE end let(:powershell_script_resource) do @@ -467,7 +467,7 @@ EOH Password = #{r.ps_credential('jf9a8m49jrajf4#')} Ensure = "Present" } -EOF + EOF r.configuration_data_script(configuration_data_path) end end -- cgit v1.2.1 From 98d736b40bcde92026b30c1566fbaaaefb5636cd Mon Sep 17 00:00:00 2001 From: Bryan McLellan Date: Tue, 9 Apr 2019 15:51:09 -0400 Subject: Don't force DSC functional tests to PS4 New Windows platforms like 2016 have Powershell 5. Signed-off-by: Bryan McLellan --- spec/functional/resource/dsc_script_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 04a65acae7..37b70598df 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -74,11 +74,11 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do let(:env_value2) { "value2" } let(:dsc_test_run_context) do node = Chef::Node.new + node.consume_external_attrs(OHAI_SYSTEM.data, {}) # node[:languages][:powershell][:version] node.automatic["os"] = "windows" node.automatic["platform"] = "windows" node.automatic["platform_version"] = "6.1" node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported - node.automatic[:languages][:powershell][:version] = "4.0" empty_events = Chef::EventDispatch::Dispatcher.new Chef::RunContext.new(node, {}, empty_events) end -- cgit v1.2.1 From 90a74a80196725c4198b6042e8485d68c70777ac Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 2 Jul 2019 10:03:50 -0700 Subject: fixes for chefstyle bump result of automation https://github.com/chef/chefstyle/pull/72 Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 37b70598df..0808927000 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -310,7 +310,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do it "should set a registry key according to parameters passed to the configuration" do dsc_test_resource.configuration_name(config_name_value) - dsc_test_resource.flags({ :"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value }) + dsc_test_resource.flags({ "#{reg_key_name_param_name}": test_registry_key, "#{reg_key_value_param_name}": test_registry_value }) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) @@ -347,7 +347,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do shared_examples_for "a dsc_script with configuration data that takes parameters" do let(:dsc_user_code) { dsc_user_param_code } let(:config_param_section) { config_params } - let(:config_flags) { { :"#{dsc_user_prefix_param_name}" => (dsc_user_prefix).to_s, :"#{dsc_user_suffix_param_name}" => (dsc_user_suffix).to_s } } + let(:config_flags) { { "#{dsc_user_prefix_param_name}": (dsc_user_prefix).to_s, "#{dsc_user_suffix_param_name}": (dsc_user_suffix).to_s } } it "does not directly contain the user name" do configuration_script_content = ::File.open(dsc_test_resource.command) do |file| file.read -- cgit v1.2.1 From 2a4916b7f01940d1199c35645c1b2172f5bd74b2 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 5 Jul 2019 12:58:00 -0700 Subject: Style/StringLiteralsInInterpolation since we use double quotes, be consistent everywhere. Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 0808927000..8488fe09ed 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -184,8 +184,8 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do end let(:dsc_environment_env_var_name) { "dsc_test_cwd" } - let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" } - let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } + let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV["systemroot"]}\\system32" } + let(:dsc_environment_fail_etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" } let(:exception_message_signature) { "LL927-LL928" } let(:dsc_environment_config) do <<~EOH @@ -464,7 +464,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do User dsctestusercreate { UserName = '#{dsc_user}' - Password = #{r.ps_credential('jf9a8m49jrajf4#')} + Password = #{r.ps_credential("jf9a8m49jrajf4#")} Ensure = "Present" } EOF -- cgit v1.2.1 From 3b10f9ca503dcbce747241281b9151d3d010f9ef Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 5 Jul 2019 13:26:53 -0700 Subject: Style/SymbolProc enforce pretzels. Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 8488fe09ed..224141c0f8 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -349,9 +349,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do let(:config_param_section) { config_params } let(:config_flags) { { "#{dsc_user_prefix_param_name}": (dsc_user_prefix).to_s, "#{dsc_user_suffix_param_name}": (dsc_user_suffix).to_s } } it "does not directly contain the user name" do - configuration_script_content = ::File.open(dsc_test_resource.command) do |file| - file.read - end + configuration_script_content = ::File.open(dsc_test_resource.command, &:read) expect(configuration_script_content.include?(dsc_user)).to be(false) end it_behaves_like "a dsc_script with configuration data" @@ -361,9 +359,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do let(:dsc_user_code) { dsc_user_env_code } it "does not directly contain the user name" do - configuration_script_content = ::File.open(dsc_test_resource.command) do |file| - file.read - end + configuration_script_content = ::File.open(dsc_test_resource.command, &:read) expect(configuration_script_content.include?(dsc_user)).to be(false) end it_behaves_like "a dsc_script with configuration data" -- cgit v1.2.1 From 4d3b847aee1b917bb139862c623e9633d180fb31 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 13 Apr 2020 15:21:45 -0700 Subject: Remove copyright dates Legally incredibly dubious, particularly since we don't follow it strictly as policy, and we have git history instead, which does it right. This is just a waste of time and a cargo cult. Signed-off-by: Lamont Granquist --- spec/functional/resource/dsc_script_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 224141c0f8..85f21cdbbd 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Edwards () -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); -- cgit v1.2.1 From 10bc6366052a06c9445c40f2bbb4d84cd64499ae Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 4 Aug 2020 09:03:30 -0700 Subject: Remove more requires that come for free The universal DSL includes all this stuff. In resource we include the universal DSL, but we also include several of the things it includes. Signed-off-by: Tim Smith --- spec/functional/resource/dsc_script_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 85f21cdbbd..83544cee04 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -18,7 +18,6 @@ require "spec_helper" require "chef/mixin/powershell_out" -require "chef/mixin/shell_out" require "chef/mixin/windows_architecture_helper" require "support/shared/integration/integration_helper" -- cgit v1.2.1 From 67f3ba114e27e8353b7844aede1c26b06fdd7a3e Mon Sep 17 00:00:00 2001 From: mwrock Date: Wed, 28 Oct 2020 15:44:50 -0700 Subject: convert most internal powershell_out to powershell_exec Signed-off-by: mwrock --- spec/functional/resource/dsc_script_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 83544cee04..9d18e2f85d 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -17,13 +17,13 @@ # require "spec_helper" -require "chef/mixin/powershell_out" +require "chef/mixin/powershell_exec" require "chef/mixin/windows_architecture_helper" require "support/shared/integration/integration_helper" describe Chef::Resource::DscScript, :windows_powershell_dsc_only do include Chef::Mixin::WindowsArchitectureHelper - include Chef::Mixin::PowershellOut + include Chef::Mixin::PowershellExec before(:all) do @temp_dir = ::Dir.mktmpdir("dsc-functional-test") # enable the HTTP listener if it is not already enabled needed by underlying DSC engine @@ -33,7 +33,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do winrm create winrm/config/Listener?Address=*+Transport=HTTP } CODE - powershell_out!(winrm_code) + powershell_exec!(winrm_code) end after(:all) do -- cgit v1.2.1 From 6408c925c03bb44ea3ae2194c064815177497d2e Mon Sep 17 00:00:00 2001 From: mwrock Date: Mon, 30 Nov 2020 13:40:36 -0800 Subject: replace usages of Cmdlet class with powershell_exec Signed-off-by: mwrock --- spec/functional/resource/dsc_script_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 9d18e2f85d..60197c8643 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -261,10 +261,10 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do it "should raise an exception if the cwd is etc" do dsc_test_resource.cwd(dsc_environment_fail_etc_directory) - expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::Exceptions::PowershellCmdletException) + expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::PowerShell::CommandFailed) begin dsc_test_resource.run_action(:run) - rescue Chef::Exceptions::PowershellCmdletException => e + rescue Chef::PowerShell::CommandFailed => e expect(e.message).to match(exception_message_signature) end end -- cgit v1.2.1 From 63c8079bc281048f4327c1e4912b88859a7eef69 Mon Sep 17 00:00:00 2001 From: mwrock Date: Mon, 30 Nov 2020 16:03:17 -0800 Subject: responding to feedback Signed-off-by: mwrock --- spec/functional/resource/dsc_script_spec.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 60197c8643..87c624e85f 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -261,12 +261,9 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do it "should raise an exception if the cwd is etc" do dsc_test_resource.cwd(dsc_environment_fail_etc_directory) - expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::PowerShell::CommandFailed) - begin + expect { dsc_test_resource.run_action(:run) - rescue Chef::PowerShell::CommandFailed => e - expect(e.message).to match(exception_message_signature) - end + }.to raise_error(Chef::PowerShell::CommandFailed, /#{exception_message_signature}/) end end end -- cgit v1.2.1 From 9f3e836914fcc00425b452502a8806381d685842 Mon Sep 17 00:00:00 2001 From: mwrock Date: Thu, 3 Dec 2020 14:55:56 -0800 Subject: only test dsc_script on 64 bit and document that it will fail on 32 bit clients Signed-off-by: mwrock --- spec/functional/resource/dsc_script_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 87c624e85f..d0baeae7a9 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -21,7 +21,7 @@ require "chef/mixin/powershell_exec" require "chef/mixin/windows_architecture_helper" require "support/shared/integration/integration_helper" -describe Chef::Resource::DscScript, :windows_powershell_dsc_only do +describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :windows64_only do include Chef::Mixin::WindowsArchitectureHelper include Chef::Mixin::PowershellExec before(:all) do -- cgit v1.2.1 From e33babda9681f0276e9ef6661d5f5c86f644e0bb Mon Sep 17 00:00:00 2001 From: mwrock Date: Fri, 4 Dec 2020 09:47:37 -0800 Subject: only run dsc_script functional tests on 64 bit ruby Signed-off-by: mwrock --- spec/functional/resource/dsc_script_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/functional/resource/dsc_script_spec.rb') diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index d0baeae7a9..b22599266b 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -21,7 +21,7 @@ require "chef/mixin/powershell_exec" require "chef/mixin/windows_architecture_helper" require "support/shared/integration/integration_helper" -describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :windows64_only do +describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :ruby64_only do include Chef::Mixin::WindowsArchitectureHelper include Chef::Mixin::PowershellExec before(:all) do -- cgit v1.2.1