Skip to content

Commit 3deccd0

Browse files
authored
Change [Test] to [RecordedTest] for Key Vault (Azure#28812)
Also ignores 409 errors for user-triggered restore operations still in progress.
1 parent f1656f6 commit 3deccd0

File tree

10 files changed

+127
-122
lines changed

10 files changed

+127
-122
lines changed

sdk/keyvault/Azure.Security.KeyVault.Certificates/tests/CertificateClientLiveTests.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void ClearChallengeCacheforRecord()
6868
}
6969
}
7070

71-
[Test]
71+
[RecordedTest]
7272
public void StartCreateCertificateError()
7373
{
7474
string certName = Recording.GenerateId();
@@ -85,7 +85,7 @@ public void StartCreateCertificateError()
8585
Assert.AreEqual(400, ex.Status);
8686
}
8787

88-
[Test]
88+
[RecordedTest]
8989
public async Task VerifyGetCertificateOperation()
9090
{
9191
string certName = Recording.GenerateId();
@@ -103,7 +103,7 @@ public async Task VerifyGetCertificateOperation()
103103
Assert.IsNotNull(getOperation);
104104
}
105105

106-
[Test]
106+
[RecordedTest]
107107
public async Task VerifyCancelCertificateOperation()
108108
{
109109
string certName = Recording.GenerateId();
@@ -145,7 +145,7 @@ public async Task VerifyCancelCertificateOperation()
145145
Assert.AreEqual(200, operation.GetRawResponse().Status);
146146
}
147147

148-
[Test]
148+
[RecordedTest]
149149
public async Task VerifyUnexpectedCancelCertificateOperation()
150150
{
151151
string certName = Recording.GenerateId();
@@ -189,7 +189,7 @@ public async Task VerifyUnexpectedCancelCertificateOperation()
189189
Assert.AreEqual(200, operation.GetRawResponse().Status);
190190
}
191191

192-
[Test]
192+
[RecordedTest]
193193
public async Task VerifyDeleteCertificateOperation()
194194
{
195195
string certName = Recording.GenerateId();
@@ -212,7 +212,7 @@ public async Task VerifyDeleteCertificateOperation()
212212
Assert.AreEqual(404, operation.GetRawResponse().Status);
213213
}
214214

215-
[Test]
215+
[RecordedTest]
216216
public async Task VerifyUnexpectedDeleteCertificateOperation()
217217
{
218218
string certName = Recording.GenerateId();
@@ -243,7 +243,7 @@ public async Task VerifyUnexpectedDeleteCertificateOperation()
243243
Assert.AreEqual(404, operation.GetRawResponse().Status);
244244
}
245245

246-
[Test]
246+
[RecordedTest]
247247
public async Task VerifyCertificateOperationError()
248248
{
249249
string issuerName = Recording.GenerateId();
@@ -294,7 +294,7 @@ public async Task VerifyCertificateOperationError()
294294
}
295295
}
296296

297-
[Test]
297+
[RecordedTest]
298298
public async Task VerifyCertificateGetWithPolicyInProgress()
299299
{
300300
string certName = Recording.GenerateId();
@@ -321,7 +321,7 @@ public async Task VerifyCertificateGetWithPolicyInProgress()
321321
Assert.AreEqual(certificate.Name, certName);
322322
}
323323

324-
[Test]
324+
[RecordedTest]
325325
public async Task VerifyGetCertificateCompleted()
326326
{
327327
string certName = Recording.GenerateId();
@@ -347,7 +347,7 @@ public async Task VerifyGetCertificateCompleted()
347347
Assert.AreEqual(certificate.Name, certName);
348348
}
349349

350-
[Test]
350+
[RecordedTest]
351351
public async Task VerifyGetCertificateCompletedSubsequently()
352352
{
353353
string certName = Recording.GenerateId();
@@ -374,7 +374,7 @@ public async Task VerifyGetCertificateCompletedSubsequently()
374374
Assert.NotNull(certificateWithPolicy.Properties.Version);
375375
}
376376

