@@ -20,8 +20,8 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
20
20
$plaintext = " BigOlPassword!"
21
21
$password = ConvertTo-SecureString $plaintext - AsPlainText - Force
22
22
23
- $instance2 = Connect-DbaInstance - SqlInstance $script :instance2
24
- $instance3 = Connect-DbaInstance - SqlInstance $script :instance3
23
+ $server2 = Connect-DbaInstance - SqlInstance $script :instance2
24
+ $server3 = Connect-DbaInstance - SqlInstance $script :instance3
25
25
26
26
# Add user
27
27
foreach ($login in $logins ) {
@@ -58,14 +58,14 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
58
58
#>
59
59
60
60
# check to see if a crypto provider is present on the instances
61
- $instance2CryptoProviders = $instance2 .Query (" SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name" )
62
- $instance3CryptoProviders = $instance3 .Query (" SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name" )
61
+ $instance2CryptoProviders = $server2 .Query (" SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name" )
62
+ $instance3CryptoProviders = $server3 .Query (" SELECT name FROM sys.cryptographic_providers WHERE is_enabled = 1 ORDER BY name" )
63
63
64
64
$cryptoProvider = ($instance2CryptoProviders | Where-Object { $_.name -eq $instance3CryptoProviders.name } | Select-Object - First 1 ).name
65
65
}
66
66
AfterAll {
67
- (Get-DbaCredential - SqlInstance $instance2 - Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto - ErrorAction Stop - WarningAction SilentlyContinue).Drop()
68
- (Get-DbaCredential - SqlInstance $instance3 - Identity dbatoolsci_thor, dbatoolsci_thorsmomma, dbatoolsci_thor_crypto - ErrorAction Stop - WarningAction SilentlyContinue).Drop()
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()
69
69
70
70
foreach ($login in $logins ) {
71
71
$null = Invoke-Command2 - ScriptBlock { net user $args / delete * > & 1 } - ArgumentList $login - ComputerName $script :instance2
@@ -75,16 +75,16 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
75
75
76
76
Context " Create new credential" {
77
77
It " Should create new credentials with the proper properties" {
78
- $results = New-DbaCredential - SqlInstance $instance2 - Name dbatoolsci_thorcred - Identity dbatoolsci_thor - Password $password
78
+ $results = New-DbaCredential - SqlInstance $server2 - Name dbatoolsci_thorcred - Identity dbatoolsci_thor - Password $password
79
79
$results.Name | Should Be " dbatoolsci_thorcred"
80
80
$results.Identity | Should Be " dbatoolsci_thor"
81
81
82
- $results = New-DbaCredential - SqlInstance $instance2 - Identity dbatoolsci_thorsmomma - Password $password
82
+ $results = New-DbaCredential - SqlInstance $server2 - Identity dbatoolsci_thorsmomma - Password $password
83
83
$results.Name | Should Be " dbatoolsci_thorsmomma"
84
84
$results.Identity | Should Be " dbatoolsci_thorsmomma"
85
85
86
86
if ($cryptoProvider ) {
87
- $results = New-DbaCredential - SqlInstance $instance2 - Identity dbatoolsci_thor_crypto - Password $password - MappedClassType CryptographicProvider - ProviderName $cryptoProvider
87
+ $results = New-DbaCredential - SqlInstance $server2 - Identity dbatoolsci_thor_crypto - Password $password - MappedClassType CryptographicProvider - ProviderName $cryptoProvider
88
88
$results.Name | Should Be " dbatoolsci_thor_crypto"
89
89
$results.Identity | Should Be " dbatoolsci_thor_crypto"
90
90
$results.ProviderName | Should - Be $cryptoProvider
@@ -94,13 +94,13 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
94
94
95
95
Context " Copy Credential with the same properties." {
96
96
It " Should copy successfully" {
97
- $results = Copy-DbaCredential - Source $instance2 - Destination $instance3 - Name dbatoolsci_thorcred
97
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thorcred
98
98
$results.Status | Should Be " Successful"
99
99
}
100
100
101
101
It " Should retain its same properties" {
102
- $Credential1 = Get-DbaCredential - SqlInstance $instance2 - Name dbatoolsci_thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
103
- $Credential2 = Get-DbaCredential - SqlInstance $instance3 - Name dbatoolsci_thor - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
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
104
104
105
105
# Compare its value
106
106
$Credential1.Name | Should Be $Credential2.Name
@@ -110,26 +110,26 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
110
110
111
111
Context " No overwrite" {
112
112
It " does not overwrite without force" {
113
- $results = Copy-DbaCredential - Source $instance2 - Destination $instance3 - Name dbatoolsci_thorcred
113
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thorcred
114
114
$results.Status | Should Be " Skipping"
115
115
}
116
116
}
117
117
118
118
# See https://github.com/dataplat/dbatools/issues/7896 and comments above in BeforeAll
119
119
Context " Crypto provider cred" {
120
120
It - Skip:(-not $cryptoProvider ) " ensure copied credential is using the same crypto provider" {
121
- $results = Copy-DbaCredential - Source $instance2 - Destination $instance3 - Name dbatoolsci_thor_crypto
121
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thor_crypto
122
122
$results.Status | Should Be Successful
123
- $results = Get-DbaCredential - SqlInstance $instance3 - Name dbatoolsci_thor_crypto
123
+ $results = Get-DbaCredential - SqlInstance $server3 - Name dbatoolsci_thor_crypto
124
124
$results.Name | Should - Be dbatoolsci_thor_crypto
125
125
$results.ProviderName | Should - Be $cryptoProvider
126
126
}
127
127
128
128
It - Skip:(-not $cryptoProvider ) " check warning message if crypto provider is not configured/enabled on destination" {
129
- Remove-DbaCredential - SqlInstance $instance3 - Credential dbatoolsci_thor_crypto - Confirm:$false
130
- $instance3 .Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider DISABLE" )
131
- $results = Copy-DbaCredential - Source $instance2 - Destination $instance3 - Name dbatoolsci_thor_crypto
132
- $instance3 .Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider ENABLE" )
129
+ Remove-DbaCredential - SqlInstance $server3 - Credential dbatoolsci_thor_crypto - Confirm:$false
130
+ $server3 .Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider DISABLE" )
131
+ $results = Copy-DbaCredential - Source $server2 - Destination $server3 - Name dbatoolsci_thor_crypto
132
+ $server3 .Query (" ALTER CRYPTOGRAPHIC PROVIDER $cryptoProvider ENABLE" )
133
133
$results.Status | Should Be Failed
134
134
$results.Notes | Should -Match " The cryptographic provider $cryptoProvider needs to be configured and enabled on"
135
135
}
0 commit comments