Skip to content

Commit cf89a08

Browse files
authored
MONGOCRYPT-771 Remove check for $jsonSchema siblings (#948)
* remove check for `$jsonSchema` siblings * update test * remove `_test_encrypt_dupe_jsonschema` Remove the test. A `validator` with duplicate fields on the server is not expected.
1 parent ecb7614 commit cf89a08

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

src/mongocrypt-ctx-encrypt.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ static bool _set_schema_from_collinfo(mongocrypt_ctx_t *ctx, bson_t *collinfo) {
426426
return _mongocrypt_ctx_fail_w_msg(ctx, "malformed $jsonSchema");
427427
}
428428
found_jsonschema = true;
429-
} else {
430-
ectx->collinfo_has_siblings = true;
429+
break;
431430
}
432431
}
433432
}
@@ -800,15 +799,6 @@ static bool _mongo_feed_markings(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *in)
800799
"local schema used but does not have encryption specifiers");
801800
}
802801
return true;
803-
} else {
804-
/* if the schema requires encryption, but has sibling validators, error.
805-
*/
806-
if (ectx->collinfo_has_siblings) {
807-
return _mongocrypt_ctx_fail_w_msg(ctx,
808-
"schema requires encryption, "
809-
"but collection JSON schema "
810-
"validator has siblings");
811-
}
812802
}
813803

814804
if (bson_iter_init_find(&iter, &as_bson, "hasEncryptedPlaceholders") && !bson_iter_as_bool(&iter)) {

src/mongocrypt-ctx-private.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ typedef struct {
178178
_mongocrypt_buffer_t encrypted_cmd;
179179
_mongocrypt_buffer_t key_id;
180180
bool used_local_schema;
181-
/* collinfo_has_siblings is true if the schema came from a remote JSON
182-
* schema, and there were siblings. */
183-
bool collinfo_has_siblings;
184181
/* encrypted_field_config is set when:
185182
* 1. `target_ns` is present in an encrypted_field_config_map.
186183
* 2. (TODO MONGOCRYPT-414) The collection has encryptedFields in the

test/test-mongocrypt-ctx-encrypt.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,28 +1004,8 @@ static void _test_encrypt_invalid_siblings(_mongocrypt_tester_t *tester) {
10041004
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
10051005

10061006
BSON_ASSERT(MONGOCRYPT_CTX_NEED_MONGO_MARKINGS == mongocrypt_ctx_state(ctx));
1007-
ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/mongocryptd-reply.json")),
1008-
ctx,
1009-
"JSON schema validator has siblings");
1010-
1011-
mongocrypt_ctx_destroy(ctx);
1012-
mongocrypt_destroy(crypt);
1013-
}
1014-
1015-
static void _test_encrypt_dupe_jsonschema(_mongocrypt_tester_t *tester) {
1016-
mongocrypt_t *crypt;
1017-
mongocrypt_ctx_t *ctx;
1018-
1019-
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
1020-
ctx = mongocrypt_ctx_new(crypt);
1021-
ASSERT_OK(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_FILE("./test/example/cmd.json")), ctx);
1022-
1023-
BSON_ASSERT(MONGOCRYPT_CTX_NEED_MONGO_COLLINFO == mongocrypt_ctx_state(ctx));
1024-
ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx,
1025-
TEST_BSON("{'options': {'validator': { '$jsonSchema': {}, "
1026-
"'$jsonSchema': {} } } }")),
1027-
ctx,
1028-
"duplicate $jsonSchema");
1007+
// MONGOCRYPT-771 removes checks for sibling validators.
1008+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/mongocryptd-reply.json")), ctx);
10291009

10301010
mongocrypt_ctx_destroy(ctx);
10311011
mongocrypt_destroy(crypt);
@@ -4690,7 +4670,6 @@ void _mongocrypt_tester_install_ctx_encrypt(_mongocrypt_tester_t *tester) {
46904670
INSTALL_TEST(_test_encrypt_is_remote_schema);
46914671
INSTALL_TEST(_test_encrypt_init_each_cmd);
46924672
INSTALL_TEST(_test_encrypt_invalid_siblings);
4693-
INSTALL_TEST(_test_encrypt_dupe_jsonschema);
46944673
INSTALL_TEST(_test_encrypting_with_explicit_encryption);
46954674
INSTALL_TEST(_test_explicit_encryption);
46964675
INSTALL_TEST(_test_encrypt_empty_aws);

0 commit comments

Comments
 (0)