diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2022-01-26 07:41:50 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2022-01-26 07:41:50 +0300 |
commit | 9afd47babef04c91e9fd174c3395e75687a6d6af (patch) | |
tree | e695d75c499fc234111920595501d5a945c2c744 /internal | |
parent | c27391b4ab52f19f0457550d50aff427c370f620 (diff) | |
parent | 1af66db0e4204920a496530fac19c6424a60b8f7 (diff) |
Merge branch 'test/valid-tls' into 'master'
test: add valid tls config tests
See merge request gitlab-org/gitlab-pages!581
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/tls/tls_test.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/internal/config/tls/tls_test.go b/internal/config/tls/tls_test.go index 06704a64..7146d904 100644 --- a/internal/config/tls/tls_test.go +++ b/internal/config/tls/tls_test.go @@ -29,7 +29,7 @@ var getCertificate = func(ch *tls.ClientHelloInfo) (*tls.Certificate, error) { return nil, nil } -func TestValidateTLSVersions(t *testing.T) { +func TestInvalidTLSVersions(t *testing.T) { tests := map[string]struct { tlsMin string tlsMax string @@ -48,6 +48,28 @@ func TestValidateTLSVersions(t *testing.T) { } } +func TestValidTLSVersions(t *testing.T) { + tests := map[string]struct { + tlsMin string + tlsMax string + }{ + "tls 1.3 only": {tlsMin: "tls1.3", tlsMax: "tls1.3"}, + "tls 1.2 only": {tlsMin: "tls1.2", tlsMax: "tls1.2"}, + "tls 1.3 max": {tlsMax: "tls1.3"}, + "tls 1.2 max": {tlsMax: "tls1.2"}, + "tls 1.3+": {tlsMin: "tls1.3"}, + "tls 1.2+": {tlsMin: "tls1.2"}, + "default": {}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := ValidateTLSVersions(tc.tlsMin, tc.tlsMax) + require.NoError(t, err) + }) + } +} + func TestInvalidKeyPair(t *testing.T) { _, err := Create([]byte(``), []byte(``), getCertificate, false, tls.VersionTLS11, tls.VersionTLS12) require.EqualError(t, err, "tls: failed to find any PEM data in certificate input") |