mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-28 09:58:52 +03:00
9c9d6b48e3
Merge in DNS/adguard-home from imp-tests to master Squashed commit of the following: commit ea5b4e7a93359ae4800f75e77d02944a4f5d2df8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Oct 27 15:12:45 2022 +0300 all: imp tests, use testutil
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package aghtls_test
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"testing"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghtls"
|
|
"github.com/AdguardTeam/golibs/testutil"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
testutil.DiscardLogOutput(m)
|
|
}
|
|
|
|
func TestParseCiphers(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
wantErrMsg string
|
|
want []uint16
|
|
in []string
|
|
}{{
|
|
name: "nil",
|
|
wantErrMsg: "",
|
|
want: nil,
|
|
in: nil,
|
|
}, {
|
|
name: "empty",
|
|
wantErrMsg: "",
|
|
want: []uint16{},
|
|
in: []string{},
|
|
}, {}, {
|
|
name: "one",
|
|
wantErrMsg: "",
|
|
want: []uint16{tls.TLS_AES_128_GCM_SHA256},
|
|
in: []string{"TLS_AES_128_GCM_SHA256"},
|
|
}, {
|
|
name: "several",
|
|
wantErrMsg: "",
|
|
want: []uint16{tls.TLS_AES_128_GCM_SHA256, tls.TLS_AES_256_GCM_SHA384},
|
|
in: []string{"TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"},
|
|
}, {
|
|
name: "bad",
|
|
wantErrMsg: `unknown cipher "bad_cipher"`,
|
|
want: nil,
|
|
in: []string{"bad_cipher"},
|
|
}}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got, err := aghtls.ParseCiphers(tc.in)
|
|
testutil.AssertErrorMsg(t, tc.wantErrMsg, err)
|
|
assert.Equal(t, tc.want, got)
|
|
})
|
|
}
|
|
}
|