add HTTP Request to TokenVerifier (#404)
The request might be needed to verify the token. Fixes #403.
This commit is contained in:
parent
29c1650e2a
commit
d0c5943f25
1 changed files with 16 additions and 13 deletions
|
|
@ -7,13 +7,13 @@ package auth
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestVerify(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
verifier := func(_ context.Context, token string) (*TokenInfo, error) {
|
||||
verifier := func(_ context.Context, token string, _ *http.Request) (*TokenInfo, error) {
|
||||
switch token {
|
||||
case "valid":
|
||||
return &TokenInfo{Expiration: time.Now().Add(time.Hour)}, nil
|
||||
|
|
@ -67,7 +67,9 @@ func TestVerify(t *testing.T) {
|
|||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, gotMsg, gotCode := verify(ctx, verifier, tt.opts, tt.header)
|
||||
_, gotMsg, gotCode := verify(&http.Request{
|
||||
Header: http.Header{"Authorization": {tt.header}},
|
||||
}, verifier, tt.opts)
|
||||
if gotMsg != tt.wantMsg || gotCode != tt.wantCode {
|
||||
t.Errorf("got (%q, %d), want (%q, %d)", gotMsg, gotCode, tt.wantMsg, tt.wantCode)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue