|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 17 | +#include "mc-fle-blob-subtype-private.h" |
17 | 18 | #include "mc-fle2-insert-update-payload-private.h" |
18 | 19 | #include "test-mongocrypt.h" |
19 | 20 |
|
@@ -160,7 +161,29 @@ static void test_FLE2InsertUpdatePayload_decrypt(_mongocrypt_tester_t *tester) { |
160 | 161 |
|
161 | 162 | #undef TEST_IUP_HEX |
162 | 163 |
|
| 164 | +static void test_FLE2InsertUpdatePayload_parse_errors(_mongocrypt_tester_t *tester) { |
| 165 | + bson_t *input_bson = TMP_BSON_STR(BSON_STR({ |
| 166 | + "d" : {"$binary" : {"base64" : "AAAA", "subType" : "00"}}, // |
| 167 | + "t" : "wrong type!" |
| 168 | + })); |
| 169 | + _mongocrypt_buffer_t input_buf; |
| 170 | + _mongocrypt_buffer_init_size(&input_buf, 1 + input_bson->len); |
| 171 | + input_buf.data[0] = (uint8_t)MC_SUBTYPE_FLE2InsertUpdatePayload; |
| 172 | + memcpy(input_buf.data + 1, bson_get_data(input_bson), input_bson->len); |
| 173 | + |
| 174 | + mc_FLE2InsertUpdatePayload_t payload; |
| 175 | + mc_FLE2InsertUpdatePayload_init(&payload); |
| 176 | + mongocrypt_status_t *status = mongocrypt_status_new(); |
| 177 | + ASSERT_FAILS_STATUS(mc_FLE2InsertUpdatePayload_parse(&payload, &input_buf, status), |
| 178 | + status, |
| 179 | + "Field 't' expected to hold an int32"); |
| 180 | + mc_FLE2InsertUpdatePayload_cleanup(&payload); |
| 181 | + mongocrypt_status_destroy(status); |
| 182 | + _mongocrypt_buffer_cleanup(&input_buf); |
| 183 | +} |
| 184 | + |
163 | 185 | void _mongocrypt_tester_install_fle2_payload_iup(_mongocrypt_tester_t *tester) { |
164 | 186 | INSTALL_TEST(test_FLE2InsertUpdatePayload_parse); |
165 | 187 | INSTALL_TEST(test_FLE2InsertUpdatePayload_decrypt); |
| 188 | + INSTALL_TEST(test_FLE2InsertUpdatePayload_parse_errors); |
166 | 189 | } |
0 commit comments