11
11
# See the License for the specific language governing permissions and
12
12
# limitations under the License.
13
13
# ----------------------------------------------------------------------------------
14
-
15
- # A managed instance can be provisioned using instructions here https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance-get-started
16
- # currently this takes about 2-3 hours
17
- $mangedInstanceRg = " BenjinResourceGroup"
18
- $managedInstanceName = " benjinmitest"
19
- $keyVaultName = " mitest-eus-doNotDelete"
20
- $keyName = " mitest-key"
21
- $keyId = " https://mitest-eus-donotdelete.vault.azure.net/keys/mitest-key/6dc78e98a3274d87bd847436dd34045e"
22
- $keyVersion = " 6dc78e98a3274d87bd847436dd34045e"
23
- $tdeKeyName = $keyVaultName + " _" + $keyName + " _" + $keyVersion
24
-
25
14
26
15
<#
27
16
. SYNOPSIS
28
17
Tests for managing TDE keyVaultKey in managed instance for continuous validation
29
18
#>
30
19
function Test-ManagedInstanceKeyVaultKeyCI
31
20
{
32
-
33
- $managedInstance = Get-AzSqlInstance - Name $managedInstanceName - ResourceGroupName $mangedInstanceRg
21
+ $params = Get-SqlServerKeyVaultKeyTestEnvironmentParameters
22
+ $managedInstance = Get-ManagedInstanceForTdeTest $params
23
+ $mangedInstanceRg = $managedInstance.ResourceGroupName
24
+ $managedInstanceName = $managedInstance.ManagedInstanceName
34
25
$managedInstanceResourceId = $managedInstance.Id
35
26
36
27
# Test Add
37
- $keyResult = Add-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $keyId
28
+ $keyResult = Add-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $params . keyId
38
29
39
- Assert-AreEqual $keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
40
- Assert-AreEqual $tdeKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
30
+ Assert-AreEqual $params . keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
31
+ Assert-AreEqual $params .serverKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
41
32
42
33
43
34
# Test Get
44
- $keyResult2 = $managedInstance | Get-AzSqlInstanceKeyVaultKey - KeyId $keyId
35
+ $keyResult2 = $managedInstance | Get-AzSqlInstanceKeyVaultKey - KeyId $params . keyId
45
36
46
- Assert-AreEqual $keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
47
- Assert-AreEqual $tdeKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
37
+ Assert-AreEqual $params . keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
38
+ Assert-AreEqual $params .serverKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
48
39
49
40
# Test List
50
41
$keyResults = Get-AzSqlInstanceKeyVaultKey - InstanceResourceId $managedInstanceResourceId
@@ -57,18 +48,23 @@ function Test-ManagedInstanceKeyVaultKeyCI
57
48
#>
58
49
function Test-ManagedInstanceKeyVaultKey
59
50
{
51
+ $params = Get-SqlServerKeyVaultKeyTestEnvironmentParameters
52
+ $managedInstance = Get-ManagedInstanceForTdeTest $params
53
+ $mangedInstanceRg = $managedInstance.ResourceGroupName
54
+ $managedInstanceName = $managedInstance.ManagedInstanceName
55
+
60
56
# Test Add
61
- $keyResult = Add-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $keyId
57
+ $keyResult = Add-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $params . keyId
62
58
63
- Assert-AreEqual $keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
64
- Assert-AreEqual $tdeKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
59
+ Assert-AreEqual $params . keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
60
+ Assert-AreEqual $params .serverKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
65
61
66
62
67
63
# Test Get
68
- $keyResult2 = Get-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $keyId
64
+ $keyResult2 = Get-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName - KeyId $params . keyId
69
65
70
- Assert-AreEqual $keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
71
- Assert-AreEqual $tdeKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
66
+ Assert-AreEqual $params . keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
67
+ Assert-AreEqual $params .serverKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
72
68
73
69
# Test List
74
70
$keyResults = Get-AzSqlInstanceKeyVaultKey - ResourceGroupName $mangedInstanceRg - InstanceName $managedInstanceName
@@ -82,20 +78,23 @@ function Test-ManagedInstanceKeyVaultKey
82
78
#>
83
79
function Test-ManagedInstanceKeyVaultKeyInputObject
84
80
{
85
- $managedInstance = Get-AzSqlInstance - Name $managedInstanceName - ResourceGroupName $mangedInstanceRg
81
+ $params = Get-SqlServerKeyVaultKeyTestEnvironmentParameters
82
+ $managedInstance = Get-ManagedInstanceForTdeTest $params
83
+ $mangedInstanceRg = $managedInstance.ResourceGroupName
84
+ $managedInstanceName = $managedInstance.ManagedInstanceName
86
85
87
86
# Test Add
88
- $keyResult = Add-AzSqlInstanceKeyVaultKey - Instance $managedInstance - KeyId $keyId
87
+ $keyResult = Add-AzSqlInstanceKeyVaultKey - Instance $managedInstance - KeyId $params . keyId
89
88
90
- Assert-AreEqual $keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
91
- Assert-AreEqual $tdeKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
89
+ Assert-AreEqual $params . keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
90
+ Assert-AreEqual $params .serverKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
92
91
93
92
94
93
# Test Get
95
- $keyResult2 = Get-AzSqlInstanceKeyVaultKey - Instance $managedInstance - KeyId $keyId
94
+ $keyResult2 = Get-AzSqlInstanceKeyVaultKey - Instance $managedInstance - KeyId $params . keyId
96
95
97
- Assert-AreEqual $keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
98
- Assert-AreEqual $tdeKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
96
+ Assert-AreEqual $params . keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
97
+ Assert-AreEqual $params .serverKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
99
98
100
99
101
100
# Test List
@@ -111,21 +110,24 @@ function Test-ManagedInstanceKeyVaultKeyInputObject
111
110
#>
112
111
function Test-ManagedInstanceKeyVaultKeyResourceId
113
112
{
114
- $managedInstance = Get-AzSqlInstance - Name $managedInstanceName - ResourceGroupName $mangedInstanceRg
113
+ $params = Get-SqlServerKeyVaultKeyTestEnvironmentParameters
114
+ $managedInstance = Get-ManagedInstanceForTdeTest $params
115
+ $mangedInstanceRg = $managedInstance.ResourceGroupName
116
+ $managedInstanceName = $managedInstance.ManagedInstanceName
115
117
$managedInstanceResourceId = $managedInstance.Id
116
118
117
119
# Test Add
118
- $keyResult = Add-AzSqlInstanceKeyVaultKey - InstanceResourceId $managedInstanceResourceId - KeyId $keyId
120
+ $keyResult = Add-AzSqlInstanceKeyVaultKey - InstanceResourceId $managedInstanceResourceId - KeyId $params . keyId
119
121
120
- Assert-AreEqual $keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
121
- Assert-AreEqual $tdeKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
122
+ Assert-AreEqual $params . keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
123
+ Assert-AreEqual $params .serverKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
122
124
123
125
124
126
# Test Get
125
- $keyResult2 = Get-AzSqlInstanceKeyVaultKey - InstanceResourceId $managedInstanceResourceId - KeyId $keyId
127
+ $keyResult2 = Get-AzSqlInstanceKeyVaultKey - InstanceResourceId $managedInstanceResourceId - KeyId $params . keyId
126
128
127
- Assert-AreEqual $keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
128
- Assert-AreEqual $tdeKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
129
+ Assert-AreEqual $params . keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
130
+ Assert-AreEqual $params .serverKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
129
131
130
132
131
133
# Test List
@@ -141,20 +143,23 @@ function Test-ManagedInstanceKeyVaultKeyResourceId
141
143
#>
142
144
function Test-ManagedInstanceKeyVaultKeyPiping
143
145
{
144
- $managedInstance = Get-AzSqlInstance - Name $managedInstanceName - ResourceGroupName $mangedInstanceRg
146
+ $params = Get-SqlServerKeyVaultKeyTestEnvironmentParameters
147
+ $managedInstance = Get-ManagedInstanceForTdeTest $params
148
+ $mangedInstanceRg = $managedInstance.ResourceGroupName
149
+ $managedInstanceName = $managedInstance.ManagedInstanceName
145
150
146
151
# Test Add
147
- $keyResult = $managedInstance | Add-AzSqlInstanceKeyVaultKey - KeyId $keyId
152
+ $keyResult = $managedInstance | Add-AzSqlInstanceKeyVaultKey - KeyId $params . keyId
148
153
149
- Assert-AreEqual $keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
150
- Assert-AreEqual $tdeKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
154
+ Assert-AreEqual $params . keyId $keyResult.KeyId " KeyId mismatch after calling Add-AzSqlInstanceKeyVaultKey"
155
+ Assert-AreEqual $params .serverKeyName $keyResult.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Add-AzSqlInstanceKeyVaultKey"
151
156
152
157
153
158
# Test Get
154
- $keyResult2 = $managedInstance | Get-AzSqlInstanceKeyVaultKey - KeyId $keyId
159
+ $keyResult2 = $managedInstance | Get-AzSqlInstanceKeyVaultKey - KeyId $params . keyId
155
160
156
- Assert-AreEqual $keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
157
- Assert-AreEqual $tdeKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
161
+ Assert-AreEqual $params . keyId $keyResult2.KeyId " KeyId mismatch after calling Get-AzSqlInstanceKeyVaultKey"
162
+ Assert-AreEqual $params .serverKeyName $keyResult2.ManagedInstanceKeyName " ManagedInstanceKeyName mismatch after calling Get-AzSqlInstanceKeyVaultKey"
158
163
159
164
160
165
# Test List
0 commit comments