diff --git a/testutil/testutil.go b/testutil/testutil.go index b5c30639..19eb64c1 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -17,6 +17,16 @@ import ( // kontrol.go) If the host does not have a kite.key file kite.New() panics. // This is a helper to put a fake key on it's location. func NewKiteKey() *jwt.Token { + return newKiteKey("") +} + +// NewKiteKeyUsername is like NewKiteKey() but it uses the given username +// instead of using the "testuser" name +func NewKiteKeyUsername(username string) *jwt.Token { + return newKiteKey(username) +} + +func newKiteKey(username string) *jwt.Token { tknID, err := uuid.NewV4() if err != nil { panic(err) @@ -27,7 +37,10 @@ func NewKiteKey() *jwt.Token { panic(err) } - username := "testuser" + if username == "" { + username = "testuser" + } + if testuser := os.Getenv("TESTKEY_USERNAME"); testuser != "" { username = testuser } @@ -51,6 +64,7 @@ func NewKiteKey() *jwt.Token { token.Valid = true return token + } func NewConfig() *config.Config {