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>
This commit is contained in:
1 parent
a7fca44809
commit
11c7c8dbe8
7 files changed
+190
-63
No files matched your search
@@ -2,6 +2,7 @@ package authtoken
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
// 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())
|
||||
@@ -16,4 +18,20 @@ func Test_GetOpts(t *testing.T) {
|
||||
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)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user