add basic test cases for ALPN protocols

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2023-10-28 13:07:23 +02:00
parent 7da5d8fcea
commit 9bcdc90ca8
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF

View file

@ -1750,6 +1750,17 @@ func TestSQLPlaceholderLimits(t *testing.T) {
}
}
func TestALPNProtocols(t *testing.T) {
protocols := util.GetALPNProtocols(nil)
assert.Equal(t, []string{"http/1.1", "h2"}, protocols)
protocols = util.GetALPNProtocols([]string{"invalid1", "invalid2"})
assert.Equal(t, []string{"http/1.1", "h2"}, protocols)
protocols = util.GetALPNProtocols([]string{"invalid1", "h2", "invalid2"})
assert.Equal(t, []string{"h2"}, protocols)
protocols = util.GetALPNProtocols([]string{"h2", "http/1.1"})
assert.Equal(t, []string{"h2", "http/1.1"}, protocols)
}
func BenchmarkBcryptHashing(b *testing.B) {
bcryptPassword := "bcryptpassword"
for i := 0; i < b.N; i++ {