Files
threshold/internal/authtoken/options_test.go
T
Jeff MalnickandJeff Mitchell 11c7c8dbe8 feat: make auth token staleness and duration configurable (#777)
* feat: make auth token time to live and staleness configurable

* docs: add configuration docs for auth token TTL and staleness

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-11-16 10:39:18 -08:00

38 lines
961 B
Go

package authtoken
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
// Test_GetOpts provides unit tests for GetOpts and all the options
func Test_GetOpts(t *testing.T) {
t.Parallel()
t.Run("withTokenValue", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(withTokenValue())
testOpts := getDefaultOptions()
testOpts.withTokenValue = true
assert.Equal(opts, testOpts)
})
t.Run("WithTokenTimeToLiveDuration", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithTokenTimeToLiveDuration(1 * time.Hour))
testOpts := getDefaultOptions()
testOpts.withTokenTimeToLiveDuration = 1 * time.Hour
assert.Equal(opts, testOpts)
})
t.Run("WithTokenTimeToLiveStale", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithTokenTimeToStaleDuration(1 * time.Hour))
testOpts := getDefaultOptions()
testOpts.withTokenTimeToStaleDuration = 1 * time.Hour
assert.Equal(opts, testOpts)
})
}