diff --git a/run_functional_tests.sh b/run_functional_tests.sh index 72813fed5..f5ed35d6c 100755 --- a/run_functional_tests.sh +++ b/run_functional_tests.sh @@ -16,37 +16,35 @@ # function run_minio_server() { - if [ ! -f tests/functional/minio ]; then - wget --quiet --output-document tests/functional/minio https://dl.min.io/server/minio/release/linux-amd64/minio - chmod +x tests/functional/minio - fi + if [ ! -f tests/functional/minio ]; then + wget --quiet --output-document tests/functional/minio https://dl.min.io/server/minio/release/linux-amd64/minio + chmod +x tests/functional/minio + fi - export MINIO_ACCESS_KEY=minio - export MINIO_SECRET_KEY=minio123 - export MINIO_KMS_KES_ENDPOINT=https://play.min.io:7373 - export MINIO_KMS_KES_KEY_FILE=tests/functional/play.min.io.kes.root.key - export MINIO_KMS_KES_CERT_FILE=tests/functional/play.min.io.kes.root.cert - export MINIO_KMS_KES_KEY_NAME=my-minio-key - export MINIO_NOTIFY_WEBHOOK_ENABLE_miniopytest=on - export MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniopytest=http://example.org/ - export SQS_ARN="arn:minio:sqs::miniopytest:webhook" - export MINIO_CI_CD=1 - tests/functional/minio server --config-dir tests/functional/.cfg tests/functional/.d{1...4} >tests/functional/minio.log 2>&1 & + export MINIO_KMS_KES_ENDPOINT=https://play.min.io:7373 + export MINIO_KMS_KES_KEY_FILE=tests/functional/play.min.io.kes.root.key + export MINIO_KMS_KES_CERT_FILE=tests/functional/play.min.io.kes.root.cert + export MINIO_KMS_KES_KEY_NAME=my-minio-key + export MINIO_NOTIFY_WEBHOOK_ENABLE_miniopytest=on + export MINIO_NOTIFY_WEBHOOK_ENDPOINT_miniopytest=http://example.org/ + export SQS_ARN="arn:minio:sqs::miniopytest:webhook" + export MINIO_CI_CD=1 + tests/functional/minio server --config-dir tests/functional/.cfg tests/functional/.d{1...4} >tests/functional/minio.log 2>&1 & } if [ -z ${SERVER_ENDPOINT+x} ]; then - run_minio_server - MINIO_PID=$! - trap 'kill -9 ${MINIO_PID} 2>/dev/null' INT + run_minio_server + MINIO_PID=$! + trap 'kill -9 ${MINIO_PID} 2>/dev/null' INT - export MINT_MODE=full - export SERVER_ENDPOINT=localhost:9000 - export ACCESS_KEY=minio - export SECRET_KEY=minio123 - export ENABLE_HTTPS=0 + export MINT_MODE=full + export SERVER_ENDPOINT=localhost:9000 + export ACCESS_KEY=minioadmin + export SECRET_KEY=minioadmin + export ENABLE_HTTPS=0 fi PYTHONPATH=$PWD python tests/functional/tests.py if [ -n "$MINIO_PID" ]; then - kill -9 "$MINIO_PID" 2>/dev/null + kill -9 "$MINIO_PID" 2>/dev/null fi diff --git a/tests/functional/tests.py b/tests/functional/tests.py index f6a043f2d..e76946288 100644 --- a/tests/functional/tests.py +++ b/tests/functional/tests.py @@ -1379,9 +1379,6 @@ def test_presigned_get_object_response_headers( # pylint: disable=invalid-name size = 1 * KB _CLIENT.put_object(bucket_name, object_name, LimitedRandomReader(size), size) - presigned_get_object_url = _CLIENT.presigned_get_object( - bucket_name, object_name, timedelta(seconds=120)) - response_headers = { 'response-content-type': content_type, 'response-content-language': content_language @@ -1418,6 +1415,51 @@ def test_presigned_get_object_response_headers( # pylint: disable=invalid-name _CLIENT.remove_bucket(bucket_name) +def test_presigned_get_object_range( # pylint: disable=invalid-name + log_entry): + """Test presigned_get_object() with headers.""" + + # Get a unique bucket_name and object_name + bucket_name = _gen_bucket_name() + object_name = f"{uuid4()}" + + log_entry["args"] = { + "bucket_name": bucket_name, + "object_name": object_name, + } + + _CLIENT.make_bucket(bucket_name) + try: + size = 556433 # on purpose its mis-aligned + _CLIENT.put_object(bucket_name, object_name, LimitedRandomReader(size), + size) + + presigned_get_object_url = _CLIENT.presigned_get_object( + bucket_name, object_name, timedelta(seconds=120)) + + log_entry["args"]["presigned_get_object_url"] = ( + presigned_get_object_url) + + response = HTTP.urlopen('GET', presigned_get_object_url, + headers={'Range': 'bytes=490897-556432'}) + + log_entry["args"]['response.status'] = response.status + log_entry["args"]['response.reason'] = response.reason + log_entry["args"]['response.headers'] = json.dumps( + response.headers.__dict__) + # pylint: disable=protected-access + log_entry["args"]['response._body'] = response._body.decode('utf-8') + + if response.status != 200: + raise Exception( + "Presigned GET object URL {presigned_get_object_url} failed; " + "code: {response.code}, error: {response.data}" + ) + finally: + _CLIENT.remove_object(bucket_name, object_name) + _CLIENT.remove_bucket(bucket_name) + + def test_presigned_get_object_version( # pylint: disable=invalid-name log_entry): """Test presigned_get_object() of versioned object."""