Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/Dockerfile_test_bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ ENV PATH="$VENV/bin:${PATH}"
WORKDIR /home/tester
RUN make

RUN chown -R tester:tester /home/tester/.cache/go-build /home/tester/go

USER tester

RUN . $SECRETS_FILE && \
Expand All @@ -55,5 +57,14 @@ RUN mkdir config log && cp $CONFIG_FILE config/.env
ENV WORKSPACE=.
ENV VERSITYGW_TEST_ENV=/home/tester/config/.env

#RUN set -x; \
# id; \
# whoami; \
# echo "GOCACHE=$(go env GOCACHE)"; \
# echo "GOMODCACHE=$(go env GOMODCACHE)"; \
# echo "GOPATH=$(go env GOPATH)" || true
#
#RUN cache="$(go env GOCACHE)" && ls -ld "$cache" && find "$cache" -maxdepth 2 -ls 2>/dev/null | head -100 || true

ENTRYPOINT ["tests/run.sh"]
CMD ["s3api,s3,s3cmd,mc,rest"]
34 changes: 0 additions & 34 deletions tests/commands/put_bucket_policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,3 @@ put_bucket_policy_rest_200_or_204() {
fi
return 0
}

create_website_with_random_string_and_add_permissions() {
if ! check_param_count_v2 "bucket name" 1 $#; then
return 1
fi
local bucket_name="$1"
local response random_string policy_file

if ! response=$(create_website_with_random_string "$bucket_name" 2>&1); then
log 2 "error creating website: $response"
return 1
fi
read -r _ random_string <<< "$response"

if [ "$DIRECT" == "true" ]; then
if ! put_public_access_block "$bucket_name" "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"; then
log 2 "error putting public access block"
return 1
fi
fi

if ! response=$(setup_policy_with_single_statement_v2 "2012-10-17" "Allow" "*" "s3:GetObject" "arn:aws:s3:::$bucket_name/*" 2>&1); then
log 2 "error setting up policy: $response"
return 1
fi
policy_file="$response"

if ! put_bucket_policy "rest" "$bucket_name" "$TEST_FILE_FOLDER"/"$policy_file"; then
log 2 "error putting bucket policy"
return 1
fi
printf '%s\n' "$random_string"
return 0
}
41 changes: 22 additions & 19 deletions tests/commands/upload_part_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,37 @@
# under the License.

upload_part_copy() {
if [ $# -ne 5 ]; then
log 2 "upload multipart part copy function must have bucket, key, upload ID, file name, part number"
if ! check_param_count_v2 "bucket, key, upload ID, file name, part number" 5 $#; then
return 1
fi
local etag_json
log 5 "parameters: '$1' '$2' '$3' '$4' '$5'"
etag_json=$(send_command aws --no-verify-ssl s3api upload-part-copy --bucket "$1" --key "$2" --upload-id "$3" --part-number "$5" --copy-source "$1/$4-$(($5-1))") || local uploaded=$?
if [[ $uploaded -ne 0 ]]; then
log 2 "Error uploading part $5: $etag_json"
local bucket="$1" key="$2" upload_id="$3" file_name="$4" part_number="$5"
local response response_without_warning

if ! response=$(send_command aws --no-verify-ssl s3api upload-part-copy --bucket "$1" --key "$2" --upload-id "$3" --part-number "$5" --copy-source "$1/$4-$(($5-1))" 2>&1); then
log 2 "UploadPartCopy command error: $response"
return 1
fi
etag=$(echo "$etag_json" | jq '.CopyPartResult.ETag')
export etag
log 5 "UploadPartCopy response: $response"
response_without_warning=$(grep -v "InsecureRequestWarning" - <<< "$response")
etag=$(jq -r '.CopyPartResult.ETag' - <<< "$response_without_warning" 2>&1)
printf '%s\n' "$etag"
return 0
}

upload_part_copy_with_range() {
if [ $# -ne 6 ]; then
log 2 "upload multipart part copy function must have bucket, key, upload ID, file name, part number, range"
if ! check_param_count_v2 "bucket, key, upload ID, file name, part number, range" 6 $#; then
return 1
fi
local etag_json
log 5 "bucket: $1, key: $2, upload ID: $3, file name: $4, range: $5, copy source range: $6"
etag_json=$(send_command aws --no-verify-ssl s3api upload-part-copy --bucket "$1" --key "$2" --upload-id "$3" --part-number "$5" --copy-source "$1/$4-$(($5-1))" --copy-source-range "$6" 2>&1) || local uploaded=$?
if [[ $uploaded -ne 0 ]]; then
log 2 "Error uploading part $5: $etag_json"
export upload_part_copy_error=$etag_json
local bucket="$1" key="$2" upload_id="$3" file_name="$4" part_number="$5" range="$6"
local response etag

if ! response=$(send_command aws --no-verify-ssl s3api upload-part-copy --bucket "$bucket" --key "$key" --upload-id "$upload_id" \
--part-number "$part_number" --copy-source "${bucket}/${file_name}-$((part_number-1))" --copy-source-range "$range" 2>&1); then
printf "s3api UploadPartCopy command error: %s\n" "$response"
return 1
fi
etag=$(echo "$etag_json" | grep -v "InsecureRequestWarning" | jq '.CopyPartResult.ETag')
export etag
log 5 "UploadPartCopy with range response: $response"
etag=$(echo "$response" | grep -v "InsecureRequestWarning" | jq -r '.CopyPartResult.ETag')
printf '%s\n' "$etag"
return 0
}
9 changes: 9 additions & 0 deletions tests/download_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ download_apt_packages() {
return 1
fi

if ! env DEBIAN_FRONTEND=noninteractive sudo rm -rf /var/lib/apt/lists/*; then
echo "error removing old apt lists" >&2
return 1
fi
if ! env DEBIAN_FRONTEND=noninteractive sudo apt-get clean; then
echo "error with apt clean" >&2
return 1
fi

if ! env DEBIAN_FRONTEND=noninteractive sudo apt-get update; then
echo "error with apt update" >&2
return 1
Expand Down
Loading
Loading