diff --git a/cmd/cat-main.go b/cmd/cat-main.go index 83a2889c..1a658a42 100644 --- a/cmd/cat-main.go +++ b/cmd/cat-main.go @@ -154,9 +154,6 @@ func parseCatSyntax(ctx *cli.Context) (args []string, versionID string, timeRef fatalIf(errInvalidArgument().Trace(), "You need to pass at least one argument if --version-id is specified") } - if len(args) == 0 { - args = []string{"-"} - } for _, arg := range args { if strings.HasPrefix(arg, "-") && len(arg) > 1 { fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Unknown flag `%s` passed.", arg)) diff --git a/functional-tests.sh b/functional-tests.sh index 8f6f3c3a..87ddd99f 100755 --- a/functional-tests.sh +++ b/functional-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# MinIO Client (C) 2017 MinIO, Inc. +# MinIO Client (C) 2017-2020 MinIO, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ declare -a MC_CMD function get_md5sum() { - filename="$FILE_1_MB" + filename="$1" out=$(md5sum "$filename" 2>/dev/null) rv=$? if [ "$rv" -eq 0 ]; then @@ -432,7 +432,7 @@ function test_presigned_put_object() assert_success "$start_time" "${FUNCNAME[0]}" show_on_failure $? "unable to upload $FILE_1_MB presigned put object url" assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd cp "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" "${object_name}.downloaded" - assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "$FILE_65_MB_MD5SUM" "${object_name}.downloaded" + assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "$FILE_1_MB_MD5SUM" "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd rm "${object_name}.downloaded" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" log_success "$start_time" "${FUNCNAME[0]}" @@ -473,6 +473,21 @@ function test_cat_object() log_success "$start_time" "${FUNCNAME[0]}" } +function test_cat_stdin() +{ + show "${FUNCNAME[0]}" + + start_time=$(get_time) + object_name="mc-test-object-$RANDOM" + echo "testcontent" | "${MC_CMD[@]}" cat > stdin.output + assert_success "$start_time" "${FUNCNAME[0]}" show_on_failure $? "unable to redirect stdin to stdout using 'mc cat'" + assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "42ed9fb3563d8e9c7bb522be443033f4" stdin.output + assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd rm stdin.output + + log_success "$start_time" "${FUNCNAME[0]}" +} + + function test_mirror_list_objects() { show "${FUNCNAME[0]}" @@ -703,7 +718,7 @@ function test_copy_object_with_sse_rewrite() # now do a server side copy and store it unencrypted. assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd cp --encrypt-key "${cli_flag}" "${SERVER_ALIAS}/${BUCKET_NAME}/${prefix}/${object_name}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" # cat the unencrypted destination object. should return data without any error - assert_success "$start_time" "${FUNCNAME[0]}" "${MC_CMD[@]}" cat "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" > "${object_name}.downloaded" + "${MC_CMD[@]}" cat "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" >"${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" show_on_failure $? "unable to download object using 'mc cat'" assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "$FILE_1_MB_MD5SUM" "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd rm "${object_name}.downloaded" @@ -730,7 +745,7 @@ function test_copy_object_with_sse_dest() # now do a server side copy and store it eith different encryption key. assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd cp --encrypt-key "${cli_flag1},${cli_flag2}" "${SERVER_ALIAS}/${BUCKET_NAME}/${prefix}/${object_name}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" # cat the destination object with the new key. should return data without any error - assert_success "$start_time" "${FUNCNAME[0]}" "${MC_CMD[@]}" cat --encrypt-key "${cli_flag2}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" > "${object_name}.downloaded" + "${MC_CMD[@]}" cat --encrypt-key "${cli_flag2}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" > "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" show_on_failure $? "unable to download object using 'mc cat'" assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "$FILE_1_MB_MD5SUM" "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd rm "${object_name}.downloaded" @@ -759,7 +774,7 @@ function test_sse_key_rotation() # now do a server side copy on same object and do a key rotation assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd cp --encrypt-key "${cli_flag1},${cli_flag2}" "${SERVER_ALIAS}/${BUCKET_NAME}/${prefix}/${object_name}" "${SERVER_ALIAS_TLS}/${BUCKET_NAME}/${object_name}" # cat the object with the new key. should return data without any error - assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd cat --encrypt-key "${cli_flag2}" "${SERVER_ALIAS_TLS}/${BUCKET_NAME}/${object_name}" > "${object_name}.downloaded" + "${MC_CMD[@]}" cat --encrypt-key "${cli_flag2}" "${SERVER_ALIAS_TLS}/${BUCKET_NAME}/${object_name}" > "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" show_on_failure $? "unable to download object using 'mc cat'" assert_success "$start_time" "${FUNCNAME[0]}" check_md5sum "$FILE_1_MB_MD5SUM" "${object_name}.downloaded" assert_success "$start_time" "${FUNCNAME[0]}" mc_cmd rm "${object_name}.downloaded" @@ -853,6 +868,7 @@ function run_test() test_presigned_put_object test_presigned_get_object test_cat_object + test_cat_stdin test_mirror_list_objects test_mirror_list_objects_storage_class test_copy_object_preserve_filesystem_attr