summaryrefslogtreecommitdiffstats
path: root/services/auth/auth_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-02 17:48:48 +0200
committerGitHub <noreply@github.com>2021-09-02 17:48:48 +0200
commita75b2f2842e3bfa462da4d205194a59824c2dde8 (patch)
treed17724696e6e5a1c4b2ad87323817d9296fe8578 /services/auth/auth_test.go
parentPrevent leave changes dialogs due to autofill fields (#16912) (diff)
downloadforgejo-a75b2f2842e3bfa462da4d205194a59824c2dde8.tar.xz
forgejo-a75b2f2842e3bfa462da4d205194a59824c2dde8.zip
Allow BASIC authentication access to /:owner/:repo/releases/download/* (#16916)
Duplicate #15987 to allow access to releases download through BASIC authentication. Fix #16914 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/auth/auth_test.go')
-rw-r--r--services/auth/auth_test.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/services/auth/auth_test.go b/services/auth/auth_test.go
index f6b43835f4..b0d23bb4e9 100644
--- a/services/auth/auth_test.go
+++ b/services/auth/auth_test.go
@@ -83,6 +83,10 @@ func Test_isGitRawOrLFSPath(t *testing.T) {
"/owner/repo/commit/123456789012345678921234567893124567894",
false,
},
+ {
+ "/owner/repo/releases/download/tag/repo.tar.gz",
+ true,
+ },
}
lfsTests := []string{
"/owner/repo/info/lfs/",
@@ -102,11 +106,11 @@ func Test_isGitRawOrLFSPath(t *testing.T) {
t.Run(tt.path, func(t *testing.T) {
req, _ := http.NewRequest("POST", "http://localhost"+tt.path, nil)
setting.LFS.StartServer = false
- if got := isGitRawOrLFSPath(req); got != tt.want {
+ if got := isGitRawReleaseOrLFSPath(req); got != tt.want {
t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want)
}
setting.LFS.StartServer = true
- if got := isGitRawOrLFSPath(req); got != tt.want {
+ if got := isGitRawReleaseOrLFSPath(req); got != tt.want {
t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want)
}
})
@@ -115,11 +119,11 @@ func Test_isGitRawOrLFSPath(t *testing.T) {
t.Run(tt, func(t *testing.T) {
req, _ := http.NewRequest("POST", tt, nil)
setting.LFS.StartServer = false
- if got := isGitRawOrLFSPath(req); got != setting.LFS.StartServer {
- t.Errorf("isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawPathRe.MatchString(tt))
+ if got := isGitRawReleaseOrLFSPath(req); got != setting.LFS.StartServer {
+ t.Errorf("isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawReleasePathRe.MatchString(tt))
}
setting.LFS.StartServer = true
- if got := isGitRawOrLFSPath(req); got != setting.LFS.StartServer {
+ if got := isGitRawReleaseOrLFSPath(req); got != setting.LFS.StartServer {
t.Errorf("isGitOrLFSPath(%q) = %v, want %v", tt, got, setting.LFS.StartServer)
}
})