summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-12-22 10:39:28 +0000
committerGitHub <noreply@github.com>2021-12-22 10:39:28 +0000
commit62dcf1a6fb8f4cf935e7ca288406402d243507c0 (patch)
tree0150ef5d7377dc6bb1459a51e711ab9f720e50bc /integrations
parenta9ed1c5c7c6c85ae280e6a13ca0d4e665945efb4 (diff)
downloadgitea-62dcf1a6fb8f4cf935e7ca288406402d243507c0.tar.gz
gitea-62dcf1a6fb8f4cf935e7ca288406402d243507c0.zip
Add NotFound handler (#18062)
PR #17997 means that urls with terminal '/' are no longer immediately mapped to the url without a terminal slash. However, it has revealed that the NotFound handler appears to have been lost. This PR adds back in a NotFound handler that simply redirects to a path without the terminal slash or runs the NotFound handler. Fix #18060 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/links_test.go10
-rw-r--r--integrations/signout_test.go2
2 files changed, 11 insertions, 1 deletions
diff --git a/integrations/links_test.go b/integrations/links_test.go
index 91166274a2..872234e61f 100644
--- a/integrations/links_test.go
+++ b/integrations/links_test.go
@@ -61,6 +61,16 @@ func TestRedirectsNoLogin(t *testing.T) {
resp := MakeRequest(t, req, http.StatusFound)
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
}
+
+ var temporaryRedirects = map[string]string{
+ "/user2/repo1/": "/user2/repo1",
+ }
+ for link, redirectLink := range temporaryRedirects {
+ req := NewRequest(t, "GET", link)
+ resp := MakeRequest(t, req, http.StatusTemporaryRedirect)
+ assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
+ }
+
}
func TestNoLoginNotExist(t *testing.T) {
diff --git a/integrations/signout_test.go b/integrations/signout_test.go
index c31c913070..b54e7ee9ee 100644
--- a/integrations/signout_test.go
+++ b/integrations/signout_test.go
@@ -18,7 +18,7 @@ func TestSignOut(t *testing.T) {
session.MakeRequest(t, req, http.StatusFound)
// try to view a private repo, should fail
- req = NewRequest(t, "GET", "/user2/repo2/")
+ req = NewRequest(t, "GET", "/user2/repo2")
session.MakeRequest(t, req, http.StatusNotFound)
// invalidate cached cookies for user2, for subsequent tests