storj/satellite/console/consoleauth/claims_test.go
Yehor Butko e38cf8f50d
Renaming and moving pkg/satellite to satellite/console (#1054)
* [WIP] V3-853 Merge the satellite DB into the master database

* Removing consoleDB from satelliteDB

* Fixing tests for satellite/console

* fixing linter

* sorting imports in satellite/console

* fixing console config

* fixing linter
2019-01-15 15:03:24 +02:00

43 lines
1.2 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleauth
import (
"testing"
"time"
"github.com/skyrings/skyring-common/tools/uuid"
"github.com/stretchr/testify/assert"
)
func TestClaims(t *testing.T) {
id, err := uuid.New()
assert.Nil(t, err)
assert.NoError(t, err)
assert.NotNil(t, id)
claims := Claims{
ID: *id,
Email: "someEmail@ukr.net",
Expiration: time.Now(),
}
claimsBytes, err := claims.JSON()
assert.NoError(t, err)
assert.NotNil(t, claimsBytes)
parsedClaims, err := FromJSON(claimsBytes)
assert.NoError(t, err)
assert.NotNil(t, parsedClaims)
assert.Equal(t, parsedClaims.Email, claims.Email)
assert.Equal(t, parsedClaims.ID, claims.ID)
assert.Equal(t, parsedClaims.Expiration.Year(), claims.Expiration.Year())
assert.Equal(t, parsedClaims.Expiration.Month(), claims.Expiration.Month())
assert.Equal(t, parsedClaims.Expiration.Day(), claims.Expiration.Day())
assert.Equal(t, parsedClaims.Expiration.Hour(), claims.Expiration.Hour())
assert.Equal(t, parsedClaims.Expiration.Minute(), claims.Expiration.Minute())
assert.Equal(t, parsedClaims.Expiration.Second(), claims.Expiration.Second())
}