1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package acceptance_test
import (
"net/http"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-pages/internal/feature"
"gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
)
func TestCustomRoot(t *testing.T) {
t.Setenv(feature.ConfigurableRoot.EnvVariable, "true")
RunPagesProcess(t)
tests := []struct {
name string
requestDomain string
requestPath string
redirectURL string
httpStatus int
}{
{
name: "custom root",
requestDomain: "custom-root.gitlab-example.com",
httpStatus: http.StatusOK,
},
{
name: "custom root legacy",
requestDomain: "custom-root-legacy.gitlab-example.com",
httpStatus: http.StatusOK,
},
{
name: "custom root explicitly public",
requestDomain: "custom-root-explicit-public.gitlab-example.com",
httpStatus: http.StatusOK,
},
{
name: "project does not have pages files inside a subdirectory",
requestDomain: "custom-root-no-subdir.gitlab-example.com",
httpStatus: http.StatusNotFound,
},
{
name: "used a root dir value that does not exist inside the archive",
requestDomain: "custom-root-wrong-dir.gitlab-example.com",
httpStatus: http.StatusNotFound,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
rsp, err := GetRedirectPage(t, httpsListener, test.requestDomain, test.requestPath)
require.NoError(t, err)
testhelpers.Close(t, rsp.Body)
require.Equal(t, test.httpStatus, rsp.StatusCode)
})
}
}
|