mirror of
https://git.vectorsigma.ru/public/AdGuardHome.git
synced 2026-07-28 23:49:09 +00:00
Merge in DNS/adguard-home from AGDNS-3060-imp-gocognit-logs to master
Squashed commit of the following:
commit 3026dc35662c71c125c60198f828e7da7e8e5b4f
Merge: 2b56f4236 df258512d
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Jul 30 13:00:44 2025 +0300
Merge branch 'master' into AGDNS-3060-imp-gocognit-logs
commit 2b56f423649ef0e5734a3a1d9c0b5df178462e29
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Fri Jul 25 14:41:40 2025 +0300
all: imp docs
commit 101d043c85e8b813f6b28751edeeb6c6b43578a9
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Jul 23 20:09:38 2025 +0300
all: imp code
commit 87cfa502f7abf5b8f8a18b71f4a99aab9a066961
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Jul 23 14:51:33 2025 +0300
all: imp code
commit 07c1a04a4022f4e38282a538670d575fba949bb2
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Tue Jul 22 20:04:58 2025 +0300
all: imp gocognit, logs
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package aghtls_test
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghtls"
|
|
"github.com/AdguardTeam/golibs/logutil/slogutil"
|
|
"github.com/AdguardTeam/golibs/testutil"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// testTimeout is a common timeout for tests and contexts.
|
|
const testTimeout time.Duration = 1 * time.Second
|
|
|
|
func TestParseCiphers(t *testing.T) {
|
|
aghtls.Init(testutil.ContextWithTimeout(t, testTimeout), slogutil.NewDiscardLogger())
|
|
|
|
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)
|
|
})
|
|
}
|
|
}
|