mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
split headers.Authenticate and headers.Authorization (#523)
This commit is contained in:
@@ -3,51 +3,18 @@ package auth
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/base"
|
||||
)
|
||||
|
||||
func TestSenderErrors(t *testing.T) {
|
||||
for _, ca := range []struct {
|
||||
name string
|
||||
hv base.HeaderValue
|
||||
err string
|
||||
}{
|
||||
{
|
||||
"invalid method",
|
||||
base.HeaderValue{`Invalid`},
|
||||
"no authentication methods available",
|
||||
},
|
||||
{
|
||||
"digest invalid",
|
||||
base.HeaderValue{`Digest`},
|
||||
"unable to split between method and keys (Digest)",
|
||||
},
|
||||
{
|
||||
"digest, missing realm",
|
||||
base.HeaderValue{`Digest nonce=123`},
|
||||
"realm is missing",
|
||||
},
|
||||
{
|
||||
"digest, missing nonce",
|
||||
base.HeaderValue{`Digest realm=123`},
|
||||
"nonce is missing",
|
||||
},
|
||||
{
|
||||
"basic invalid",
|
||||
base.HeaderValue{`Basic`},
|
||||
"unable to split between method and keys (Basic)",
|
||||
},
|
||||
{
|
||||
"basic, missing realm",
|
||||
base.HeaderValue{`Basic nonce=123`},
|
||||
"realm is missing",
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
_, err := NewSender(ca.hv, "myuser", "mypass")
|
||||
require.EqualError(t, err, ca.err)
|
||||
})
|
||||
}
|
||||
func FuzzSender(f *testing.F) {
|
||||
f.Add(`Invalid`)
|
||||
f.Add(`Digest`)
|
||||
f.Add(`Digest nonce=123`)
|
||||
f.Add(`Digest realm=123`)
|
||||
f.Add(`Basic`)
|
||||
f.Add(`Basic nonce=123`)
|
||||
|
||||
f.Fuzz(func(t *testing.T, a string) {
|
||||
NewSender(base.HeaderValue{a}, "myuser", "mypass") //nolint:errcheck
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user