1
0
Fork 0
forked from forgejo/forgejo

[BRANDING] define the forgejo webhook type

templates/swagger/v1_json.tmpl updated with `make generate-swagger`

(cherry picked from commit 88899c492e)
(cherry picked from commit 7171bd9617)
(cherry picked from commit 1a742446c1)
This commit is contained in:
Earl Warren 2023-01-14 10:07:01 +01:00 committed by Loïc Dachary
parent f1972578f5
commit d7c189d7b2
No known key found for this signature in database
GPG key ID: 992D23B392F9E4F2
13 changed files with 136 additions and 11 deletions

View file

@ -173,3 +173,41 @@ func TestLinksLogin(t *testing.T) {
testLinksAsUser("user2", t)
}
func TestRedirectsWebhooks(t *testing.T) {
defer tests.PrepareTestEnv(t)()
//
// A redirect means the route exists but not if it performs as intended.
//
for _, kind := range []string{"forgejo", "gitea"} {
{
redirects := map[string]string{
"/user2/repo1/settings/hooks/" + kind + "/new": "/user/login",
"/admin/system-hooks/" + kind + "/new": "/user/login",
"/admin/default-hooks/" + kind + "/new": "/user/login",
}
for link, redirectLink := range redirects {
req := NewRequest(t, "GET", link)
resp := MakeRequest(t, req, http.StatusSeeOther)
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
}
}
{
redirects := map[string]string{
"/user2/repo1/settings/hooks/" + kind + "/new": "/",
"/admin/system-hooks/" + kind + "/new": "/",
"/admin/default-hooks/" + kind + "/new": "/",
"/user2/repo1/settings/hooks/" + kind + "/1": "/",
"/admin/hooks/" + kind + "/1": "/",
}
for link, redirectLink := range redirects {
req := NewRequest(t, "POST", link)
resp := MakeRequest(t, req, http.StatusSeeOther)
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
}
}
}
}