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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package acceptance_test
import (
"fmt"
"net"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestEnvironmentVariablesConfig(t *testing.T) {
skipUnlessEnabled(t)
envVarValue := "LISTEN_HTTP=" + net.JoinHostPort(httpListener.Host, httpListener.Port)
RunPagesProcessWithStubGitLabServer(t,
withoutWait,
withListeners([]ListenSpec{}), // explicitly disable listeners for this test
withEnv([]string{envVarValue}),
)
require.NoError(t, httpListener.WaitUntilRequestSucceeds(nil))
rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/")
require.NoError(t, err)
rsp.Body.Close()
require.Equal(t, http.StatusOK, rsp.StatusCode)
}
func TestMixedConfigSources(t *testing.T) {
skipUnlessEnabled(t)
envVarValue := "LISTEN_HTTP=" + net.JoinHostPort(httpListener.Host, httpListener.Port)
RunPagesProcessWithStubGitLabServer(t,
withoutWait,
withListeners([]ListenSpec{httpsListener}),
withEnv([]string{envVarValue}),
)
for _, listener := range []ListenSpec{httpListener, httpsListener} {
require.NoError(t, listener.WaitUntilRequestSucceeds(nil))
rsp, err := GetPageFromListener(t, listener, "group.gitlab-example.com", "project/")
require.NoError(t, err)
rsp.Body.Close()
require.Equal(t, http.StatusOK, rsp.StatusCode)
}
}
func TestMultipleListenersFromEnvironmentVariables(t *testing.T) {
skipUnlessEnabled(t)
listenSpecs := []ListenSpec{{"http", "127.0.0.1", "37001"}, {"http", "127.0.0.1", "37002"}}
envVarValue := fmt.Sprintf("LISTEN_HTTP=%s,%s", net.JoinHostPort("127.0.0.1", "37001"), net.JoinHostPort("127.0.0.1", "37002"))
RunPagesProcessWithStubGitLabServer(t,
withoutWait,
withListeners([]ListenSpec{}), // explicitly disable listeners for this test
withEnv([]string{envVarValue}),
)
for _, listener := range listenSpecs {
require.NoError(t, listener.WaitUntilRequestSucceeds(nil))
rsp, err := GetPageFromListener(t, listener, "group.gitlab-example.com", "project/")
require.NoError(t, err)
rsp.Body.Close()
require.Equal(t, http.StatusOK, rsp.StatusCode)
}
}
// TODO: remove along chroot https://gitlab.com/gitlab-org/gitlab-pages/-/issues/561
func TestEnableJailFromEnvironment(t *testing.T) {
out, teardown := runPagesProcess(t,
true,
*pagesBinary,
[]ListenSpec{httpListener},
"",
[]string{
"DAEMON_ENABLE_JAIL=true",
},
"-domain-config-source", "disk",
)
t.Cleanup(teardown)
require.Eventually(t, func() bool {
require.Contains(t, out.String(), "\"daemon-enable-jail\":true")
return true
}, time.Second, 10*time.Millisecond)
rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/")
require.NoError(t, err)
rsp.Body.Close()
require.Equal(t, http.StatusOK, rsp.StatusCode)
}
|