Skip to content

Commit

Permalink
test: default state without RAINBOW_TRACING_AUTH
Browse files Browse the repository at this point in the history
Just a precaution, that we dont open tracing by default when we refactor
things going forward
  • Loading branch information
lidel committed Jun 25, 2024
1 parent 103335f commit 511492a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestNoBlockcacheHeader(t *testing.T) {
ts, gnd := mustTestServer(t, Config{
Bitswap: true,
TracingAuthToken: authToken,
disableMetrics: true,
})

content := make([]byte, 1024)
Expand Down Expand Up @@ -153,7 +154,34 @@ func TestNoBlockcacheHeader(t *testing.T) {
assert.Equal(t, content, responseBody)
})

t.Run("Skipping the cache only works when the authorization field matches", func(t *testing.T) {
t.Run("Skipping the cache only works when the Authorization header matches", func(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, url, nil)
require.NoError(t, err)

// Authorization missing, expect NoBlockcacheHeader to be ignored
req.Header.Set(NoBlockcacheHeader, "true")

res, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, res.StatusCode)
responseBody, err := io.ReadAll(res.Body)
assert.NoError(t, err)
assert.Equal(t, content, responseBody)
})

t.Run("Skipping the cache only works when RAINBOW_TRACING_AUTH is set", func(t *testing.T) {
// Set up separate server without authToken set
ts2, gnd := mustTestServer(t, Config{
Bitswap: true,
TracingAuthToken: "", // simulate RAINBOW_TRACING_AUTH being not set
disableMetrics: true,
})
content := make([]byte, 1024)
_, err := rand.Read(content)
require.NoError(t, err)
cid2 := mustAddFile(t, gnd, content)
url := ts2.URL + "/ipfs/" + cid2.String()

req, err := http.NewRequest(http.MethodGet, url, nil)
require.NoError(t, err)

Expand Down

0 comments on commit 511492a

Please sign in to comment.