377-
[Test]
377+
[RecordedTest]
378378
public async Task VerifyUpdateCertificate()
379379
{
380380
string certName = Recording.GenerateId();
@@ -402,7 +402,7 @@ public async Task VerifyUpdateCertificate()
402402
CollectionAssert.AreEqual(expTags, updated.Properties.Tags);
403403
}
404404

405-
[Test]
405+
[RecordedTest]
406406
public async Task VerifyDeleteRecoverPurge()
407407
{
408408
string certName = Recording.GenerateId();
@@ -442,7 +442,7 @@ public async Task VerifyDeleteRecoverPurge()
442442
await WaitForPurgedCertificate(certName);
443443
}
444444

445-
[Test]
445+
[RecordedTest]
446446
public async Task VerifyImportCertificatePem()
447447
{
448448
string certificateName = Recording.GenerateId();
@@ -465,7 +465,7 @@ public async Task VerifyImportCertificatePem()
465465
Assert.AreEqual("azuresdk@microsoft.com", cert.Policy.SubjectAlternativeNames?.Emails?[0]);
466466
}
467467

468-
[Test]
468+
[RecordedTest]
469469
public async Task VerifyImportCertificatePemWithoutIssuer()
470470
{
471471
string certificateName = Recording.GenerateId();
@@ -495,7 +495,7 @@ public async Task VerifyImportCertificatePemWithoutIssuer()
495495
Assert.AreEqual("azuresdk@microsoft.com", cert.Policy.SubjectAlternativeNames?.Emails?[0]);
496496
}
497497

498-
[Test]
498+
[RecordedTest]
499499
public async Task VerifyImportCertificatePfx()
500500
{
501501
string caCertificateName = Recording.GenerateId();
@@ -516,7 +516,7 @@ public async Task VerifyImportCertificatePfx()
516516
CollectionAssert.AreEqual(pubBytes, cert.Cer);
517517
}
518518

519-
[Test]
519+
[RecordedTest]
520520
public async Task ValidateMergeCertificate()
521521
{
522522
string serverCertificateName = Recording.GenerateId();
@@ -583,7 +583,7 @@ public async Task ValidateMergeCertificate()
583583
CollectionAssert.AreEqual(mergedServerCertificate.Cer, completedServerCertificate.Cer);
584584
}
585585

586-
[Test]
586+
[RecordedTest]
587587
public async Task VerifyGetIssuer()
588588
{
589589
string issuerName = Recording.GenerateId();
@@ -618,7 +618,7 @@ public async Task VerifyGetIssuer()
618618
// Assert.AreEqual(issuer.Name, getIssuer.Name);
619619
}
620620

621-
[Test]
621+
[RecordedTest]
622622
public async Task VerifyUpdateIssuer()
623623
{
624624
string issuerName = Recording.GenerateId();
@@ -642,7 +642,7 @@ public async Task VerifyUpdateIssuer()
642642
Assert.AreEqual(updateProvider, updateIssuer.Provider);
643643
}
644644

645-
[Test]
645+
[RecordedTest]
646646
public async Task VerifyGetPropertiesOfIssuersAsync()
647647
{
648648
string issuerName = Recording.GenerateId();
@@ -673,7 +673,7 @@ public async Task VerifyGetPropertiesOfIssuersAsync()
673673
}
674674
}
675675

676-
[Test]
676+
[RecordedTest]
677677
public async Task VerifyGetContacts()
678678
{
679679
IList<CertificateContact> contacts = new List<CertificateContact>();
@@ -710,7 +710,7 @@ public async Task VerifyGetContacts()
710710
}
711711
}
712712

