Skip to content

Commit

Permalink
MONGOCRYPT-724 remove use of bson_as_json (#895)
Browse files Browse the repository at this point in the history
`bson_as_json` is planned for deprecation.
  • Loading branch information
kevinAlbs authored Oct 21, 2024
1 parent a96bfcc commit de69cc9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/mongocrypt-opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ bool _mongocrypt_parse_kms_providers(mongocrypt_binary_t *kms_providers_definiti
}

if (log && log->trace_enabled) {
char *as_str = bson_as_json(&as_bson, NULL);
char *as_str = bson_as_relaxed_extended_json(&as_bson, NULL);
_mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "kms_providers", as_str);
bson_free(as_str);
}
Expand Down
2 changes: 1 addition & 1 deletion test/example-state-machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void _print_binary_as_bson(mongocrypt_binary_t *binary) {
BSON_ASSERT(binary);

bson_init_static(&as_bson, mongocrypt_binary_data(binary), mongocrypt_binary_len(binary));
str = bson_as_json(&as_bson, NULL);
str = bson_as_relaxed_extended_json(&as_bson, NULL);
printf("%s\n", str);
bson_free(str);
}
Expand Down
4 changes: 2 additions & 2 deletions test/test-mongocrypt-assert-match-bson.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ bool _check_match_bson(const bson_t *doc, const bson_t *pattern, char *errmsg, s
if (1) { \
char errmsg[1024] = ""; \
if (!_check_match_bson(doc, pattern, errmsg, sizeof(errmsg))) { \
char *doc_str = bson_as_json(doc, NULL); \
char *pattern_str = bson_as_json(pattern, NULL); \
char *doc_str = bson_as_relaxed_extended_json(doc, NULL); \
char *pattern_str = bson_as_relaxed_extended_json(pattern, NULL); \
\
TEST_ERROR("ASSERT_MATCH failed with document:\n\n" \
"%s\n" \
Expand Down
4 changes: 2 additions & 2 deletions test/test-mongocrypt-kek.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void _run_one_test(_mongocrypt_tester_t *tester, bson_t *test) {
expect_append = expect;
}

input_str = bson_as_json(&input, NULL);
input_str = bson_as_relaxed_extended_json(&input, NULL);
printf("- testcase: %s\n", input_str);
bson_free(input_str);

Expand Down Expand Up @@ -98,4 +98,4 @@ void test_mongocrypt_kek_parsing(_mongocrypt_tester_t *tester) {

void _mongocrypt_tester_install_kek(_mongocrypt_tester_t *tester) {
INSTALL_TEST(test_mongocrypt_kek_parsing);
}
}
6 changes: 3 additions & 3 deletions test/test-mongocrypt-key-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static void _match_cache_entry(_mongocrypt_tester_t *tester, mongocrypt_ctx_t *c
while (pair) {
if (_match_one_cache_entry(pair, expected_entry)) {
if (matched) {
printf("double matched entry: %s\n", bson_as_json(expected_entry, NULL));
printf("double matched entry: %s\n", bson_as_relaxed_extended_json(expected_entry, NULL));
BSON_ASSERT(false);
}
matched = true;
Expand All @@ -278,7 +278,7 @@ static void _match_cache_entry(_mongocrypt_tester_t *tester, mongocrypt_ctx_t *c
}

if (!matched) {
printf("could not match entry: %s\n", bson_as_json(expected_entry, NULL));
printf("could not match entry: %s\n", bson_as_relaxed_extended_json(expected_entry, NULL));
BSON_ASSERT(false);
}
}
Expand Down Expand Up @@ -419,4 +419,4 @@ static void _test_key_cache(_mongocrypt_tester_t *tester) {

void _mongocrypt_tester_install_key_cache(_mongocrypt_tester_t *tester) {
INSTALL_TEST(_test_key_cache);
}
}

0 comments on commit de69cc9

Please sign in to comment.