mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Backport #27486 by @lunny Fix #27204 This PR allows `/<username>/<reponame>/attachments/<uuid>` access with personal access token and also changed attachments API download url to it so it can be download correctly. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		@@ -85,6 +85,10 @@ func Test_isGitRawOrLFSPath(t *testing.T) {
 | 
			
		||||
			"/owner/repo/releases/download/tag/repo.tar.gz",
 | 
			
		||||
			true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			"/owner/repo/attachments/6d92a9ee-5d8b-4993-97c9-6181bdaa8955",
 | 
			
		||||
			true,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	lfsTests := []string{
 | 
			
		||||
		"/owner/repo/info/lfs/",
 | 
			
		||||
@@ -104,11 +108,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 := isGitRawReleaseOrLFSPath(req); got != tt.want {
 | 
			
		||||
			if got := isGitRawOrAttachOrLFSPath(req); got != tt.want {
 | 
			
		||||
				t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want)
 | 
			
		||||
			}
 | 
			
		||||
			setting.LFS.StartServer = true
 | 
			
		||||
			if got := isGitRawReleaseOrLFSPath(req); got != tt.want {
 | 
			
		||||
			if got := isGitRawOrAttachOrLFSPath(req); got != tt.want {
 | 
			
		||||
				t.Errorf("isGitOrLFSPath() = %v, want %v", got, tt.want)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
@@ -117,11 +121,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 := isGitRawReleaseOrLFSPath(req); got != setting.LFS.StartServer {
 | 
			
		||||
				t.Errorf("isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawReleasePathRe.MatchString(tt))
 | 
			
		||||
			if got := isGitRawOrAttachOrLFSPath(req); got != setting.LFS.StartServer {
 | 
			
		||||
				t.Errorf("isGitOrLFSPath(%q) = %v, want %v, %v", tt, got, setting.LFS.StartServer, gitRawOrAttachPathRe.MatchString(tt))
 | 
			
		||||
			}
 | 
			
		||||
			setting.LFS.StartServer = true
 | 
			
		||||
			if got := isGitRawReleaseOrLFSPath(req); got != setting.LFS.StartServer {
 | 
			
		||||
			if got := isGitRawOrAttachOrLFSPath(req); got != setting.LFS.StartServer {
 | 
			
		||||
				t.Errorf("isGitOrLFSPath(%q) = %v, want %v", tt, got, setting.LFS.StartServer)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user