mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 14:52:46 +08:00
auth: add Validate() and deprecate Validator{} (#272)
This commit is contained in:
@@ -1045,17 +1045,17 @@ func TestServerSessionTeardown(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServerAuth(t *testing.T) {
|
||||
authValidator := auth.NewValidator("myuser", "mypass", nil)
|
||||
nonce := auth.GenerateNonce()
|
||||
|
||||
s := &Server{
|
||||
Handler: &testServerHandler{
|
||||
onAnnounce: func(ctx *ServerHandlerOnAnnounceCtx) (*base.Response, error) {
|
||||
err := authValidator.ValidateRequest(ctx.Request, nil)
|
||||
err := auth.Validate(ctx.Request, "myuser", "mypass", nil, nil, "IPCAM", nonce)
|
||||
if err != nil {
|
||||
return &base.Response{
|
||||
StatusCode: base.StatusUnauthorized,
|
||||
Header: base.Header{
|
||||
"WWW-Authenticate": authValidator.Header(),
|
||||
"WWW-Authenticate": auth.GenerateWWWAuthenticate(nil, "IPCAM", nonce),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user