dex/refresh/refreshtest/repo.go

20 lines
526 B
Go
Raw Normal View History

2015-08-17 17:27:27 -07:00
package refreshtest
import (
"fmt"
2016-02-09 11:37:32 -08:00
"github.com/coreos/dex/db"
2015-08-17 17:27:27 -07:00
"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-09 11:37:32 -08:00
func NewTestRefreshTokenRepo() refresh.RefreshTokenRepo {
2015-08-17 17:27:27 -07:00
var tokenIdx int
tokenGenerator := func() ([]byte, error) {
2015-08-17 17:27:27 -07:00
tokenIdx++
return []byte(fmt.Sprintf("refresh-%d", tokenIdx)), nil
2015-08-17 17:27:27 -07:00
}
2016-02-09 11:37:32 -08:00
return db.NewRefreshTokenRepoWithGenerator(db.NewMemDB(), tokenGenerator)
2015-08-17 17:27:27 -07:00
}