diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-11 20:05:08 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-20 14:38:05 -0700 |
commit | 9a65eb8552db53fdd0bd93c945e001905ad793e3 (patch) | |
tree | 5765c2c51cac1f804de07fee70c71e3edf5c1093 /lib/chef | |
parent | a6902ea47197a9f2600795a7d1d48713ea05dbd1 (diff) | |
download | chef-9a65eb8552db53fdd0bd93c945e001905ad793e3.tar.gz |
Refactor ps_credential for easier mocking
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/util/powershell/ps_credential.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/util/powershell/ps_credential.rb b/lib/chef/util/powershell/ps_credential.rb index 20c2055247..701b3ce685 100644 --- a/lib/chef/util/powershell/ps_credential.rb +++ b/lib/chef/util/powershell/ps_credential.rb @@ -22,11 +22,17 @@ class Chef::Util::Powershell class PSCredential def initialize(username, password) @username = username - @encrypted_password = Chef::ReservedNames::Win32::Crypto.encrypt(password) + @password = password end def to_psobject - "New-Object System.Management.Automation.PSCredential('#{@username}',\('#{@encrypted_password}' | ConvertTo-SecureString))" + "New-Object System.Management.Automation.PSCredential('#{@username}',('#{encrypt(@password)}' | ConvertTo-SecureString))" + end + + private + + def encrypt(str) + Chef::ReservedNames::Win32::Crypto.encrypt(str) end end end |