From 6dcef7f2f7732e8d580a01bdf487e434b2a6fbca Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 2 Oct 2023 15:56:55 +0800 Subject: [PATCH] Test more templates for if they contain an error (#27367) (cherry picked from commit 439a0cca2c84c83650fa94dea0bc9d36af347a13) (cherry picked from commit a4ee21cb5be71a5e07a161f5e92079f1c42feea6) (cherry picked from commit 22a32ef309cc1028e01c4533bf1d394d7e6941e9) (cherry picked from commit 7d748224000245b97aa56a0e0e48d2b9aaa175b9) (cherry picked from commit cb92fad0efbc888caaf2bfdabb7919d1253abe9b) (cherry picked from commit a647f7d9aaf21f04e686cf28a631246713bd2838) (cherry picked from commit abe5a0343d8084481a70d24a845a6469bfa84eaf) --- models/fixtures/repo_unit.yml | 20 ++++++++++++++++++++ tests/integration/links_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/models/fixtures/repo_unit.yml b/models/fixtures/repo_unit.yml index c22eb8c2a2..0104419550 100644 --- a/models/fixtures/repo_unit.yml +++ b/models/fixtures/repo_unit.yml @@ -649,3 +649,23 @@ repo_id: 49 type: 2 created_unix: 946684810 + +- + id: 98 + repo_id: 1 + type: 8 + created_unix: 946684810 + +- + id: 99 + repo_id: 1 + type: 9 + config: "{}" + created_unix: 946684810 + +- + id: 100 + repo_id: 1 + type: 10 + config: "{}" + created_unix: 946684810 diff --git a/tests/integration/links_test.go b/tests/integration/links_test.go index 91655833af..a3937dd697 100644 --- a/tests/integration/links_test.go +++ b/tests/integration/links_test.go @@ -159,6 +159,7 @@ func testLinksAsUser(userName string, t *testing.T) { "/releases/new", //"/wiki/_pages", "/wiki/?action=_new", + "/activity", } for _, repo := range apiRepos { @@ -174,3 +175,35 @@ func TestLinksLogin(t *testing.T) { testLinksAsUser("user2", t) } + +func TestRepoLinks(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + // repo1 has enabled almost features, so we can test most links + repoLink := "/user2/repo1" + links := []string{ + "/actions", + "/packages", + "/projects", + } + + // anonymous user + for _, link := range links { + req := NewRequest(t, "GET", repoLink+link) + MakeRequest(t, req, http.StatusOK) + } + + // admin/owner user + session := loginUser(t, "user1") + for _, link := range links { + req := NewRequest(t, "GET", repoLink+link) + session.MakeRequest(t, req, http.StatusOK) + } + + // non-admin non-owner user + session = loginUser(t, "user2") + for _, link := range links { + req := NewRequest(t, "GET", repoLink+link) + session.MakeRequest(t, req, http.StatusOK) + } +}