@@ -16,7 +16,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
16
16
17
17
Describe " $CommandName Integration Tests" - Tag " IntegrationTests" {
18
18
BeforeAll {
19
- $logins = " dbatoolsci_thor " , " dbatoolsci_thorsmomma " , " dbatoolsci_thor_crypto "
19
+ $logins = " thor " , " thorsmomma " , " thor_crypto "
20
20
$plaintext = " BigOlPassword!"
21
21
$password = ConvertTo-SecureString $plaintext - AsPlainText - Force
22
22
@@ -26,7 +26,6 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
26
26
# Add user
27
27
foreach ($login in $logins ) {
28
28
$null = Invoke-Command2 - ScriptBlock { net user $args [0 ] $args [1 ] / add * > & 1 } - ArgumentList $login , $plaintext - ComputerName $TestConfig.instance2
29
- $null = Invoke-Command2 - ScriptBlock { net user $args [0 ] $args [1 ] / add * > & 1 } - ArgumentList $login , $plaintext - ComputerName $TestConfig.instance3
30
29
}
31
30
32
31
<#
@@ -64,43 +63,41 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
64
63
$cryptoProvider = ($instance2CryptoProviders | Where-Object { $_.name -eq $instance3CryptoProviders.name } | Select-Object - First 1 ).name
65
64
}
66
65
AfterAll {
67
- (Get-DbaCredential - SqlInstance $server2 - Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto - ErrorAction Stop - WarningAction SilentlyContinue).Drop()
68
- (Get-DbaCredential - SqlInstance $server3 - Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto - ErrorAction Stop - WarningAction SilentlyContinue).Drop()
66
+ Remove-DbaCredential - SqlInstance $server2 , $server3 - Identity thor, thorsmomma, thor_crypto - Confirm:$false
69
67
70
68
foreach ($login in $logins ) {
71
69
$null = Invoke-Command2 - ScriptBlock { net user $args / delete * > & 1 } - ArgumentList $login - ComputerName $TestConfig.instance2
72
- $null = Invoke-Command2 - ScriptBlock { net user $args / delete * > & 1 } - ArgumentList $login - ComputerName $TestConfig.instance3
73
70
}
74
71
}
75
72
76
73
Context " Create new credential" {
77
74
It " Should create new credentials with the proper properties" {
78
- $results = New-DbaCredential - SqlInstance $server2 - Name dbatoolsci_thorcred - Identity dbatoolsci_thor - Password $password
79
- $results.Name | Should Be " dbatoolsci_thorcred "
80
- $results.Identity | Should Be " dbatoolsci_thor "
75
+ $results = New-DbaCredential - SqlInstance $server2 - Name thorcred - Identity thor - Password $password
76
+ $results.Name | Should Be " thorcred "
77
+ $results.Identity | Should Be " thor "
81
78
82
- $results = New-DbaCredential - SqlInstance $server2 - Identity dbatoolsci_thorsmomma - Password $password
83
- $results.Name | Should Be " dbatoolsci_thorsmomma "
84
- $results.Identity | Should Be " dbatoolsci_thorsmomma "
79
+ $results = New-DbaCredential - SqlInstance $server2 - Identity thorsmomma - Password $password
80
+ $results.Name | Should Be " thorsmomma "
81
+ $results.Identity | Should Be " thorsmomma "
85
82
86
83
if ($cryptoProvider ) {
87
- $results = New-DbaCredential - SqlInstance $server2 - Identity dbatoolsci_thor_crypto - Password $password - MappedClassType CryptographicProvider - ProviderName $cryptoProvider
88
- $results.Name | Should Be " dbatoolsci_thor_crypto "
89
- $results.Identity | Should Be " dbatoolsci_thor_crypto "
84
+ $results = New-DbaCredential - SqlInstance $server2 - Identity thor_crypto - Password $password - MappedClassType CryptographicProvider - ProviderName $cryptoProvider
85
+ $results.Name | Should Be " thor_crypto "
86
+ $results.Identity | Should Be " thor_crypto "
90
87
$results.ProviderName | Should - Be $cryptoProvider
91
88
}
92
89
}
93
90
}
94
91
95
92
Context " Copy Credential with the same properties." {
96
93
It " Should copy successfully" {
97
- $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thorcred
94
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name thorcred
98
95
$results.Status | Should Be " Successful"
99
96
}
100
97
101
98
It " Should retain its same properties" {
102
- $Credential1 = Get-DbaCredential - SqlInstance $server2 - Name dbatoolsci_thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
103
- $Credential2 = Get-DbaCredential - SqlInstance $server3 - Name dbatoolsci_thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
99
+ $Credential1 = Get-DbaCredential - SqlInstance $server2 - Name thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
100
+ $Credential2 = Get-DbaCredential - SqlInstance $server3 - Name thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
104
101
105
102
# Compare its value
106
103
$Credential1.Name | Should Be $Credential2.Name
@@ -110,25 +107,25 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
110
107
111
108
Context " No overwrite" {
112
109
It " does not overwrite without force" {
113
- $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thorcred
110
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name thorcred
114
111
$results.Status | Should Be " Skipping"
115
112
}
116
113
}
117
114
118
115
# See https://github.com/dataplat/dbatools/issues/7896 and comments above in BeforeAll
119
116
Context " Crypto provider cred" {
120
117
It - Skip:(-not $cryptoProvider ) " ensure copied credential is using the same crypto provider" {
121
- $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thor_crypto
118
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name thor_crypto
122
119
$results.Status | Should Be Successful
123
- $results = Get-DbaCredential - SqlInstance $server3 - Name dbatoolsci_thor_crypto
124
- $results.Name | Should - Be dbatoolsci_thor_crypto
120
+ $results = Get-DbaCredential - SqlInstance $server3 - Name thor_crypto
121
+ $results.Name | Should - Be thor_crypto
125
122
$results.ProviderName | Should - Be $cryptoProvider
126
123
}
127
124
128
125
It - Skip:(-not $cryptoProvider ) " check warning message if crypto provider is not configured/enabled on destination" {
129
- Remove-DbaCredential - SqlInstance $server3 - Credential dbatoolsci_thor_crypto - Confirm:$false
126
+ Remove-DbaCredential - SqlInstance $server3 - Credential thor_crypto - Confirm:$false
130
127
$server3.Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider DISABLE" )
131
- $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thor_crypto
128
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name thor_crypto
132
129
$server3.Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider ENABLE" )
133
130
$results.Status | Should Be Failed
134
131
$results.Notes | Should -Match " The cryptographic provider $cryptoProvider needs to be configured and enabled on"
0 commit comments