Skip to content

Commit 537dde0

Browse files
authored
CXX-3278 update invalid URIs in CSE endpoint tests (#1395)
* update test case 4 * replace `.local` with `.invalid`
1 parent e7a2760 commit 537dde0

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/mongocxx/test/client_side_encryption.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ void _run_endpoint_test(
11761176
}));
11771177

11781178
kms_doc_invalid.append(
1179-
kvp("kmip", [&](sub_document subdoc) { subdoc.append(kvp("endpoint", "doesnotexist.local:5698")); }));
1179+
kvp("kmip", [&](sub_document subdoc) { subdoc.append(kvp("endpoint", "doesnotexist.invalid:5698")); }));
11801180

11811181
ce_opts_invalid.key_vault_client(setup_client);
11821182
ce_opts_invalid.key_vault_namespace({"keyvault", "datakeys"});
@@ -1276,22 +1276,16 @@ TEST_CASE("Custom endpoint", "[client_side_encryption]") {
12761276
_run_endpoint_test(&setup_client, endpoint_masterkey2.view(), "aws");
12771277
}
12781278

1279-
// Call client_encryption.createDataKey() with "aws" as the provider and the following
1279+
// Call client_encryption.createDataKey() with "kmip" as the provider and the following
12801280
// masterKey:
12811281
// {
1282-
// region: "us-east-1",
1283-
// key: "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0",
1284-
// endpoint: "kms.us-east-1.amazonaws.com:12345"
1282+
// "keyId": "1",
1283+
// "endpoint": "localhost:12345"
12851284
// }
12861285
// Expect this to fail with a socket connection error.
12871286
SECTION("Test Case 4") {
1288-
auto socket_error_masterkey = document{}
1289-
<< "region"
1290-
<< "us-east-1"
1291-
<< "key"
1292-
<< "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0"
1293-
<< "endpoint"
1294-
<< "kms.us-east-1.amazonaws.com:12345" << finalize;
1287+
auto socket_error_masterkey = document{} << "keyId" << 1 << "endpoing"
1288+
<< "localhost:12345" << finalize;
12951289
_run_endpoint_test(&setup_client, socket_error_masterkey.view(), "aws", {{"error"}});
12961290
}
12971291

@@ -1428,7 +1422,7 @@ TEST_CASE("Custom endpoint", "[client_side_encryption]") {
14281422
// Expect this to succeed. Use the returned UUID of the key to explicitly encrypt and decrypt
14291423
// the string "test" to validate it works. Call client_encryption_invalid.createDataKey() with
14301424
// the same masterKey. Expect this to fail with a network exception indicating failure to
1431-
// resolve "doesnotexist.local".
1425+
// resolve "doesnotexist.invalid".
14321426
SECTION("Test Case 10") {
14331427
auto kmip_masterkey = document{} << "keyId"
14341428
<< "1" << finalize;
@@ -1437,7 +1431,7 @@ TEST_CASE("Custom endpoint", "[client_side_encryption]") {
14371431
kmip_masterkey.view(),
14381432
"kmip",
14391433
bsoncxx::stdx::nullopt,
1440-
{{"Failed to resolve doesnotexist.local: generic server error"}});
1434+
{{"Failed to resolve doesnotexist.invalid: generic server error"}});
14411435
}
14421436

14431437
// Call `client_encryption.createDataKey()` with "kmip" as the provider and the following
@@ -1460,20 +1454,20 @@ TEST_CASE("Custom endpoint", "[client_side_encryption]") {
14601454
// masterKey:
14611455
// {
14621456
// "keyId": "1",
1463-
// "endpoint": "doesnotexist.local:5698"
1457+
// "endpoint": "doesnotexist.invalid:5698"
14641458
// }
14651459
// Expect this to fail with a network exception indicating failure to resolve
1466-
// "doesnotexist.local".
1460+
// "doesnotexist.invalid".
14671461
SECTION("Test Case 12") {
14681462
auto kmip_masterkey = document{} << "keyId"
14691463
<< "1"
14701464
<< "endpoint"
1471-
<< "doesnotexist.local:5698" << finalize;
1465+
<< "doesnotexist.invalid:5698" << finalize;
14721466
_run_endpoint_test(
14731467
&setup_client,
14741468
kmip_masterkey.view(),
14751469
"kmip",
1476-
{{"Failed to resolve doesnotexist.local: generic server error"}});
1470+
{{"Failed to resolve doesnotexist.invalid: generic server error"}});
14771471
}
14781472
}
14791473

@@ -1955,7 +1949,7 @@ TEST_CASE("KMS TLS Options Tests", "[client_side_encryption][!mayfail]") {
19551949

19561950
opts.master_key(
19571951
document() << "keyVaultEndpoint"
1958-
<< "doesnotexist.local"
1952+
<< "doesnotexist.invalid"
19591953
<< "keyName"
19601954
<< "foo" << finalize);
19611955

0 commit comments

Comments
 (0)