diff options
author | adamedx <adamedx@gmail.com> | 2016-02-15 07:47:15 -0800 |
---|---|---|
committer | nimisha <nimisha.sharad@msystechnologies.com> | 2017-02-02 18:00:28 +0530 |
commit | f0809fbb1c08ad14faed9c51f861a94373a39d27 (patch) | |
tree | 172c532086df85ba29ca6c5800c94ba826b271fc /spec | |
parent | 4044fdbe22d45e5f859f952cd5b2ae36f6e1115c (diff) | |
download | chef-f0809fbb1c08ad14faed9c51f861a94373a39d27.tar.gz |
Rubcop violations in alt-user execute common code
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/shared/functional/execute_resource.rb | 28 | ||||
-rw-r--r-- | spec/unit/mixin/user_identity_spec.rb | 42 |
2 files changed, 35 insertions, 35 deletions
diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb index 8e402d3dbe..6561f95ec1 100644 --- a/spec/support/shared/functional/execute_resource.rb +++ b/spec/support/shared/functional/execute_resource.rb @@ -19,11 +19,11 @@ shared_context "a non-admin Windows user" do include Chef::Mixin::ShellOut - let(:windows_nonadmin_user_domain) { ENV['COMPUTERNAME'] } + let(:windows_nonadmin_user_domain) { ENV["COMPUTERNAME"] } let(:windows_nonadmin_user_qualified) { "#{windows_nonadmin_user_domain}\\#{windows_nonadmin_user}" } let(:temp_profile_path) { "#{ENV['USERPROFILE']}\\..\\cheftesttempuser" } before do - shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0,2]) + shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0, 2]) # Supply a profile path when creating a user to avoid an apparent Windows bug where deleting # the user actually creates the profile when it did not immediately exist before executing @@ -33,19 +33,19 @@ shared_context "a non-admin Windows user" do end after do - shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0,2]) + shell_out!("net.exe user /delete #{windows_nonadmin_user}", returns: [0, 2]) end end shared_context "alternate user identity" do - let(:windows_alternate_user) {"chef%02d%02d%02d" %[Time.now.year % 100, Time.now.month, Time.now.day]} - let(:windows_alternate_user_password) { 'lj28;fx3T!x,2'} + let(:windows_alternate_user) { "chef%02d%02d%02d" % [Time.now.year % 100, Time.now.month, Time.now.day] } + let(:windows_alternate_user_password) { "lj28;fx3T!x,2" } let(:windows_alternate_user_qualified) { "#{ENV['COMPUTERNAME']}\\#{windows_alternate_user}" } let(:windows_nonadmin_user) { windows_alternate_user } let(:windows_nonadmin_user_password) { windows_alternate_user_password } - include_context 'a non-admin Windows user' + include_context "a non-admin Windows user" end shared_context "a command that can be executed as an alternate user" do @@ -58,7 +58,7 @@ shared_context "a command that can be executed as an alternate user" do include Chef::Mixin::ShellOut before do - shell_out!("icacls \"#{script_output_dir.gsub(/\//,'\\')}\" /grant \"authenticated users:(F)\"") + shell_out!("icacls \"#{script_output_dir.gsub(/\//, '\\')}\" /grant \"authenticated users:(F)\"") end after do @@ -72,7 +72,7 @@ shared_examples_for "an execute resource that supports alternate user identity" include_context "a command that can be executed as an alternate user" - let(:windows_current_user) { ENV['USERNAME'] } + let(:windows_current_user) { ENV["USERNAME"] } let(:windows_current_user_qualified) { "#{ENV['USERDOMAIN'] || ENV['COMPUTERNAME']}\\#{windows_current_user}" } let(:resource_identity_command) { "powershell.exe -noprofile -command \"import-module microsoft.powershell.utility;([Security.Principal.WindowsPrincipal]([Security.Principal.WindowsIdentity]::GetCurrent())).identity.name | out-file -encoding ASCII '#{script_output_path}'\"" } @@ -107,8 +107,8 @@ shared_examples_for "a resource with a guard specifying an alternate user identi let(:resource_command_property) { :command } - let(:powershell_equal_to_alternate_user) { '-eq' } - let(:powershell_not_equal_to_alternate_user) { '-ne' } + let(:powershell_equal_to_alternate_user) { "-eq" } + let(:powershell_not_equal_to_alternate_user) { "-ne" } let(:guard_identity_command) { "powershell.exe -noprofile -command \"import-module microsoft.powershell.utility;exit @(392,0)[[int32](([Security.Principal.WindowsPrincipal]([Security.Principal.WindowsIdentity]::GetCurrent())).Identity.Name #{comparison_to_alternate_user} '#{windows_alternate_user_qualified}')]\"" } before do @@ -119,13 +119,13 @@ shared_examples_for "a resource with a guard specifying an alternate user identi let(:comparison_to_alternate_user) { powershell_equal_to_alternate_user } it "causes the resource to be updated for only_if" do - resource.only_if(guard_identity_command, {user: windows_alternate_user, password: windows_alternate_user_password}) + resource.only_if(guard_identity_command, { user: windows_alternate_user, password: windows_alternate_user_password }) resource.run_action(:run) expect(resource).to be_updated_by_last_action end it "causes the resource to not be updated for not_if" do - resource.not_if(guard_identity_command, {user: windows_alternate_user, password: windows_alternate_user_password}) + resource.not_if(guard_identity_command, { user: windows_alternate_user, password: windows_alternate_user_password }) resource.run_action(:run) expect(resource).not_to be_updated_by_last_action end @@ -135,13 +135,13 @@ shared_examples_for "a resource with a guard specifying an alternate user identi let(:comparison_to_alternate_user) { powershell_not_equal_to_alternate_user } it "causes the resource not to be updated for only_if" do - resource.only_if(guard_identity_command, {user: windows_alternate_user, password: windows_alternate_user_password}) + resource.only_if(guard_identity_command, { user: windows_alternate_user, password: windows_alternate_user_password }) resource.run_action(:run) expect(resource).not_to be_updated_by_last_action end it "causes the resource to be updated for not_if" do - resource.not_if(guard_identity_command, {user: windows_alternate_user, password: windows_alternate_user_password}) + resource.not_if(guard_identity_command, { user: windows_alternate_user, password: windows_alternate_user_password }) resource.run_action(:run) expect(resource).to be_updated_by_last_action end diff --git a/spec/unit/mixin/user_identity_spec.rb b/spec/unit/mixin/user_identity_spec.rb index f75092f660..799260b25a 100644 --- a/spec/unit/mixin/user_identity_spec.rb +++ b/spec/unit/mixin/user_identity_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/user_identity' +require "spec_helper" +require "chef/mixin/user_identity" shared_examples_for "it received valid credentials" do describe "the validation method" do it "should not raise an error" do - expect {instance_with_identity.validate(username, password, domain)}.not_to raise_error + expect { instance_with_identity.validate(username, password, domain) }.not_to raise_error end end @@ -39,7 +39,7 @@ end shared_examples_for "it received invalid credentials" do describe "the validation method" do it "should raise an error" do - expect { instance_with_identity.validate(username, password, domain)}.to raise_error(ArgumentError) + expect { instance_with_identity.validate(username, password, domain) }.to raise_error(ArgumentError) end end end @@ -47,7 +47,7 @@ end shared_examples_for "it received credentials that are not valid on the platform" do describe "the validation method" do it "should raise an error" do - expect { instance_with_identity.validate(username, password, domain)}.to raise_error(Chef::Exceptions::UnsupportedPlatform) + expect { instance_with_identity.validate(username, password, domain) }.to raise_error(Chef::Exceptions::UnsupportedPlatform) end end end @@ -66,9 +66,9 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do end context "when a valid username is specified" do - let(:username) { 'starchild' } + let(:username) { "starchild" } context "when a valid domain is specified" do - let(:domain) { 'mothership' } + let(:domain) { "mothership" } context "when the password is not specified" do let(:password) { nil } @@ -76,7 +76,7 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do end context "when the password is specified" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } it_behaves_like "it received valid credentials" end end @@ -90,7 +90,7 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do end context "when the password is specified" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } it_behaves_like "it received valid credentials" end end @@ -100,20 +100,20 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do let(:username) { nil } context "when the password is specified and the domain is not" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } let(:domain) { nil } it_behaves_like "it received invalid credentials" end context "when the domain is specified and the password is not" do - let(:domain) { 'mothership' } + let(:domain) { "mothership" } let(:password) { nil } it_behaves_like "it received invalid credentials" end context "when the domain and password are specified" do - let(:domain) { 'mothership' } - let(:password) { 'we.funk!' } + let(:domain) { "mothership" } + let(:password) { "we.funk!" } it_behaves_like "it received invalid credentials" end end @@ -132,26 +132,26 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do end context "when the user is specified and the domain and password are not" do - let(:username) { 'starchild' } + let(:username) { "starchild" } let(:domain) { nil } let(:password) { nil } it_behaves_like "it received valid credentials" context "when the password is specified and the domain is not" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } let(:domain) { nil } it_behaves_like "it received credentials that are not valid on the platform" end context "when the domain is specified and the password is not" do - let(:domain) { 'mothership' } + let(:domain) { "mothership" } let(:password) { nil } it_behaves_like "it received credentials that are not valid on the platform" end context "when the domain and password are specified" do - let(:domain) { 'mothership' } - let(:password) { 'we.funk!' } + let(:domain) { "mothership" } + let(:password) { "we.funk!" } it_behaves_like "it received credentials that are not valid on the platform" end end @@ -159,9 +159,9 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do context "when the user is not specified" do let(:username) { nil } context "when the domain is specified" do - let(:domain) { 'mothership' } + let(:domain) { "mothership" } context "when the password is specified" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } it_behaves_like "it received credentials that are not valid on the platform" end @@ -174,7 +174,7 @@ shared_examples_for "a consumer of the ::Chef::Mixin::UserIdentity mixin" do context "when the domain is not specified" do let(:domain) { nil } context "when the password is specified" do - let(:password) { 'we.funk!' } + let(:password) { "we.funk!" } it_behaves_like "it received credentials that are not valid on the platform" end end |