713-
[Test]
713+
[RecordedTest]
714714
public async Task VerifyGetCertificatePolicy()
715715
{
716716
string certName = Recording.GenerateId();
@@ -733,7 +733,7 @@ public async Task VerifyGetCertificatePolicy()
733733
Assert.AreEqual(DefaultPolicy.ReuseKey, policy.ReuseKey);
734734
}
735735

736-
[Test]
736+
[RecordedTest]
737737
public async Task VerifyUpdateCertificatePolicy()
738738
{
739739
string certName = Recording.GenerateId();
@@ -901,7 +901,7 @@ public async Task DownloadNonExportableCertificate(string contentType)
901901
Assert.IsFalse(x509certificate.HasPrivateKey);
902902
}
903903

904-
[Test]
904+
[RecordedTest]
905905
public async Task DownloadECDsaCertificateSignRemoteVerifyLocal([EnumValues] CertificateContentType contentType, [EnumValues] CertificateKeyCurveName keyCurveName)
906906
{
907907
#if NET461
@@ -958,7 +958,7 @@ public async Task DownloadECDsaCertificateSignRemoteVerifyLocal([EnumValues] Cer
958958
}
959959
}
960960

961-
[Test]
961+
[RecordedTest]
962962
public async Task DownloadECDsaCertificateSignLocalVerifyRemote([EnumValues] CertificateContentType contentType, [EnumValues] CertificateKeyCurveName keyCurveName)
963963
{
964964
#if NET461

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/CryptographyClientLiveTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected CryptographyClientLiveTests(bool isAsync, KeyClientOptions.ServiceVers
3030
CompareBodies = false;
3131
}
3232

33-
[Test]
33+
[RecordedTest]
3434
public async Task EncryptDecryptRoundTrip([EnumValues(nameof(EncryptionAlgorithm.Rsa15), nameof(EncryptionAlgorithm.RsaOaep), nameof(EncryptionAlgorithm.RsaOaep256))]EncryptionAlgorithm algorithm)
3535
{
3636
KeyVaultKey key = await CreateTestKey(algorithm);
@@ -56,7 +56,7 @@ public async Task EncryptDecryptRoundTrip([EnumValues(nameof(EncryptionAlgorithm
5656
CollectionAssert.AreEqual(data, decResult.Plaintext);
5757
}
5858

59-
[Test]
59+
[RecordedTest]
6060
public async Task WrapUnwrapRoundTrip([EnumValues(Exclude = new[] { nameof(KeyWrapAlgorithm.A128KW), nameof(KeyWrapAlgorithm.A192KW), nameof(KeyWrapAlgorithm.A256KW) })]KeyWrapAlgorithm algorithm)
6161
{
6262
KeyVaultKey key = await CreateTestKey(algorithm);
@@ -82,7 +82,7 @@ public async Task WrapUnwrapRoundTrip([EnumValues(Exclude = new[] { nameof(KeyWr
8282
CollectionAssert.AreEqual(data, decResult.Key);
8383
}
8484

85-
[Test]
85+
[RecordedTest]
8686
public async Task SignVerifyDataRoundTrip([EnumValues]SignatureAlgorithm algorithm)
8787
{
8888
KeyVaultKey key = await CreateTestKey(algorithm);
@@ -124,7 +124,7 @@ public async Task SignVerifyDataRoundTrip([EnumValues]SignatureAlgorithm algorit
124124
Assert.True(verifyResult.IsValid);
125125
}
126126

127-
[Test]
127+
[RecordedTest]
128128
public async Task SignVerifyDataStreamRoundTrip([EnumValues]SignatureAlgorithm algorithm)
129129
{
130130
KeyVaultKey key = await CreateTestKey(algorithm);
@@ -174,7 +174,7 @@ public async Task SignVerifyDataStreamRoundTrip([EnumValues]SignatureAlgorithm a
174174

175175
// We do not test using ES256K below since macOS doesn't support it; various ideas to work around that adversely affect runtime code too much.
176176

177-
[Test]
177+
[RecordedTest]
178178
public async Task LocalSignVerifyRoundTrip([EnumValues(Exclude = new[] { nameof(SignatureAlgorithm.ES256K) })]SignatureAlgorithm algorithm)
179179
{
180180
#if NET461
@@ -217,7 +217,7 @@ public async Task LocalSignVerifyRoundTrip([EnumValues(Exclude = new[] { nameof(
217217
Assert.IsTrue(verifyResult.IsValid);
218218
}
219219

220-
[Test]
220+
[RecordedTest]
221221
public async Task LocalSignVerifyRoundTripOnFramework([EnumValues(nameof(SignatureAlgorithm.PS256), nameof(SignatureAlgorithm.PS384), nameof(SignatureAlgorithm.PS512))]SignatureAlgorithm algorithm)
222222
{
223223
#if !NETFRAMEWORK
@@ -251,7 +251,7 @@ public async Task LocalSignVerifyRoundTripOnFramework([EnumValues(nameof(Signatu
251251
Assert.IsTrue(verifyResult.IsValid);
252252
}
253253

254-
[Test]
254+
[RecordedTest]
255255
public async Task SignLocalVerifyRoundTrip([EnumValues(Exclude = new[] { nameof(SignatureAlgorithm.ES256K) })]SignatureAlgorithm algorithm)
256256
{
257257
#if NET461
@@ -294,7 +294,7 @@ public async Task SignLocalVerifyRoundTrip([EnumValues(Exclude = new[] { nameof(
294294
Assert.IsTrue(verifyResult.IsValid);
295295
}
296296

297-
[Test]
297+
[RecordedTest]
298298
public async Task SignLocalVerifyRoundTripFramework([EnumValues(nameof(SignatureAlgorithm.PS256), nameof(SignatureAlgorithm.PS384), nameof(SignatureAlgorithm.PS512))]SignatureAlgorithm algorithm)
299299
{
300300
#if !NETFRAMEWORK
@@ -328,7 +328,7 @@ public async Task SignLocalVerifyRoundTripFramework([EnumValues(nameof(Signature
328328
Assert.IsTrue(verifyResult.IsValid);
329329
}
330330

331-
[Test]
331+
[RecordedTest]
332332
public async Task EncryptLocalDecryptOnKeyVault([EnumValues(nameof(EncryptionAlgorithm.Rsa15), nameof(EncryptionAlgorithm.RsaOaep), nameof(EncryptionAlgorithm.RsaOaep256))] EncryptionAlgorithm algorithm)
333333
{
334334
KeyVaultKey key = await CreateTestKey(algorithm);
@@ -355,7 +355,7 @@ public async Task EncryptLocalDecryptOnKeyVault([EnumValues(nameof(EncryptionAlg
355355
CollectionAssert.AreEqual(plaintext, decrypted.Plaintext);
356356
}
357357

358-
[Test]
358+
[RecordedTest]
359359
public async Task EncryptDecryptFromKeyClient()
360360
{
361361
KeyVaultKey key = await CreateTestKey(EncryptionAlgorithm.RsaOaep);
@@ -371,7 +371,7 @@ public async Task EncryptDecryptFromKeyClient()
371371
Assert.AreEqual(plaintext, decryptResult.Plaintext);
372372
}
373373

374-
[Test]
374+
[RecordedTest]
375375
public async Task EncryptWithKeyNameReturnsFullKeyId()
376376
{
377377
KeyVaultKey key = await CreateTestKey(EncryptionAlgorithm.RsaOaep);

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/KeyClientLiveTests.KeyRotation.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Azure.Security.KeyVault.Keys.Tests
1111
{
1212
public partial class KeyClientLiveTests
1313
{
14-
[Test]
14+
[RecordedTest]
1515
[KeyVaultOnly]
1616
[ServiceVersion(Min = KeyClientOptions.ServiceVersion.V7_3)]
1717
public async Task GetKeyRotationPolicyReturnsDefault()
@@ -25,7 +25,7 @@ public async Task GetKeyRotationPolicyReturnsDefault()
2525
Assert.That(policy.LifetimeActions, Has.One.Matches<KeyRotationLifetimeAction>(action => action.Action == KeyRotationPolicyAction.Notify));
2626
}
2727

28-
[Test]
28+
[RecordedTest]
2929
[KeyVaultOnly]
3030
[ServiceVersion(Min = KeyClientOptions.ServiceVersion.V7_3)]
3131
public void GetKeyRotationPolicyThrowsForMissingKey()
@@ -38,7 +38,7 @@ public void GetKeyRotationPolicyThrowsForMissingKey()
3838
Assert.AreEqual("KeyNotFound", ex.ErrorCode);
3939
}
4040

41-
[Test]
41+
[RecordedTest]
4242
[KeyVaultOnly]
4343
[ServiceVersion(Min = KeyClientOptions.ServiceVersion.V7_3)]
4444
public async Task RotateKeyCreatesNewVersion()
@@ -55,7 +55,7 @@ public async Task RotateKeyCreatesNewVersion()
5555
Assert.AreNotEqual(key.Key.N, rotatedKey.Key.N);
5656
}
5757

58-
[Test]
58+
[RecordedTest]
5959
[KeyVaultOnly]
6060
[ServiceVersion(Min = KeyClientOptions.ServiceVersion.V7_3)]
6161
public async Task UpdateKeyRotationPolicy()
@@ -90,7 +90,7 @@ public async Task UpdateKeyRotationPolicy()
9090
Assert.AreEqual(policy.LifetimeActions[0].TimeBeforeExpiry, rotateAction.TimeBeforeExpiry);
9191
}
9292

93-
[Test]
93+
[RecordedTest]
9494
[KeyVaultOnly]
9595
[ServiceVersion(Min = KeyClientOptions.ServiceVersion.V7_3)]
9696
public void UpdateKeyRotationPolicyThrowsForMissingKey()

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/KeyClientLiveTests.SecureKeyRelease.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Azure.Security.KeyVault.Keys.Tests
1313
{
1414
public partial class KeyClientLiveTests
1515
{
16-
[Test]
16+
[RecordedTest]
1717
[IgnoreServiceError(403, "Forbidden", Message = "Target environment attestation statement cannot be verified.")] // TODO: Remove once the attestation issue is resolved: https://github.com/Azure/azure-sdk-for-net/issues/27957
1818
[IgnoreServiceError(400, "BadParameter")] // TODO: Remove once SKR is deployed to sovereign clouds.
1919
[PremiumOnly]
@@ -41,7 +41,7 @@ public async Task ReleaseCreatedKey()
4141
Assert.AreEqual(JsonValueKind.String, keyElement.GetProperty("key_hsm").ValueKind);
4242
}
4343

44-
[Test]
44+
[RecordedTest]
4545
[IgnoreServiceError(403, "Forbidden", Message = "Target environment attestation statement cannot be verified.")] // TODO: Remove once the attestation issue is resolved: https://github.com/Azure/azure-sdk-for-net/issues/27957
4646
[IgnoreServiceError(400, "BadParameter")] // TODO: Remove once SKR is deployed to sovereign clouds.
4747
[PremiumOnly]
@@ -79,7 +79,7 @@ public async Task ReleaseUpdatedKey()
7979
Assert.AreEqual("BadParameter", ex.ErrorCode);
8080
}
8181

82-
[Test]
82+
[RecordedTest]
8383
[IgnoreServiceError(403, "Forbidden", Message = "Target environment attestation statement cannot be verified.")] // TODO: Remove once the attestation issue is resolved: https://github.com/Azure/azure-sdk-for-net/issues/27957
8484
[IgnoreServiceError(400, "BadParameter")] // TODO: Remove once SKR is deployed to sovereign clouds.
8585
[PremiumOnly]

0 commit comments

Comments
 (0)