Skip to content

Commit d257425

Browse files
authored
Remove unneeded constructor tests (#787)
1 parent 1ef484f commit d257425

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

test/PSCredentialInfo.Tests.ps1

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -42,84 +42,3 @@ Describe "Create PSCredentialInfo with VaultName, SecretName, and Credential" -t
4242
$credentialInfo.SecretName | Should -Be $randomSecret
4343
}
4444
}
45-
46-
Describe "Create PSCredentialInfo from a PSObject" -tags 'CI' {
47-
48-
It "Throws if VaultName is null" {
49-
$customObject = New-Object PSObject
50-
{ New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo $customObject } | Should -Throw -ErrorId "ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand"
51-
}
52-
53-
It "Throws if SecretName is null" {
54-
$customObject = New-Object PSObject
55-
$customObject | Add-Member -Name "VaultName" -Value "testvault" -MemberType NoteProperty
56-
{ New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo $customObject } | Should -Throw -ErrorId "ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand"
57-
}
58-
59-
It "Creates PSCredentialInfo successfully from PSObject with VaultName and SecretName" {
60-
$randomSecret = [System.IO.Path]::GetRandomFileName()
61-
$properties = [PSCustomObject]@{
62-
VaultName = "testvault"
63-
SecretName = $randomSecret
64-
}
65-
66-
$credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties
67-
68-
$credentialInfo.VaultName | Should -Be "testvault"
69-
$credentialInfo.SecretName | Should -Be $randomSecret
70-
}
71-
72-
It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and PSCredential Credential" {
73-
$randomSecret = [System.IO.Path]::GetRandomFileName()
74-
$randomPassword = [System.IO.Path]::GetRandomFileName()
75-
76-
$credential = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString $randomPassword -AsPlainText -Force))
77-
$properties = [PSCustomObject]@{
78-
VaultName = "testvault"
79-
SecretName = $randomSecret
80-
Credential = [PSCredential] $credential
81-
}
82-
83-
$credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties
84-
85-
$credentialInfo.VaultName | Should -Be "testvault"
86-
$credentialInfo.SecretName | Should -Be $randomSecret
87-
$credentialInfo.Credential.UserName | Should -Be "username"
88-
$credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword
89-
}
90-
91-
It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and string Credential" {
92-
$randomSecret = [System.IO.Path]::GetRandomFileName()
93-
$randomPassword = [System.IO.Path]::GetRandomFileName()
94-
95-
$properties = [PSCustomObject]@{
96-
VaultName = "testvault"
97-
SecretName = $randomSecret
98-
Credential = $randomPassword
99-
}
100-
101-
$credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties
102-
103-
$credentialInfo.VaultName | Should -Be "testvault"
104-
$credentialInfo.SecretName | Should -Be $randomSecret
105-
$credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword
106-
}
107-
108-
It "Creates PSCredentialInfo successfully from PSObject with VaultName, SecretName and SecureString Credential" {
109-
$randomSecret = [System.IO.Path]::GetRandomFileName()
110-
$randomPassword = [System.IO.Path]::GetRandomFileName()
111-
112-
$secureString = ConvertTo-SecureString $randomPassword -AsPlainText -Force
113-
$properties = [PSCustomObject]@{
114-
VaultName = "testvault"
115-
SecretName = $randomSecret
116-
Credential = $secureString
117-
}
118-
119-
$credentialInfo = [Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo] $properties
120-
121-
$credentialInfo.VaultName | Should -Be "testvault"
122-
$credentialInfo.SecretName | Should -Be $randomSecret
123-
$credentialInfo.Credential.GetNetworkCredential().Password | Should -Be $randomPassword
124-
}
125-
}

0 commit comments

Comments
 (0)