From 37525070c47944b7e7e7d0d1ce8093959c5943ce Mon Sep 17 00:00:00 2001 From: PaulHigin Date: Thu, 1 Sep 2022 09:36:24 -0700 Subject: [PATCH] Remove unneeded constructor tests --- test/PSCredentialInfo.Tests.ps1 | 81 --------------------------------- 1 file changed, 81 deletions(-) diff --git a/test/PSCredentialInfo.Tests.ps1 b/test/PSCredentialInfo.Tests.ps1 index 20f121adb..23d38c2c2 100644 --- a/test/PSCredentialInfo.Tests.ps1 +++ b/test/PSCredentialInfo.Tests.ps1 @@ -42,84 +42,3 @@ Describe "Create PSCredentialInfo with VaultName, SecretName, and Credential" -t $credentialInfo.SecretName | Should -Be $randomSecret } } - -Describe "Create PSCredentialInfo from a PSObject" -tags 'CI' { - - It "Throws if VaultName is null" { - $customObject = New-Object PSObject - { New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo $customObject } | Should -Throw -ErrorId "ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand" - } - - It "Throws if SecretName is null" { - $customObject = New-Object PSObject - $customObject | Add-Member -Name "VaultName" -Value "testvault" -MemberType NoteProperty - { New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo $customObject } | Should -Throw -ErrorId "ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand" - } - - It "Creates PSCredentialInfo successfully from PSObject with VaultName and SecretName" { - $randomSecret = [System.IO.Path]::GetRandomFileName() - $properties = [PSCustomObject]@{ - VaultName = "testvault" - SecretName = $randomSecret - } - - $credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties - - $credentialInfo.VaultName | Should -Be "testvault" - $credentialInfo.SecretName | Should -Be $randomSecret - } - - It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and PSCredential Credential" { - $randomSecret = [System.IO.Path]::GetRandomFileName() - $randomPassword = [System.IO.Path]::GetRandomFileName() - - $credential = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString $randomPassword -AsPlainText -Force)) - $properties = [PSCustomObject]@{ - VaultName = "testvault" - SecretName = $randomSecret - Credential = [PSCredential] $credential - } - - $credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties - - $credentialInfo.VaultName | Should -Be "testvault" - $credentialInfo.SecretName | Should -Be $randomSecret - $credentialInfo.Credential.UserName | Should -Be "username" - $credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword - } - - It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and string Credential" { - $randomSecret = [System.IO.Path]::GetRandomFileName() - $randomPassword = [System.IO.Path]::GetRandomFileName() - - $properties = [PSCustomObject]@{ - VaultName = "testvault" - SecretName = $randomSecret - Credential = $randomPassword - } - - $credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties - - $credentialInfo.VaultName | Should -Be "testvault" - $credentialInfo.SecretName | Should -Be $randomSecret - $credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword - } - - It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and SecureString Credential" { - $randomSecret = [System.IO.Path]::GetRandomFileName() - $randomPassword = [System.IO.Path]::GetRandomFileName() - - $secureString = ConvertTo-SecureString $randomPassword -AsPlainText -Force - $properties = [PSCustomObject]@{ - VaultName = "testvault" - SecretName = $randomSecret - Credential = $secureString - } - - $credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties - - $credentialInfo.VaultName | Should -Be "testvault" - $credentialInfo.SecretName | Should -Be $randomSecret - $credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword - } -}