dex/refresh/refreshtest/repo.go

19 lines
507 B
Go
Raw Normal View History

2015-08-18 05:57:27 +05:30
package refreshtest
import (
"fmt"
"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}.
func NewTestRefreshTokenRepo() (refresh.RefreshTokenRepo, error) {
var tokenIdx int
tokenGenerator := func() ([]byte, error) {
2015-08-18 05:57:27 +05:30
tokenIdx++
return []byte(fmt.Sprintf("refresh-%d", tokenIdx)), nil
2015-08-18 05:57:27 +05:30
}
return refresh.NewRefreshTokenRepoWithTokenGenerator(tokenGenerator), nil
}