Skip to content

Commit

Permalink
fix activation token location
Browse files Browse the repository at this point in the history
For backend we have workspace in project and token on default location.
For tests I want to have option to use token from non default location.
And to enable testing with workspace without token.
  • Loading branch information
ianic committed Dec 4, 2021
1 parent a45b9b0 commit 3c470f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions domain/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func AppConfigDir() (string, error) {
}

func StoreActivationToken(jwt string) error {
dir, _, err := WorkspacePathAndName()
dir, err := activationTokenPath()
if err != nil {
return err
}
Expand All @@ -128,7 +128,7 @@ func StoreActivationTokenTo(jwt string, dir string) error {
}

func ReadActivationToken() (string, error) {
dir, _, err := WorkspacePathAndName()
dir, err := activationTokenPath()
if err != nil {
return "", err
}
Expand All @@ -143,6 +143,13 @@ func ReadActivationToken() (string, error) {
return string(buf), nil
}

func activationTokenPath() (string, error) {
if val, ok := os.LookupEnv(EnvWorkspacePath); ok {
return val, nil
}
return AppConfigDir()
}

func WorkspacePathAndName() (string, string, error) {
// workspace pats set from env, used in end_to_end test
if val, ok := os.LookupEnv(EnvWorkspacePath); ok {
Expand Down

0 comments on commit 3c470f7

Please sign in to comment.