diff --git a/.github/integration/tests/common/50_check_endpoint.sh b/.github/integration/tests/common/50_check_endpoint.sh index edbff75..3f21f83 100755 --- a/.github/integration/tests/common/50_check_endpoint.sh +++ b/.github/integration/tests/common/50_check_endpoint.sh @@ -92,7 +92,7 @@ fi curl --cacert certs/ca.pem -H "Authorization: Bearer $token" "https://localhost:8443/files/urn:neic:001-002?startCoordinate=0&endCoordinate=2" --output test-part.txt -echo "TH" > old-part.txt +dd if=old-file.txt ibs=1 skip=0 count=2 > old-part.txt cmp --silent old-part.txt test-part.txt status=$? @@ -100,11 +100,12 @@ if [[ $status = 0 ]]; then echo "Files are the same" else echo "Files are different" + exit 1 fi curl --cacert certs/ca.pem -H "Authorization: Bearer $token" "https://localhost:8443/files/urn:neic:001-002?startCoordinate=7&endCoordinate=14" --output test-part2.txt -echo "LE IS J" > old-part2.txt +dd if=old-file.txt ibs=1 skip=7 count=7 > old-part2.txt cmp --silent old-part2.txt test-part2.txt status=$? @@ -112,6 +113,7 @@ if [[ $status = 0 ]]; then echo "Files are the same" else echo "Files are different" + exit 1 fi # ------------------ diff --git a/.github/integration/tests/s3notls/52_check_endpoint.sh b/.github/integration/tests/s3notls/52_check_endpoint.sh index b49e0c3..67bdff9 100644 --- a/.github/integration/tests/s3notls/52_check_endpoint.sh +++ b/.github/integration/tests/s3notls/52_check_endpoint.sh @@ -88,7 +88,7 @@ fi curl -H "Authorization: Bearer $token" "http://localhost:8080/files/urn:neic:001-002?startCoordinate=0&endCoordinate=2" --output test-part.txt -echo "TH" > old-part.txt +dd if=old-file.txt ibs=1 skip=0 count=2 > old-part.txt cmp --silent old-part.txt test-part.txt status=$? @@ -96,11 +96,12 @@ if [[ $status = 0 ]]; then echo "Files are the same" else echo "Files are different" + exit 1 fi curl -H "Authorization: Bearer $token" "http://localhost:8080/files/urn:neic:001-002?startCoordinate=7&endCoordinate=14" --output test-part2.txt -echo "LE IS J" > old-part2.txt +dd if=old-file.txt ibs=1 skip=7 count=7 > old-part2.txt cmp --silent old-part2.txt test-part2.txt status=$? @@ -108,6 +109,7 @@ if [[ $status = 0 ]]; then echo "Files are the same" else echo "Files are different" + exit 1 fi # ------------------ diff --git a/api/sda/sda.go b/api/sda/sda.go index 4c5c215..2f7b137 100644 --- a/api/sda/sda.go +++ b/api/sda/sda.go @@ -255,6 +255,13 @@ func Download(c *gin.Context) { // used from: https://github.com/neicnordic/crypt4gh/blob/master/examples/reader/main.go#L48C1-L113C1 var sendStream = func(reader *streaming.Crypt4GHReader, writer http.ResponseWriter, start, end int64) error { + if start != 0 { + // We don't want to read from start, skip ahead to where we should be + if _, err := reader.Seek(start, 0); err != nil { + return err + } + } + // Calculate how much we should read (if given) togo := end - start