From d6a34a3a8fda13c809120a013054d35b54a88fa0 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 2 Oct 2023 12:03:41 +0200 Subject: [PATCH 1/2] release: v0.4.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13cd3cc72..4ec737f0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [0.4.0] - 2023-10-02 ### Added - Added tests for HTTP Range requests, as well as some basic helpers for `AnyOf` and `AllOf`. [PR](https://github.com/ipfs/gateway-conformance/pull/162) From 60f09eb86695ffc7f44086dde73fbde453f16cdc Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 2 Oct 2023 14:03:29 +0200 Subject: [PATCH 2/2] fix: byte range panic --- tooling/helpers/range.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tooling/helpers/range.go b/tooling/helpers/range.go index b0a6d0e9d..5cafc4549 100644 --- a/tooling/helpers/range.go +++ b/tooling/helpers/range.go @@ -181,7 +181,7 @@ func IncludeRangeTests(t *testing.T, baseTest test.SugarTest, byteRanges []strin // Note: HTTP Multi Range requests can be validly responded with one of the full data, the partial data from the first // range, or the partial data from all the requested ranges func IncludeRandomRangeTests(t *testing.T, baseTest test.SugarTest, fullData []byte, contentType string) test.SugarTests { - return includeRangeTests(t, baseTest, nil, fullData, contentType) + return includeRangeTests(t, baseTest, makeRandomByteRanges(fullData), fullData, contentType) } func includeRangeTests(t *testing.T, baseTest test.SugarTest, byteRanges []string, fullData []byte, contentType string) test.SugarTests { @@ -238,22 +238,10 @@ func OnlyRangeTests(t *testing.T, baseTest test.SugarTest, byteRanges []string, // Note: HTTP Multi Range requests can be validly responded with one of the full data, the partial data from the first // range, or the partial data from all the requested ranges func OnlyRandomRangeTests(t *testing.T, baseTest test.SugarTest, fullData []byte, contentType string) test.SugarTests { - return onlyRangeTests(t, baseTest, nil, fullData, contentType) + return onlyRangeTests(t, baseTest, makeRandomByteRanges(fullData), fullData, contentType) } func onlyRangeTests(t *testing.T, baseTest test.SugarTest, byteRanges []string, fullData []byte, contentType string) test.SugarTests { - if len(byteRanges) == 0 { - dataLen := len(fullData) - if dataLen < 10 { - panic("transformation not defined for data smaller than 10 bytes") - } - - byteRanges = []string{ - "bytes=7-9", - "bytes=1-3", - } - } - singleBaseRequest := baseTest.Request.Clone() if contentType != "" { singleBaseRequest = singleBaseRequest.Header("Content-Type", contentType) @@ -280,3 +268,15 @@ func onlyRangeTests(t *testing.T, baseTest test.SugarTest, byteRanges []string, multiRange := MultiRangeTestTransform(t, multiBase, byteRanges, fullData, contentType) return test.SugarTests{singleRange, multiRange} } + +func makeRandomByteRanges(fullData []byte) []string { + dataLen := len(fullData) + if dataLen < 10 { + panic("transformation not defined for data smaller than 10 bytes") + } + + return []string{ + "bytes=7-9", + "bytes=1-3", + } +}