Skip to content

Commit 9af1b54

Browse files
committed
Fixed tests
1 parent c322e46 commit 9af1b54

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,8 @@ public void ExternalKeyVaultTest(
14331433
[ParameterAttributeData]
14341434
public async Task KmsRetryTest(
14351435
[Values("aws", "azure", "gcp")] string kmsProvider,
1436-
[Values("network", "http")] string failureType)
1436+
[Values("network", "http")] string failureType,
1437+
[Values(false, true)] bool async)
14371438
{
14381439
RequireServer.Check().Supports(Feature.ClientSideEncryption);
14391440
RequireEnvironment.Check().EnvironmentVariable("KMS_MOCK_SERVERS_ENABLED", isDefined: true);
@@ -1478,22 +1479,49 @@ public async Task KmsRetryTest(
14781479
await SetFailure(failureType, 1);
14791480

14801481
Guid dataKey = default;
1481-
var ex = await Record.ExceptionAsync(async () => dataKey = await clientEncryption
1482-
.CreateDataKeyAsync(kmsProvider, dataKeyOptions, CancellationToken.None));
1482+
Exception ex;
1483+
if (async)
1484+
{
1485+
ex = await Record.ExceptionAsync(async () => dataKey = await clientEncryption
1486+
.CreateDataKeyAsync(kmsProvider, dataKeyOptions, CancellationToken.None));
1487+
}
1488+
else
1489+
{
1490+
ex = Record.Exception(() => dataKey = clientEncryption
1491+
.CreateDataKey(kmsProvider, dataKeyOptions, CancellationToken.None));
1492+
}
14831493
ex.Should().BeNull();
14841494

14851495
await SetFailure(failureType, 1);
14861496

1487-
var ex2 = await Record.ExceptionAsync(async () => await clientEncryption.EncryptAsync(new BsonInt32(123),
1488-
new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", keyId: dataKey)));
1497+
Exception ex2;
1498+
if (async)
1499+
{
1500+
ex2 = await Record.ExceptionAsync(async () => await clientEncryption.EncryptAsync(new BsonInt32(123),
1501+
new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", keyId: dataKey)));
1502+
}
1503+
else
1504+
{
1505+
ex2 = Record.Exception(() => clientEncryption.Encrypt(new BsonInt32(123),
1506+
new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", keyId: dataKey)));
1507+
}
14891508
ex2.Should().BeNull();
14901509

14911510
if (failureType == "network")
14921511
{
14931512
await SetFailure("network", 4);
14941513

1495-
var ex3 = await Record.ExceptionAsync(async () => await clientEncryption
1496-
.CreateDataKeyAsync(kmsProvider, dataKeyOptions, CancellationToken.None));
1514+
Exception ex3;
1515+
if (async)
1516+
{
1517+
ex3 = await Record.ExceptionAsync(async () => dataKey = await clientEncryption
1518+
.CreateDataKeyAsync(kmsProvider, dataKeyOptions, CancellationToken.None));
1519+
}
1520+
else
1521+
{
1522+
ex3 = Record.Exception(() => dataKey = clientEncryption
1523+
.CreateDataKey(kmsProvider, dataKeyOptions, CancellationToken.None));
1524+
}
14971525
ex3.Should().NotBeNull();
14981526
}
14991527

0 commit comments

Comments
 (0)