2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2019-01-11 10:08:51 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package consoleauth
|
2019-01-11 10:08:51 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestToken(t *testing.T) {
|
|
|
|
token := Token{
|
|
|
|
Payload: []byte{1, 2, 3},
|
|
|
|
Signature: []byte{4, 5, 6},
|
|
|
|
}
|
|
|
|
|
|
|
|
tokenString := token.String()
|
|
|
|
assert.NotNil(t, tokenString)
|
|
|
|
assert.Equal(t, len(tokenString) > 0, true)
|
|
|
|
|
|
|
|
tokenFromString, err := FromBase64URLString(tokenString)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, tokenFromString.Payload, token.Payload)
|
|
|
|
assert.Equal(t, tokenFromString.Signature, token.Signature)
|
|
|
|
}
|