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

gateway: tests for simpler superfluous namespace handling #572

Merged
merged 1 commit into from
Feb 6, 2024
Merged

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Jan 25, 2024

Closes #344. See comments below.

Kubo: ipfs/kubo#10322

@hacdias hacdias requested a review from lidel as a code owner January 25, 2024 12:46
@hacdias hacdias self-assigned this Jan 25, 2024
@hacdias hacdias marked this pull request as draft January 25, 2024 12:49
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (89bceff) 65.48% compared to head (a393006) 65.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #572      +/-   ##
==========================================
+ Coverage   65.48%   65.60%   +0.12%     
==========================================
  Files         207      207              
  Lines       25605    25597       -8     
==========================================
+ Hits        16768    16794      +26     
+ Misses       7361     7324      -37     
- Partials     1476     1479       +3     
Files Coverage Δ
gateway/handler.go 78.27% <100.00%> (+1.81%) ⬆️

... and 14 files with indirect coverage changes

@lidel
Copy link
Member

lidel commented Jan 25, 2024

I did not look too deep, but I think this breaks valid content paths like /ipfs/ipfs/file.txt in places like subdomains – see the failing test of {{scheme}}://{{cid}}.ipfs.{{host}}/ipfs/ipns/ at https://github.com/ipfs/gateway-conformance/blob/193833b91f2e9b17daf45c84afaeeae61d9d7c7e/tests/subdomain_gateway_ipfs_test.go#L244-L259

Not sure how feasible, but it may be easier to move handleSuperfluousNamespace check from very front of the request processign pipeline, to very end: trigger it on "not found" code path (e.g. the place where we look for _redirects or produce HTTP 404 response)

@hacdias hacdias force-pushed the issue-344 branch 2 times, most recently from a99d5dc to 19304bf Compare January 26, 2024 12:01
@hacdias
Copy link
Member Author

hacdias commented Jan 26, 2024

@lidel I have actually realised #344 is actually not an issue. When I initially tested, they didn't redirect because I hadn't set the Paths field in the configuration 🤦

Nevertheless, we can use this PR as a simplification and also a bunch of tests.

@hacdias hacdias changed the title gateway: handle superfluous namespace on hostnames gateway: tests for simpler superfluous namespace handling Jan 26, 2024
@hacdias
Copy link
Member Author

hacdias commented Jan 26, 2024

@lidel it seems that we tested this in Kubo too. See here: ipfs/kubo#10322 too.

@hacdias hacdias marked this pull request as ready for review January 26, 2024 12:14
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you for cleaning this up!

@hacdias hacdias enabled auto-merge (rebase) February 6, 2024 08:35
@hacdias hacdias disabled auto-merge February 6, 2024 08:38
@hacdias hacdias enabled auto-merge (squash) February 6, 2024 08:39
@hacdias hacdias disabled auto-merge February 6, 2024 08:39
@hacdias hacdias enabled auto-merge (squash) February 6, 2024 08:39
@hacdias hacdias disabled auto-merge February 6, 2024 08:39
@hacdias hacdias enabled auto-merge (squash) February 6, 2024 08:39
@hacdias hacdias disabled auto-merge February 6, 2024 08:46
@hacdias hacdias merged commit 79cb4e2 into main Feb 6, 2024
12 of 14 checks passed
@hacdias hacdias deleted the issue-344 branch February 6, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Gateway: handleSuperfluousNamespace doesn't work with Hostnames
2 participants