2015-08-18 05:57:27 +05:30
|
|
|
package refreshtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2016-02-10 01:07:32 +05:30
|
|
|
"github.com/coreos/dex/db"
|
2015-08-18 05:57:27 +05:30
|
|
|
"github.com/coreos/dex/refresh"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewTestRefreshTokenRepo returns a test repo whose tokens monotonically increase.
|
|
|
|
// The tokens are in the form { refresh-1, refresh-2 ... refresh-n}.
|
2016-02-10 01:07:32 +05:30
|
|
|
func NewTestRefreshTokenRepo() refresh.RefreshTokenRepo {
|
2015-08-18 05:57:27 +05:30
|
|
|
var tokenIdx int
|
2015-09-01 07:54:45 +05:30
|
|
|
tokenGenerator := func() ([]byte, error) {
|
2015-08-18 05:57:27 +05:30
|
|
|
tokenIdx++
|
2015-09-01 07:54:45 +05:30
|
|
|
return []byte(fmt.Sprintf("refresh-%d", tokenIdx)), nil
|
2015-08-18 05:57:27 +05:30
|
|
|
}
|
2016-02-10 01:07:32 +05:30
|
|
|
return db.NewRefreshTokenRepoWithGenerator(db.NewMemDB(), tokenGenerator)
|
2015-08-18 05:57:27 +05:30
|
|
|
}
|