@@ -297,20 +297,20 @@ list_and_check_directory_obj() {
297
297
return 0
298
298
}
299
299
300
- check_sha256_invalid_or_incorrect () {
301
- if [ $# -ne 5 ]; then
302
- log 2 " 'check_sha256_invalid_or_incorrect' requires data file, bucket name, key, checksum, expected error"
300
+ check_checksum_invalid_or_incorrect () {
301
+ if [ $# -ne 6 ]; then
302
+ log 2 " 'check_sha256_invalid_or_incorrect' requires data file, bucket name, key, checksum type, checksum , expected error"
303
303
return 1
304
304
fi
305
- if ! result=$( COMMAND_LOG=" $COMMAND_LOG " DATA_FILE=" $1 " BUCKET_NAME=" $2 " OBJECT_KEY=" $3 " OUTPUT_FILE=" $TEST_FILE_FOLDER /result.txt" CHECKSUM_TYPE=" sha256 " CHECKSUM=" $4 " ./tests/rest_scripts/put_object.sh 2>&1 ) ; then
305
+ if ! result=$( COMMAND_LOG=" $COMMAND_LOG " DATA_FILE=" $1 " BUCKET_NAME=" $2 " OBJECT_KEY=" $3 " OUTPUT_FILE=" $TEST_FILE_FOLDER /result.txt" CHECKSUM_TYPE=" $4 " CHECKSUM=" $5 " ./tests/rest_scripts/put_object.sh 2>&1 ) ; then
306
306
log 2 " error: $result "
307
307
return 1
308
308
fi
309
309
if [ " $result " != " 400" ]; then
310
310
log 2 " expected response code of '400', was '$result ' (response: $( cat " $TEST_FILE_FOLDER /result.txt" ) "
311
311
return 1
312
312
fi
313
- if ! check_xml_element " $TEST_FILE_FOLDER /result.txt" " $5 " " Error" " Message" ; then
313
+ if ! check_xml_element " $TEST_FILE_FOLDER /result.txt" " $6 " " Error" " Message" ; then
314
314
log 2 " xml error message mismatch"
315
315
return 1
316
316
fi
@@ -322,7 +322,8 @@ put_object_rest_checksum() {
322
322
log 2 " 'put_object_rest_sha256_checksum' requires data file, bucket name, key, checksum type"
323
323
return 1
324
324
fi
325
- if ! result=$( COMMAND_LOG=" $COMMAND_LOG " DATA_FILE=" $1 " BUCKET_NAME=" $2 " OBJECT_KEY=" $3 " OUTPUT_FILE=" $TEST_FILE_FOLDER /result.txt" CHECKSUM_TYPE=" $4 " ./tests/rest_scripts/put_object.sh 2>&1 ) ; then
325
+ # shellcheck disable=SC2097,SC2098
326
+ if ! result=$( COMMAND_LOG=" $COMMAND_LOG " DATA_FILE=" $1 " BUCKET_NAME=" $2 " OBJECT_KEY=" $3 " TEST_FILE_FOLDER=" $TEST_FILE_FOLDER " OUTPUT_FILE=" $TEST_FILE_FOLDER /result.txt" CHECKSUM_TYPE=" $4 " ./tests/rest_scripts/put_object.sh 2>&1 ) ; then
326
327
log 2 " error: $result "
327
328
return 1
328
329
fi
@@ -339,7 +340,7 @@ put_object_rest_sha256_invalid() {
339
340
log 2 " 'put_object_rest_sha256_invalid' requires data file, bucket name, key"
340
341
return 1
341
342
fi
342
- if ! check_sha256_invalid_or_incorrect " $1 " " $2 " " $3 " " dummy" " Value for x-amz-checksum-sha256 header is invalid." ; then
343
+ if ! check_checksum_invalid_or_incorrect " $1 " " $2 " " $3 " " sha256 " " dummy" " Value for x-amz-checksum-sha256 header is invalid." ; then
343
344
log 2 " error checking checksum"
344
345
return 1
345
346
fi
@@ -357,7 +358,7 @@ put_object_rest_sha256_incorrect() {
357
358
error_message=" The sha256 you specified did not match the calculated checksum."
358
359
fi
359
360
incorrect_checksum=" $( echo -n " dummy" | sha256sum | awk ' {print $1}' | xxd -r -p | base64) "
360
- if ! check_sha256_invalid_or_incorrect " $1 " " $2 " " $3 " " $incorrect_checksum " " $error_message " ; then
361
+ if ! check_checksum_invalid_or_incorrect " $1 " " $2 " " $3 " " sha256 " " $incorrect_checksum " " $error_message " ; then
361
362
log 2 " error checking checksum"
362
363
return 1
363
364
fi
@@ -379,3 +380,42 @@ put_object_rest_chunked_payload_type_without_content_length() {
379
380
fi
380
381
return 0
381
382
}
383
+
384
+ put_object_rest_crc32_incorrect () {
385
+ if [ $# -ne 3 ]; then
386
+ log 2 " 'put_object_rest_crc32_incorrect' requires data file, bucket name, key"
387
+ return 1
388
+ fi
389
+ if [ " $DIRECT " == " true" ]; then
390
+ error_message=" The CRC32 you specified did not match the calculated checksum."
391
+ else
392
+ error_message=" The crc32 you specified did not match the calculated checksum."
393
+ fi
394
+ incorrect_checksum=" $( echo -n " dummy" | gzip -c -1 | tail -c8 | od -t x4 -N 4 -A n | awk ' {print $1}' | xxd -r -p | base64) "
395
+ if ! check_checksum_invalid_or_incorrect " $1 " " $2 " " $3 " " crc32" " $incorrect_checksum " " $error_message " ; then
396
+ log 2 " error checking checksum"
397
+ return 1
398
+ fi
399
+ return 0
400
+ }
401
+
402
+ put_object_rest_crc64nvme_incorrect () {
403
+ if [ $# -ne 3 ]; then
404
+ log 2 " 'put_object_rest_crc64nvme_incorrect' requires data file, bucket name, key"
405
+ return 1
406
+ fi
407
+ if [ " $DIRECT " == " true" ]; then
408
+ error_message=" The CRC64NVME you specified did not match the calculated checksum."
409
+ else
410
+ error_message=" The crc64nvme you specified did not match the calculated checksum."
411
+ fi
412
+ if ! incorrect_checksum=$( DATA_FILE=<( echo -n " dummy" ) TEST_FILE_FOLDER=" $TEST_FILE_FOLDER " ./tests/rest_scripts/calculate_crc64nvme.sh 2>&1 ) ; then
413
+ log 2 " error calculating checksum: $incorrect_checksum "
414
+ return 1
415
+ fi
416
+ if ! check_checksum_invalid_or_incorrect " $1 " " $2 " " $3 " " crc64nvme" " $incorrect_checksum " " $error_message " ; then
417
+ log 2 " error checking checksum"
418
+ return 1
419
+ fi
420
+ return 0
421
+ }
0 commit comments