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:
Diffstat (limited to 'test/acceptance/proxyv2_test.go')
-rw-r--r--test/acceptance/proxyv2_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/acceptance/proxyv2_test.go b/test/acceptance/proxyv2_test.go
new file mode 100644
index 00000000..c407ea19
--- /dev/null
+++ b/test/acceptance/proxyv2_test.go
@@ -0,0 +1,52 @@
+package acceptance_test
+
+import (
+ "io/ioutil"
+ "net/http"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestProxyv2(t *testing.T) {
+ skipUnlessEnabled(t)
+
+ logBuf, teardown := RunPagesProcessWithOutput(t, *pagesBinary, listeners, "")
+ defer teardown()
+
+ // the dummy client IP 10.1.1.1 is set by TestProxyv2Client
+ tests := map[string]struct {
+ host string
+ urlSuffix string
+ expectedStatusCode int
+ expectedContent string
+ expectedLog string
+ }{
+ "basic_proxyv2_request": {
+ host: "group.gitlab-example.com",
+ urlSuffix: "project/",
+ expectedStatusCode: http.StatusOK,
+ expectedContent: "project-subdir\n",
+ expectedLog: "group.gitlab-example.com 10.1.1.1",
+ },
+ }
+
+ for name, tt := range tests {
+ t.Run(name, func(t *testing.T) {
+ logBuf.Reset()
+
+ response, err := GetPageFromListener(t, httpsProxyv2Listener, tt.host, tt.urlSuffix)
+ require.NoError(t, err)
+ defer response.Body.Close()
+
+ require.Equal(t, tt.expectedStatusCode, response.StatusCode)
+
+ body, err := ioutil.ReadAll(response.Body)
+ require.NoError(t, err)
+
+ require.Contains(t, string(body), tt.expectedContent, "content mismatch")
+
+ require.Contains(t, logBuf.String(), tt.expectedLog, "log mismatch")
+ })
+ }
+}