Welcome to mirror list, hosted at ThFree Co, Russian Federation.

validateargs_test.go « validateargs « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7bf2ec105eb7bb91e63465c7cf504f1360c274a8 (plain)
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
package validateargs

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestValidParams(t *testing.T) {
	args := []string{"gitlab-pages",
		"-listen-http", ":3010",
		"-artifacts-server", "http://192.168.1.123:3000/api/v4",
		"-pages-domain", "127.0.0.1.xip.io"}
	require.NoError(t, Deprecated(args))
	require.NoError(t, NotAllowed(args))
}

func TestInvalidDeprecatedParms(t *testing.T) {
	tests := map[string][]string{
		"Sentry DSN passed":          []string{"gitlab-pages", "-sentry-dsn", "abc123"},
		"Sentry DSN using key=value": []string{"gitlab-pages", "-sentry-dsn=abc123"},
	}

	for name, args := range tests {
		t.Run(name, func(t *testing.T) {
			err := Deprecated(args)
			require.Error(t, err)
			require.Contains(t, err.Error(), deprecatedMessage)
		})
	}
}

func TestInvalidNotAllowedParams(t *testing.T) {
	tests := map[string][]string{
		"Client ID passed":     []string{"gitlab-pages", "-auth-client-id", "abc123"},
		"Client secret passed": []string{"gitlab-pages", "-auth-client-secret", "abc123"},
		"Auth secret passed":   []string{"gitlab-pages", "-auth-secret", "abc123"},
		"Multiple keys passed": []string{"gitlab-pages", "-auth-client-id", "abc123", "-auth-client-secret", "abc123"},
		"key=value":            []string{"gitlab-pages", "-auth-client-id=abc123"},
		"multiple key=value":   []string{"gitlab-pages", "-auth-client-id=abc123", "-auth-client-secret=abc123"},
	}

	for name, args := range tests {
		t.Run(name, func(t *testing.T) {
			err := NotAllowed(args)
			require.Error(t, err)
			require.Contains(t, err.Error(), notAllowedMsg)
		})
	}
}