diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-10-14 07:19:11 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-10-14 07:19:11 +0300 |
commit | 0db3e9e21a8c6541ffeb955f66284678b901d301 (patch) | |
tree | c8bf46828c7b3b09fb6cd4e12357b2cd05ce3406 /internal/source/gitlab | |
parent | 2533637ca527243c743458a573f80cc6dddd4644 (diff) |
Revert "Remove serving.Handler"371-refactor-domain-package
This reverts commit 0fcc0667e6f2e78ca85abdb5c9f631a964dd77c2.
Diffstat (limited to 'internal/source/gitlab')
-rw-r--r-- | internal/source/gitlab/factory.go | 5 | ||||
-rw-r--r-- | internal/source/gitlab/factory_test.go | 5 | ||||
-rw-r--r-- | internal/source/gitlab/gitlab.go | 4 | ||||
-rw-r--r-- | internal/source/gitlab/gitlab_test.go | 10 |
4 files changed, 11 insertions, 13 deletions
diff --git a/internal/source/gitlab/factory.go b/internal/source/gitlab/factory.go index 0df2e8c6..41f7ea56 100644 --- a/internal/source/gitlab/factory.go +++ b/internal/source/gitlab/factory.go @@ -13,16 +13,15 @@ import ( // fabricateLookupPath fabricates a serving LookupPath based on the API LookupPath // `size` argument is DEPRECATED, see // https://gitlab.com/gitlab-org/gitlab-pages/issues/272 -func fabricateLookupPath(size int, lookup api.LookupPath, subPath string) *serving.LookupPath { +func fabricateLookupPath(size int, lookup api.LookupPath) *serving.LookupPath { return &serving.LookupPath{ ServingType: lookup.Source.Type, Path: lookup.Source.Path, Prefix: lookup.Prefix, - IsNamespaceProject: lookup.Prefix == "/" && size > 1, + IsNamespaceProject: (lookup.Prefix == "/" && size > 1), IsHTTPSOnly: lookup.HTTPSOnly, HasAccessControl: lookup.AccessControl, ProjectID: uint64(lookup.ProjectID), - SubPath: subPath, } } diff --git a/internal/source/gitlab/factory_test.go b/internal/source/gitlab/factory_test.go index 804f5d02..2f3e1994 100644 --- a/internal/source/gitlab/factory_test.go +++ b/internal/source/gitlab/factory_test.go @@ -15,17 +15,16 @@ func TestFabricateLookupPath(t *testing.T) { t.Run("when lookup path is not a namespace project", func(t *testing.T) { lookup := api.LookupPath{Prefix: "/something"} - path := fabricateLookupPath(1, lookup, "/subpath") + path := fabricateLookupPath(1, lookup) require.Equal(t, path.Prefix, "/something") - require.Equal(t, path.SubPath, "/subpath") require.False(t, path.IsNamespaceProject) }) t.Run("when lookup path is a namespace project", func(t *testing.T) { lookup := api.LookupPath{Prefix: "/"} - path := fabricateLookupPath(2, lookup, "") + path := fabricateLookupPath(2, lookup) require.Equal(t, path.Prefix, "/") require.True(t, path.IsNamespaceProject) diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go index eecc2f2f..67c4eb6b 100644 --- a/internal/source/gitlab/gitlab.go +++ b/internal/source/gitlab/gitlab.go @@ -96,8 +96,8 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.Request, error) { return &serving.Request{ Serving: fabricateServing(lookup), - LookupPath: fabricateLookupPath(size, lookup, subPath), - }, nil + LookupPath: fabricateLookupPath(size, lookup), + SubPath: subPath}, nil } } diff --git a/internal/source/gitlab/gitlab_test.go b/internal/source/gitlab/gitlab_test.go index 5537a033..e6f194ee 100644 --- a/internal/source/gitlab/gitlab_test.go +++ b/internal/source/gitlab/gitlab_test.go @@ -44,7 +44,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project/", response.LookupPath.Path) - require.Equal(t, "", response.LookupPath.SubPath) + require.Equal(t, "", response.SubPath) require.False(t, response.LookupPath.IsNamespaceProject) }) @@ -57,7 +57,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project/", response.LookupPath.Path) - require.Equal(t, "path/index.html", response.LookupPath.SubPath) + require.Equal(t, "path/index.html", response.SubPath) require.False(t, response.LookupPath.IsNamespaceProject) }) @@ -70,7 +70,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project-3/", response.LookupPath.Path) - require.Equal(t, "", response.LookupPath.SubPath) + require.Equal(t, "", response.SubPath) require.True(t, response.LookupPath.IsNamespaceProject) }) @@ -82,7 +82,7 @@ func TestResolve(t *testing.T) { require.NoError(t, err) require.Equal(t, "/", response.LookupPath.Prefix) - require.Equal(t, "path/to/index.html", response.LookupPath.SubPath) + require.Equal(t, "path/to/index.html", response.SubPath) require.Equal(t, "some/path/to/project-3/", response.LookupPath.Path) require.True(t, response.LookupPath.IsNamespaceProject) }) @@ -95,6 +95,6 @@ func TestResolve(t *testing.T) { require.NoError(t, err) require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) - require.Equal(t, "index.html", response.LookupPath.SubPath) + require.Equal(t, "index.html", response.SubPath) }) } |