|
1 | 1 | # Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | # Licensed under the MIT License. |
3 | 3 |
|
4 | | -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'Tests create SecureStrings from known test data')] |
5 | | -param() |
6 | | - |
7 | 4 | Describe "Test Microsoft.PowerShell.SecretStore module" { |
8 | 5 | BeforeAll { |
9 | 6 | Import-Module -Force -Name Microsoft.PowerShell.SecretManagement |
@@ -126,7 +123,7 @@ Describe "Test Microsoft.PowerShell.SecretStore module" { |
126 | 123 | } |
127 | 124 |
|
128 | 125 | It "Verifies Unlock-SecretStore throws expected error when in no password mode" { |
129 | | - $token = ConvertTo-SecureString -String "None" -AsPlainText -Force |
| 126 | + $token = [System.Net.NetworkCredential]::new('', 'None').SecurePassword |
130 | 127 | { Unlock-SecretStore -Password $token } | Should -Throw -ErrorId 'InvalidOperation,Microsoft.PowerShell.SecretStore.UnlockSecretStoreCommand' |
131 | 128 | } |
132 | 129 | } |
@@ -332,7 +329,7 @@ Describe "Test Microsoft.PowerShell.SecretStore module" { |
332 | 329 | BeforeAll { |
333 | 330 | $secretName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) |
334 | 331 | $randomSecret = [System.IO.Path]::GetRandomFileName() |
335 | | - $secureStringToWrite = ConvertTo-SecureString -String $randomSecret -AsPlainText -Force |
| 332 | + $secureStringToWrite = [System.Net.NetworkCredential]::new('', $randomSecret).SecurePassword |
336 | 333 | $errorMsg = "" |
337 | 334 | } |
338 | 335 |
|
@@ -398,7 +395,7 @@ Describe "Test Microsoft.PowerShell.SecretStore module" { |
398 | 395 | } |
399 | 396 |
|
400 | 397 | It "Verifies PSCredential type write to SecretStore" { |
401 | | - $cred = [pscredential]::new('UserL', (ConvertTo-SecureString $randomSecret -AsPlainText -Force)) |
| 398 | + $cred = [pscredential]::new('UserL', ([System.Net.NetworkCredential]::new('', $randomSecret).SecurePassword)) |
402 | 399 | $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().WriteObject( |
403 | 400 | $secretName, |
404 | 401 | $cred, |
@@ -465,8 +462,8 @@ Describe "Test Microsoft.PowerShell.SecretStore module" { |
465 | 462 | $ht = @{ |
466 | 463 | Blob = ([byte[]] @(1,2)) |
467 | 464 | Str = "TestHashtableString" |
468 | | - SecureString = (ConvertTo-SecureString $randomSecretA -AsPlainText -Force) |
469 | | - Cred = ([pscredential]::New("UserA", (ConvertTo-SecureString $randomSecretB -AsPlainText -Force))) |
| 465 | + SecureString = ([System.Net.NetworkCredential]::new('', $randomSecretA).SecurePassword) |
| 466 | + Cred = ([pscredential]::New("UserA", ([System.Net.NetworkCredential]::new('', $randomSecretB).SecurePassword))) |
470 | 467 | } |
471 | 468 |
|
472 | 469 | $success = [Microsoft.PowerShell.SecretStore.LocalSecretStore]::GetInstance().WriteObject( |
|
0 commit comments