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:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2021-09-16 01:42:11 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-01-24 15:26:26 +0300
commit1af66db0e4204920a496530fac19c6424a60b8f7 (patch)
tree46ef82e0ee67d23c88cf068a3b040c0880cba523
parent88656e8f55e74ea5d7adf703e36dac23726a139b (diff)
test: add valid tls config tests
-rw-r--r--internal/config/tls/tls_test.go24
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")