From 39bd22505b847ff305ca4a6c58b0c0a64c367e44 Mon Sep 17 00:00:00 2001 From: Vasu1105 Date: Wed, 5 Feb 2020 22:02:06 -0800 Subject: Replaced powershell_out with powershell_exec and updated data type for sensitive class Signed-off-by: Vasu1105 --- lib/chef/resource/windows_user_privilege.rb | 6 +++--- spec/functional/resource/windows_user_privilege_spec.rb | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/chef/resource/windows_user_privilege.rb b/lib/chef/resource/windows_user_privilege.rb index c5538c7e19..b1955bd43b 100644 --- a/lib/chef/resource/windows_user_privilege.rb +++ b/lib/chef/resource/windows_user_privilege.rb @@ -1,7 +1,7 @@ # # Author:: Jared Kauppila () # Author:: Vasundhara Jagdale() -# Copyright 2008-2019, Chef Software, Inc. +# Copyright 2008-2020, Chef Software, Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ class Chef }, } - property :sensitive, [true, false], default: true + property :sensitive, [TrueClass, FalseClass], default: true load_current_value do |new_resource| unless new_resource.principal.nil? @@ -111,7 +111,7 @@ class Chef raise Chef::Exceptions::ValidationFailed, "Users are required property with set action." end - if powershell_out!("Get-PackageSource -Name PSGallery").stdout.empty? || powershell_out!("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").stdout.empty? + if powershell_exec("(Get-PackageSource -Name PSGallery).name").result.empty? || powershell_exec("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").result.empty? raise "This resource needs Powershell module cSecurityOptions to be installed. \n Please install it and then re-run the recipe. \n https://www.powershellgallery.com/packages/cSecurityOptions/3.1.3" end diff --git a/spec/functional/resource/windows_user_privilege_spec.rb b/spec/functional/resource/windows_user_privilege_spec.rb index 4f67032ff0..cf1320e12a 100644 --- a/spec/functional/resource/windows_user_privilege_spec.rb +++ b/spec/functional/resource/windows_user_privilege_spec.rb @@ -1,6 +1,6 @@ # # Author:: Vasundhara Jagdale () -# Copyright 2008-2019, Chef Software, Inc. +# Copyright 2008-2020, Chef Software, Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ require_relative "../../spec_helper" require_relative "../../functional/resource/base" describe Chef::Resource::WindowsUserPrivilege, :windows_only do - include Chef::Mixin::PowershellOut + include Chef::Mixin::PowershellExec let(:principal) { nil } let(:privilege) { nil } @@ -65,7 +65,7 @@ describe Chef::Resource::WindowsUserPrivilege, :windows_only do describe "#set privilege" do before(:all) { - powershell_out!("Uninstall-Module -Name cSecurityOptions") unless powershell_out!("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").stdout.empty? + powershell_exec("Uninstall-Module -Name cSecurityOptions") unless powershell_exec("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").result.empty? } let(:principal) { "user_privilege" } @@ -80,7 +80,7 @@ describe Chef::Resource::WindowsUserPrivilege, :windows_only do describe "#set privilege" do before(:all) { - powershell_out!("Install-Module -Name cSecurityOptions -Force") if powershell_out!("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").stdout.empty? + powershell_exec("Install-Module -Name cSecurityOptions -Force") if powershell_exec("(Get-Package -Name cSecurityOptions -WarningAction SilentlyContinue).name").result.empty? } after { remove_user_privilege("Administrator", subject.privilege) } -- cgit v1.2.1