mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 12:57:05 +00:00
jwt: add more helpers (DefaultRSA and DefaultHMAC)
Former-commit-id: fe06c0e0f4d7e121c678ffda7ac702ae865abd00
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package jwt_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -18,12 +19,21 @@ type userClaims struct {
|
||||
const testMaxAge = 3 * time.Second
|
||||
|
||||
// Random RSA verification and encryption.
|
||||
func TestRSA(t *testing.T) {
|
||||
j := jwt.Random(testMaxAge)
|
||||
func TestDefaultRSA(t *testing.T) {
|
||||
j := jwt.DefaultRSA(testMaxAge)
|
||||
t.Cleanup(func() {
|
||||
os.Remove(jwt.SignFilename)
|
||||
os.Remove(jwt.EncFilename)
|
||||
})
|
||||
testWriteVerifyToken(t, j)
|
||||
}
|
||||
|
||||
// HMAC verification and encryption.
|
||||
func TestDefaultHMAC(t *testing.T) {
|
||||
j := jwt.DefaultHMAC(testMaxAge, "secret", "itsa16bytesecret")
|
||||
testWriteVerifyToken(t, j)
|
||||
}
|
||||
|
||||
func TestHMAC(t *testing.T) {
|
||||
j, err := jwt.New(testMaxAge, jwt.HS256, []byte("secret"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user