Skip to content
Snippets Groups Projects
Commit 9091d1af authored by Stan Hu's avatar Stan Hu Committed by Stan Hu
Browse files

Fix regexp matching when using API with group/project syntax

Closes gitlab-org/gitlab-ce#4124
parent bd5ec001
No related branches found
No related tags found
1 merge request!21Fix regexp matching when using API with group/project syntax
Pipeline #
Loading
Loading
@@ -50,7 +50,9 @@ const projectPattern = `^/[^/]+/[^/]+/`
const gitProjectPattern = `^/[^/]+/[^/]+\.git/`
 
const apiPattern = `^/api/`
const projectsAPIPattern = `^/api/v3/projects/[^/]+/`
// Handle project IDs in two forms: integer ID and group/project_name
const projectsAPIPattern = `^/api/v3/projects/([^/]+|[^/]+/[^/]+)/`
 
const ciAPIPattern = `^/ci/api/`
 
Loading
Loading
Loading
Loading
@@ -196,6 +196,25 @@ func TestAllowedApiDownloadZip(t *testing.T) {
runOrFail(t, extractCmd)
}
 
func TestAllowedApiDownloadZipWithProjectName(t *testing.T) {
prepareDownloadDir(t)
// Prepare test server and backend
archiveName := "foobar.zip"
ts := testAuthServer(nil, 200, archiveOkBody(t, archiveName))
defer ts.Close()
ws := startWorkhorseServer(ts.URL)
defer ws.Close()
downloadCmd := exec.Command("curl", "-J", "-O", fmt.Sprintf("%s/api/v3/projects/%s/repository/archive.zip", ws.URL, testProject))
downloadCmd.Dir = scratchDir
runOrFail(t, downloadCmd)
extractCmd := exec.Command("unzip", archiveName)
extractCmd.Dir = scratchDir
runOrFail(t, extractCmd)
}
func TestDownloadCacheHit(t *testing.T) {
prepareDownloadDir(t)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment