hodu/jwt_test.go

27 lines
542 B
Go
Raw Normal View History

2025-01-28 00:44:02 +09:00
package hodu_test
import "hodu"
import "testing"
func TestJwt(t *testing.T) {
var j hodu.JWT
var tok string
var err error
type JWTClaim struct {
Abc string `json:"abc"`
Donkey string `json:"donkey"`
IssuedAt int `json:"iat"`
}
var jc JWTClaim
jc.Abc = "def"
jc.Donkey = "kong"
jc.IssuedAt = 111
tok, err = j.Sign(&jc)
if err != nil { t.Fatalf("signing failure - %s", err.Error()) }
err = j.Verify(tok)
if err != nil { t.Fatalf("verification failure - %s", err.Error()) }
}