Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release 0.5.2 #208

Merged
merged 2 commits into from
May 20, 2024
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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ 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]
- Relaxed the DAG-CBOR error check: we no longer check the body of the response, only the status code. [PR](https://github.com/ipfs/gateway-conformance/pull/205)
## [0.5.2] - 2024-05-20
### Changed
- Fixed: relaxed dag-cbor error check ([#205](https://github.com/ipfs/gateway-conformance/pull/205))
- Fixed: Header().Has works properly for checking multiple values ([#207](https://github.com/ipfs/gateway-conformance/pull/207))

## [0.5.1] - 2024-04-11
- Removed byte range text for DAG-CBOR objects converted to `text/html`. [PR](https://github.com/ipfs/gateway-conformance/pull/202)
Expand Down
23 changes: 23 additions & 0 deletions tooling/test/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"testing"

"github.com/ipfs/gateway-conformance/tooling/check"
Expand Down Expand Up @@ -42,8 +43,30 @@ func validateResponse(

for _, header := range expected.Headers_ {
testName := fmt.Sprintf("Header %s", header.Key_)

actual := res.Header.Values(header.Key_)

// HTTP Headers can have multiple values, and that can be represented by comman separated value,
// or sending the same header more than once. The `res.Header.Get` only returns the value
// from the first header, so we use Values here.
// At the same time, we don't want to have two separate checks everywhere, so we normalize
// multiple instances of the same header by converting it into a single one, with comma-separated
// values.
if len(actual) > 1 {
var result []string
all := strings.Join(actual, ",")
split := strings.Split(all, ",")
for _, s := range split {
value := strings.TrimSpace(s)
if value != "" {
result = append(result, strings.TrimSpace(s))
}
}
// Normalize values from all instances of the header into a single one and comma-separated notation
joined := strings.Join(result, ", ")
actual = []string{joined}
}

c := header.Check_
if header.Not_ {
c = check.Not(c)
Expand Down
Loading