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/encodings_test.go')
-rw-r--r--test/acceptance/encodings_test.go78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/acceptance/encodings_test.go b/test/acceptance/encodings_test.go
new file mode 100644
index 00000000..9b874205
--- /dev/null
+++ b/test/acceptance/encodings_test.go
@@ -0,0 +1,78 @@
+package acceptance_test
+
+import (
+ "mime"
+ "net/http"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestMIMETypes(t *testing.T) {
+ skipUnlessEnabled(t)
+ teardown := RunPagesProcessWithoutWait(t, *pagesBinary, listeners, "")
+ defer teardown()
+
+ require.NoError(t, httpListener.WaitUntilRequestSucceeds(nil))
+
+ tests := map[string]struct {
+ file string
+ expectedContentType string
+ }{
+ "manifest_json": {
+ file: "file.webmanifest",
+ expectedContentType: "application/manifest+json",
+ },
+ }
+
+ for name, tt := range tests {
+ t.Run(name, func(t *testing.T) {
+ rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/"+tt.file)
+ require.NoError(t, err)
+ defer rsp.Body.Close()
+
+ require.Equal(t, http.StatusOK, rsp.StatusCode)
+ mt, _, err := mime.ParseMediaType(rsp.Header.Get("Content-Type"))
+ require.NoError(t, err)
+ require.Equal(t, tt.expectedContentType, mt)
+ })
+ }
+}
+
+func TestCompressedEncoding(t *testing.T) {
+ skipUnlessEnabled(t)
+
+ tests := []struct {
+ name string
+ host string
+ path string
+ encoding string
+ }{
+ {
+ "gzip encoding",
+ "group.gitlab-example.com",
+ "index.html",
+ "gzip",
+ },
+ {
+ "brotli encoding",
+ "group.gitlab-example.com",
+ "index.html",
+ "br",
+ },
+ }
+
+ teardown := RunPagesProcess(t, *pagesBinary, listeners, "")
+ defer teardown()
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ rsp, err := GetCompressedPageFromListener(t, httpListener, "group.gitlab-example.com", "index.html", tt.encoding)
+ require.NoError(t, err)
+ defer rsp.Body.Close()
+
+ require.Equal(t, http.StatusOK, rsp.StatusCode)
+ require.Equal(t, tt.encoding, rsp.Header.Get("Content-Encoding"))
+ })
+ }
+}