implement AuthServer and AuthClient

This commit is contained in:
aler9
2020-02-16 15:25:50 +01:00
parent 2f23f19aca
commit 162fc911ce
5 changed files with 194 additions and 42 deletions

19
authserver_test.go Normal file
View File

@@ -0,0 +1,19 @@
package gortsplib
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestAuthClientServer(t *testing.T) {
as := NewAuthServer("testuser", "testpass")
wwwAuthenticate := as.GenerateHeader()
ac, err := NewAuthClient(wwwAuthenticate, "testuser", "testpass")
require.NoError(t, err)
authorization := ac.GenerateHeader("ANNOUNCE", "rtsp://myhost/mypath")
err = as.ValidateHeader(authorization, "ANNOUNCE", "rtsp://myhost/mypath")
require.NoError(t, err)
}