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:
authorJaime Martinez <jmartinez@gitlab.com>2020-10-13 06:45:26 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-10-14 07:16:32 +0300
commit0fcc0667e6f2e78ca85abdb5c9f631a964dd77c2 (patch)
treebebae04d6dd5a8a313e02d0e3d9892d1adeb4c20 /internal/source/gitlab
parent6b1237b0fb3d64efb31cb754931ccd0d8302c4d2 (diff)
Remove serving.Handler
Diffstat (limited to 'internal/source/gitlab')
-rw-r--r--internal/source/gitlab/factory.go5
-rw-r--r--internal/source/gitlab/factory_test.go5
-rw-r--r--internal/source/gitlab/gitlab.go4
-rw-r--r--internal/source/gitlab/gitlab_test.go10
4 files changed, 13 insertions, 11 deletions
diff --git a/internal/source/gitlab/factory.go b/internal/source/gitlab/factory.go
index 41f7ea56..0df2e8c6 100644
--- a/internal/source/gitlab/factory.go
+++ b/internal/source/gitlab/factory.go
@@ -13,15 +13,16 @@ 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) *serving.LookupPath {
+func fabricateLookupPath(size int, lookup api.LookupPath, subPath string) *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 2f3e1994..804f5d02 100644
--- a/internal/source/gitlab/factory_test.go
+++ b/internal/source/gitlab/factory_test.go
@@ -15,16 +15,17 @@ 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)
+ path := fabricateLookupPath(1, lookup, "/subpath")
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 67c4eb6b..eecc2f2f 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: subPath}, nil
+ LookupPath: fabricateLookupPath(size, lookup, subPath),
+ }, nil
}
}
diff --git a/internal/source/gitlab/gitlab_test.go b/internal/source/gitlab/gitlab_test.go
index e6f194ee..5537a033 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.SubPath)
+ require.Equal(t, "", response.LookupPath.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.SubPath)
+ require.Equal(t, "path/index.html", response.LookupPath.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.SubPath)
+ require.Equal(t, "", response.LookupPath.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.SubPath)
+ require.Equal(t, "path/to/index.html", response.LookupPath.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.SubPath)
+ require.Equal(t, "index.html", response.LookupPath.SubPath)
})
}