Skip to content

Commit

Permalink
Merge pull request #108 from fatih/testkey
Browse files Browse the repository at this point in the history
testutil: just add new function to be used for tests
  • Loading branch information
Cihangir committed Mar 24, 2015
2 parents 075879a + 77b5c02 commit 387abd6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -51,6 +64,7 @@ func NewKiteKey() *jwt.Token {

token.Valid = true
return token

}

func NewConfig() *config.Config {
Expand Down

0 comments on commit 387abd6

Please sign in to comment.