@@ -18,52 +18,52 @@ Tests adding certificates to a Batch account
18
18
#>
19
19
function Test-AddCertificate
20
20
{
21
- param ([string ]$accountName )
22
-
23
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
24
-
25
- # Load certificates so thumbprints can be compared later
26
- $localDir = ($pwd ).Path # Use $pwd to get the local directory. If $pwd is not used, paths are relative to [Environment]::CurrentDirectory, which can be different
27
- $cer2Path = $localDir + " \Resources\BatchTestCert02.cer"
28
- $cer3Path = $localDir + " \Resources\BatchTestCert03.cer"
29
- $pfx4Path = $localDir + " \Resources\BatchTestCert04.pfx"
30
- $pfx5Path = $localDir + " \Resources\BatchTestCert05.pfx"
31
-
32
- $password = " Passw0rd"
33
- $securePassword = ConvertTo-SecureString $password - AsPlainText - Force
34
-
35
- $cer2 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList $cer2Path
36
- $cer3 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList $cer3Path
37
- $pfx4 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList @ ($pfx4Path , $securePassword )
38
- $pfx5 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList @ ($pfx5Path , $securePassword )
39
- $pfx5Bytes = [System.IO.File ]::ReadAllBytes($pfx5Path )
40
-
41
- try
42
- {
43
- # .cer by file path
44
- New-AzureBatchCertificate_ST $cer2Path - BatchContext $context
45
- $cert = Get-AzureBatchCertificate_ST " sha1" $cer2.Thumbprint - BatchContext $context
46
- Assert-AreEqual $cer2.Thumbprint $cert.Thumbprint
47
-
48
- # .cer by raw data
49
- $cer3 | New-AzureBatchCertificate_ST - BatchContext $context
50
- $cert = Get-AzureBatchCertificate_ST " sha1" $cer3.Thumbprint - BatchContext $context
51
- Assert-AreEqual $cer3.Thumbprint $cert.Thumbprint
52
-
53
- # .pfx by file path
54
- New-AzureBatchCertificate_ST $pfx4Path - Password $password - BatchContext $context
55
- $cert = Get-AzureBatchCertificate_ST " sha1" $pfx4.Thumbprint - BatchContext $context
56
- Assert-AreEqual $pfx4.Thumbprint $cert.Thumbprint
57
-
58
- # .pfx by raw data
59
- New-AzureBatchCertificate_ST $pfx5Bytes - Password $password - BatchContext $context
60
- $cert = Get-AzureBatchCertificate_ST " sha1" $pfx4.Thumbprint - BatchContext $context
61
- Assert-AreEqual $pfx4.Thumbprint $cert.Thumbprint
62
- }
63
- finally
64
- {
65
- Get-AzureBatchCertificate_ST - BatchContext $context | Remove-AzureBatchCertificate_ST - Force - BatchContext $context
66
- }
21
+ param ([string ]$accountName )
22
+
23
+ $context = Get-ScenarioTestContext $accountName
24
+
25
+ # Load certificates so thumbprints can be compared later
26
+ $localDir = ($pwd ).Path # Use $pwd to get the local directory. If $pwd is not used, paths are relative to [Environment]::CurrentDirectory, which can be different
27
+ $cer2Path = $localDir + " \Resources\BatchTestCert02.cer"
28
+ $cer3Path = $localDir + " \Resources\BatchTestCert03.cer"
29
+ $pfx4Path = $localDir + " \Resources\BatchTestCert04.pfx"
30
+ $pfx5Path = $localDir + " \Resources\BatchTestCert05.pfx"
31
+
32
+ $password = " Passw0rd"
33
+ $securePassword = ConvertTo-SecureString $password - AsPlainText - Force
34
+
35
+ $cer2 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList $cer2Path
36
+ $cer3 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList $cer3Path
37
+ $pfx4 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList @ ($pfx4Path , $securePassword )
38
+ $pfx5 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 - ArgumentList @ ($pfx5Path , $securePassword )
39
+ $pfx5Bytes = [System.IO.File ]::ReadAllBytes($pfx5Path )
40
+
41
+ try
42
+ {
43
+ # .cer by file path
44
+ New-AzureBatchCertificate $cer2Path - BatchContext $context
45
+ $cert = Get-AzureBatchCertificate " sha1" $cer2.Thumbprint - BatchContext $context
46
+ Assert-AreEqual $cer2.Thumbprint $cert.Thumbprint
47
+
48
+ # .cer by raw data
49
+ $cer3 | New-AzureBatchCertificate - BatchContext $context
50
+ $cert = Get-AzureBatchCertificate " sha1" $cer3.Thumbprint - BatchContext $context
51
+ Assert-AreEqual $cer3.Thumbprint $cert.Thumbprint
52
+
53
+ # .pfx by file path
54
+ New-AzureBatchCertificate $pfx4Path - Password $password - BatchContext $context
55
+ $cert = Get-AzureBatchCertificate " sha1" $pfx4.Thumbprint - BatchContext $context
56
+ Assert-AreEqual $pfx4.Thumbprint $cert.Thumbprint
57
+
58
+ # .pfx by raw data
59
+ New-AzureBatchCertificate $pfx5Bytes - Password $password - BatchContext $context
60
+ $cert = Get-AzureBatchCertificate " sha1" $pfx4.Thumbprint - BatchContext $context
61
+ Assert-AreEqual $pfx4.Thumbprint $cert.Thumbprint
62
+ }
63
+ finally
64
+ {
65
+ Get-AzureBatchCertificate - BatchContext $context | Remove-AzureBatchCertificate - Force - BatchContext $context
66
+ }
67
67
}
68
68
69
69
<#
@@ -72,13 +72,13 @@ Tests querying for a certificate by its thumbprint
72
72
#>
73
73
function Test-GetCertificateByThumbprint
74
74
{
75
- param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
75
+ param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
76
76
77
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
78
- $cert = Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context
77
+ $context = Get-ScenarioTestContext $accountName
78
+ $cert = Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context
79
79
80
- Assert-AreEqual $thumbprint $cert.Thumbprint
81
- Assert-AreEqual $thumbprintAlgorithm $cert.ThumbprintAlgorithm
80
+ Assert-AreEqual $thumbprint $cert.Thumbprint
81
+ Assert-AreEqual $thumbprintAlgorithm $cert.ThumbprintAlgorithm
82
82
}
83
83
84
84
<#
@@ -87,21 +87,21 @@ Tests querying for Batch certs using a filter
87
87
#>
88
88
function Test-ListCertificatesByFilter
89
89
{
90
- param ([string ]$accountName , [string ]$state , [string ]$toDeleteThumbprint , [string ]$matches )
90
+ param ([string ]$accountName , [string ]$state , [string ]$toDeleteThumbprint , [string ]$matches )
91
91
92
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
93
- $filter = " state eq '$state '"
92
+ $context = Get-ScenarioTestContext $accountName
93
+ $filter = " state eq '$state '"
94
94
95
- # Put a cert in the 'deleting' state
96
- Remove-AzureBatchCertificate_ST " sha1" $toDeleteThumbprint - Force - BatchContext $context
95
+ # Put a cert in the 'deleting' state
96
+ Remove-AzureBatchCertificate " sha1" $toDeleteThumbprint - Force - BatchContext $context
97
97
98
- $certs = Get-AzureBatchCertificate_ST - Filter $filter - BatchContext $context
98
+ $certs = Get-AzureBatchCertificate - Filter $filter - BatchContext $context
99
99
100
- Assert-AreEqual $matches $certs.Length
101
- foreach ($cert in $certs )
102
- {
103
- Assert-AreEqual $state $cert.State
104
- }
100
+ Assert-AreEqual $matches $certs.Length
101
+ foreach ($cert in $certs )
102
+ {
103
+ Assert-AreEqual $state $cert.State
104
+ }
105
105
}
106
106
107
107
<#
@@ -110,29 +110,29 @@ Tests querying for Batch certs using a select clause
110
110
#>
111
111
function Test-GetAndListCertificatesWithSelect
112
112
{
113
- param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
113
+ param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
114
114
115
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
116
- $filter = " state eq 'active'"
117
- $selectClause = " thumbprint,state"
115
+ $context = Get-ScenarioTestContext $accountName
116
+ $filter = " state eq 'active'"
117
+ $selectClause = " thumbprint,state"
118
118
119
- # Test with Get cert API
120
- $cert = Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context
121
- Assert-AreNotEqual $null $cert.Url
122
- Assert-AreEqual $thumbprint $cert.Thumbprint
119
+ # Test with Get cert API
120
+ $cert = Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context
121
+ Assert-AreNotEqual $null $cert.Url
122
+ Assert-AreEqual $thumbprint $cert.Thumbprint
123
123
124
- $cert = Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - Select $selectClause - BatchContext $context
125
- Assert-AreEqual $null $cert.Url
126
- Assert-AreEqual $thumbprint $cert.Thumbprint
124
+ $cert = Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - Select $selectClause - BatchContext $context
125
+ Assert-AreEqual $null $cert.Url
126
+ Assert-AreEqual $thumbprint $cert.Thumbprint
127
127
128
- # Test with List certs API
129
- $cert = Get-AzureBatchCertificate_ST - Filter $filter - BatchContext $context
130
- Assert-AreNotEqual $null $cert.Url
131
- Assert-AreEqual $thumbprint $cert.Thumbprint
128
+ # Test with List certs API
129
+ $cert = Get-AzureBatchCertificate - Filter $filter - BatchContext $context
130
+ Assert-AreNotEqual $null $cert.Url
131
+ Assert-AreEqual $thumbprint $cert.Thumbprint
132
132
133
- $cert = Get-AzureBatchCertificate_ST - Filter $filter - Select $selectClause - BatchContext $context
134
- Assert-AreEqual $null $cert.Url
135
- Assert-AreEqual $thumbprint $cert.Thumbprint
133
+ $cert = Get-AzureBatchCertificate - Filter $filter - Select $selectClause - BatchContext $context
134
+ Assert-AreEqual $null $cert.Url
135
+ Assert-AreEqual $thumbprint $cert.Thumbprint
136
136
}
137
137
138
138
<#
@@ -141,12 +141,12 @@ Tests querying for Batch certs and supplying a max count
141
141
#>
142
142
function Test-ListCertificatesWithMaxCount
143
143
{
144
- param ([string ]$accountName , [string ]$maxCount )
144
+ param ([string ]$accountName , [string ]$maxCount )
145
145
146
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
147
- $certs = Get-AzureBatchCertificate_ST - MaxCount $maxCount - BatchContext $context
146
+ $context = Get-ScenarioTestContext $accountName
147
+ $certs = Get-AzureBatchCertificate - MaxCount $maxCount - BatchContext $context
148
148
149
- Assert-AreEqual $maxCount $certs.Length
149
+ Assert-AreEqual $maxCount $certs.Length
150
150
}
151
151
152
152
<#
@@ -155,12 +155,12 @@ Tests querying for all certs under an account
155
155
#>
156
156
function Test-ListAllCertificates
157
157
{
158
- param ([string ]$accountName , [string ]$count )
158
+ param ([string ]$accountName , [string ]$count )
159
159
160
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
161
- $certs = Get-AzureBatchCertificate_ST - BatchContext $context
160
+ $context = Get-ScenarioTestContext $accountName
161
+ $certs = Get-AzureBatchCertificate - BatchContext $context
162
162
163
- Assert-AreEqual $count $certs.Length
163
+ Assert-AreEqual $count $certs.Length
164
164
}
165
165
166
166
<#
@@ -169,21 +169,21 @@ Tests deleting a cert
169
169
#>
170
170
function Test-DeleteCertificate
171
171
{
172
- param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
172
+ param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
173
173
174
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
174
+ $context = Get-ScenarioTestContext $accountName
175
175
176
- # Verify the cert exists
177
- $cert = Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context
178
- Assert-AreEqual $thumbprint $cert.Thumbprint
176
+ # Verify the cert exists
177
+ $cert = Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context
178
+ Assert-AreEqual $thumbprint $cert.Thumbprint
179
179
180
- Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context | Remove-AzureBatchCertificate_ST - Force - BatchContext $context
180
+ Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context | Remove-AzureBatchCertificate - Force - BatchContext $context
181
181
182
- # Verify the cert was deleted. Use the List API since the Get Certificate API will return a 404 if the cert isn't found.
183
- $filter = " state eq 'deleting'"
184
- $cert = Get-AzureBatchCertificate_ST - Filter $filter - BatchContext $context
185
-
186
- Assert-True { $cert -eq $null -or $cert.Thumbprint -eq $thumbprint }
182
+ # Verify the cert was deleted. Use the List API since the Get Certificate API will return a 404 if the cert isn't found.
183
+ $filter = " state eq 'deleting'"
184
+ $cert = Get-AzureBatchCertificate - Filter $filter - BatchContext $context
185
+
186
+ Assert-True { $cert -eq $null -or $cert.Thumbprint -eq $thumbprint }
187
187
}
188
188
189
189
<#
@@ -192,19 +192,19 @@ Tests canceling a cert deletion
192
192
#>
193
193
function Test-TestCancelCertificateDelete
194
194
{
195
- param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
195
+ param ([string ]$accountName , [string ]$thumbprintAlgorithm , [string ]$thumbprint )
196
196
197
- $context = Get-AzureRmBatchAccountKeys - Name $accountName
197
+ $context = Get-ScenarioTestContext $accountName
198
198
199
- # Verify the cert is in the deletefailed state
200
- $cert = Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context
201
- Assert-AreEqual ' deletefailed' $cert.State.ToString ().ToLower()
199
+ # Verify the cert is in the deletefailed state
200
+ $cert = Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context
201
+ Assert-AreEqual ' deletefailed' $cert.State.ToString ().ToLower()
202
202
203
- Get-AzureBatchCertificate_ST $thumbprintAlgorithm $thumbprint - BatchContext $context | Stop-AzureBatchCertificateDeletion_ST - BatchContext $context
203
+ Get-AzureBatchCertificate $thumbprintAlgorithm $thumbprint - BatchContext $context | Stop-AzureBatchCertificateDeletion - BatchContext $context
204
204
205
- # Verify the cert went back to the active state
206
- $filter = " state eq 'active'"
207
- $cert = Get-AzureBatchCertificate_ST - Filter $filter - BatchContext $context
208
-
209
- Assert-AreEqual $thumbprint $cert.Thumbprint
205
+ # Verify the cert went back to the active state
206
+ $filter = " state eq 'active'"
207
+ $cert = Get-AzureBatchCertificate - Filter $filter - BatchContext $context
208
+
209
+ Assert-AreEqual $thumbprint $cert.Thumbprint
210
210
}
0 commit comments