diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2023-06-08 09:54:32 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2023-06-08 09:54:32 +0300 |
commit | e64dbc90aec2a9e75e3e8b8141cb25ac0a89554f (patch) | |
tree | ab4c8aea756d110ec1e676ee6088327809803b2e /internal/serving/disk/local/serving_test.go | |
parent | 5a6388a4479dcfbd522a55b525127f9096e79cdc (diff) | |
parent | 3cbfc605d0ede7e0a79d912fac01d610089f7eef (diff) |
Merge branch '1056-use-pages-root-directory-from-api' into 'master'
Use pages root directory from API
Closes #1056
See merge request https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/859
Merged-by: Jaime Martinez <jmartinez@gitlab.com>
Approved-by: Jaime Martinez <jmartinez@gitlab.com>
Reviewed-by: Kassio Borges <kborges@gitlab.com>
Reviewed-by: Jaime Martinez <jmartinez@gitlab.com>
Reviewed-by: Janis Altherr <jaltherr@gitlab.com>
Co-authored-by: janis <jaltherr@gitlab.com>
Diffstat (limited to 'internal/serving/disk/local/serving_test.go')
-rw-r--r-- | internal/serving/disk/local/serving_test.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/internal/serving/disk/local/serving_test.go b/internal/serving/disk/local/serving_test.go index dbb14138..11a328c3 100644 --- a/internal/serving/disk/local/serving_test.go +++ b/internal/serving/disk/local/serving_test.go @@ -20,34 +20,40 @@ func TestDisk_ServeFileHTTP(t *testing.T) { path string expectedStatus int expectedBody string + rootDirectory string }{ "accessing /index.html": { - vfsPath: "group/serving/public", + vfsPath: "group/serving", path: "/index.html", + rootDirectory: "public", expectedStatus: http.StatusOK, expectedBody: "HTML Document", }, "accessing /": { - vfsPath: "group/serving/public", + vfsPath: "group/serving", path: "/", + rootDirectory: "public", expectedStatus: http.StatusOK, expectedBody: "HTML Document", }, "accessing without /": { - vfsPath: "group/serving/public", + vfsPath: "group/serving", path: "", + rootDirectory: "public", expectedStatus: http.StatusFound, expectedBody: `<a href="//group.gitlab-example.com/serving/">Found</a>.`, }, "accessing vfs path that is missing": { - vfsPath: "group/serving/public-missing", - path: "/index.html", + vfsPath: "group/serving/public-missing", + path: "/index.html", + rootDirectory: "public", // we expect the status to not be set expectedStatus: 0, }, "accessing vfs path that is forbidden (like file)": { vfsPath: "group/serving/public/index.html", path: "/index.html", + rootDirectory: "public", expectedStatus: http.StatusInternalServerError, }, } @@ -64,8 +70,9 @@ func TestDisk_ServeFileHTTP(t *testing.T) { Writer: w, Request: r, LookupPath: &serving.LookupPath{ - Prefix: "/serving/", - Path: test.vfsPath, + Prefix: "/serving/", + Path: test.vfsPath, + RootDirectory: test.rootDirectory, }, SubPath: test.path, } |