Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-10-12 13:58:13 +0300
committerNick Thomas <nick@gitlab.com>2018-10-12 13:58:13 +0300
commit9d74b4230f907b167fd59f296585ca569d36734b (patch)
tree86280985e01958186f3de9dc1a868899e1253982
parentd33590ec85ed14ba7aaa824890ef562ff9967d7d (diff)
parente61224b2348b733ab7038e56f42771652d8fc3f3 (diff)
Merge branch '170-404-serving-projects-with-capital-letters' into 'master'
Resolve "404 serving projects with capital letters" Closes #170 See merge request gitlab-org/gitlab-pages!114
-rw-r--r--acceptance_test.go43
-rw-r--r--internal/domain/domain.go3
-rw-r--r--internal/domain/map_test.go1
-rw-r--r--shared/pages/CapitalGroup/CapitalProject/public/index.html1
-rw-r--r--shared/pages/CapitalGroup/project/public/index.html1
-rw-r--r--shared/pages/group/CapitalProject/public/index.html1
6 files changed, 43 insertions, 7 deletions
diff --git a/acceptance_test.go b/acceptance_test.go
index 17eb7cb4..4100fde1 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -103,12 +103,43 @@ func TestKnownHostReturns200(t *testing.T) {
teardown := RunPagesProcess(t, *pagesBinary, listeners, "")
defer teardown()
- for _, spec := range listeners {
- rsp, err := GetPageFromListener(t, spec, "group.gitlab-example.com", "project/")
+ tests := []struct {
+ name string
+ host string
+ path string
+ }{
+ {
+ name: "lower case",
+ host: "group.gitlab-example.com",
+ path: "project/",
+ },
+ {
+ name: "capital project",
+ host: "group.gitlab-example.com",
+ path: "CapitalProject/",
+ },
+ {
+ name: "capital group",
+ host: "CapitalGroup.gitlab-example.com",
+ path: "project/",
+ },
+ {
+ name: "capital group and project",
+ host: "CapitalGroup.gitlab-example.com",
+ path: "CapitalProject/",
+ },
+ }
- require.NoError(t, err)
- rsp.Body.Close()
- assert.Equal(t, http.StatusOK, rsp.StatusCode)
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ for _, spec := range listeners {
+ rsp, err := GetPageFromListener(t, spec, test.host, test.path)
+
+ require.NoError(t, err)
+ rsp.Body.Close()
+ assert.Equal(t, http.StatusOK, rsp.StatusCode)
+ }
+ })
}
}
@@ -298,7 +329,7 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) {
body, _ := ioutil.ReadAll(resp.Body)
assert.Contains(t, string(body), "gitlab_pages_http_sessions_active 0")
- assert.Contains(t, string(body), "gitlab_pages_domains_served_total 13")
+ assert.Contains(t, string(body), "gitlab_pages_domains_served_total 14")
}
}
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index c9bda506..261707cf 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -118,7 +118,8 @@ func (d *D) getProjectWithSubpath(r *http.Request) (*project, string, string) {
// If present, these projects shadow the group domain.
split := strings.SplitN(r.URL.Path, "/", 3)
if len(split) >= 2 {
- if project := d.projects[split[1]]; project != nil {
+ projectName := strings.ToLower(split[1])
+ if project := d.projects[projectName]; project != nil {
return project, split[1], strings.Join(split[2:], "/")
}
}
diff --git a/internal/domain/map_test.go b/internal/domain/map_test.go
index 31ebc016..a2b2b575 100644
--- a/internal/domain/map_test.go
+++ b/internal/domain/map_test.go
@@ -53,6 +53,7 @@ func TestReadProjects(t *testing.T) {
"no.cert.com",
"private.domain.com",
"group.auth.test.io",
+ "capitalgroup.test.io",
}
for _, expected := range domains {
diff --git a/shared/pages/CapitalGroup/CapitalProject/public/index.html b/shared/pages/CapitalGroup/CapitalProject/public/index.html
new file mode 100644
index 00000000..e977a6bf
--- /dev/null
+++ b/shared/pages/CapitalGroup/CapitalProject/public/index.html
@@ -0,0 +1 @@
+Capital Group & Project
diff --git a/shared/pages/CapitalGroup/project/public/index.html b/shared/pages/CapitalGroup/project/public/index.html
new file mode 100644
index 00000000..6f2b9967
--- /dev/null
+++ b/shared/pages/CapitalGroup/project/public/index.html
@@ -0,0 +1 @@
+Capital Group
diff --git a/shared/pages/group/CapitalProject/public/index.html b/shared/pages/group/CapitalProject/public/index.html
new file mode 100644
index 00000000..e1b52676
--- /dev/null
+++ b/shared/pages/group/CapitalProject/public/index.html
@@ -0,0 +1 @@
+Capital Project