145
# payload directly, but redirect to URL with proper origin isolation
146
147
test_localhost_gateway_response_should_contain \
148
- "request for localhost/ipfs/{CIDv1} redirects to subdomain" \
148
+ "request for localhost/ipfs/{CIDv1} returns status code HTTP 301" \
149
+ "http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
150
+ "301 Moved Permanently"
151
+
152
+test_localhost_gateway_response_should_contain \
153
+ "request for localhost/ipfs/{CIDv1} returns Location HTTP header for subdomain redirect in browsers" \
154
"http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
155
"Location: http://$CIDv1.ipfs.localhost:$GWAY_PORT/"
156
157
+# Responses to the root domain of subdomain gateway hostname should Clear-Site-Data
158
+# https://github.com/ipfs/go-ipfs/issues/6975#issuecomment-597472477
159
+test_localhost_gateway_response_should_contain \
160
+ "request for localhost/ipfs/{CIDv1} returns Clear-Site-Data header to purge Origin cookies and storage" \
161
+ "http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
162
+ 'Clear-Site-Data: \"cookies\", \"storage\"'
163
+
164
+# We return body with HTTP 301 so existing cli scripts that use path-based
165
+# gateway do not break (curl doesn't auto-redirect without passing -L; wget
166
+# does not span across hostnames by default)
167
+# Context: https://github.com/ipfs/go-ipfs/issues/6975
168
+test_localhost_gateway_response_should_contain \
169
+ "request for localhost/ipfs/{CIDv1} includes valid payload in body for CLI tools like curl" \
170
+ "http://localhost:$GWAY_PORT/ipfs/$CIDv1" \
171
+ "$CID_VAL"
172
+
173
test_localhost_gateway_response_should_contain \
174
"request for localhost/ipfs/{CIDv0} redirects to CIDv1 representation in subdomain" \
175
"http://localhost:$GWAY_PORT/ipfs/$CIDv0" \