* 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>
38 lines
961 B
Go
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)
|
|
})
|
|
}
|