@@ -259,31 +259,38 @@ static void _test_mc_tokens_error(_mongocrypt_tester_t *tester) {
259259}
260260
261261static void _test_mc_tokens_raw_buffer (_mongocrypt_tester_t * tester ) {
262- mc_ServerDataEncryptionLevel1Token_t * token ;
262+ mc_ServerDataEncryptionLevel1Token_t * token1 ;
263+ mc_ServerDataEncryptionLevel1Token_t * token2 ;
263264 _mongocrypt_buffer_t test_input ;
264265 _mongocrypt_buffer_t expected ;
265266
266267 _mongocrypt_buffer_copy_from_hex (& test_input , "6c6a349956c19f9c5e638e612011a71fbb71921edb540310c17cd0208b7f548b" );
267268
268269 /* Make a token from a raw buffer */
269- token = mc_ServerDataEncryptionLevel1Token_new_from_buffer (& test_input );
270+ token1 = mc_ServerDataEncryptionLevel1Token_new_from_buffer (& test_input );
271+ token2 = mc_ServerDataEncryptionLevel1Token_new_from_buffer_copy (& test_input );
270272
271273 /* Assert new_from_buffer did not steal ownership. */
272274 ASSERT (test_input .owned );
273275 ASSERT (test_input .len == MONGOCRYPT_HMAC_SHA256_LEN );
274276
275277 _mongocrypt_buffer_copy_from_hex (& expected , "6c6a349956c19f9c5e638e612011a71fbb71921edb540310c17cd0208b7f548b" );
276278
277- ASSERT_CMPBUF (* mc_ServerDataEncryptionLevel1Token_get (token ), expected );
279+ ASSERT_CMPBUF (* mc_ServerDataEncryptionLevel1Token_get (token1 ), expected );
280+ ASSERT_CMPBUF (* mc_ServerDataEncryptionLevel1Token_get (token2 ), expected );
278281
279282 /* Assert new_from_buffer references original buffer instead of a copy. */
280283 test_input .data [0 ] = '0' ;
281284 expected .data [0 ] = '0' ;
282- ASSERT_CMPBUF (* mc_ServerDataEncryptionLevel1Token_get (token ), expected );
285+ ASSERT_CMPBUF (* mc_ServerDataEncryptionLevel1Token_get (token1 ), expected );
286+
287+ // Assert new_from_buffer_copy references a new buffer.
288+ ASSERT_CMPUINT8 (mc_ServerDataEncryptionLevel1Token_get (token2 )-> data [0 ], != , expected .data [0 ]);
283289
284290 _mongocrypt_buffer_cleanup (& test_input );
285291 _mongocrypt_buffer_cleanup (& expected );
286- mc_ServerDataEncryptionLevel1Token_destroy (token );
292+ mc_ServerDataEncryptionLevel1Token_destroy (token1 );
293+ mc_ServerDataEncryptionLevel1Token_destroy (token2 );
287294}
288295
289296void _mongocrypt_tester_install_mc_tokens (_mongocrypt_tester_t * tester ) {
0 commit comments