Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Add new tokens command for managing API tokens #170

Merged
merged 8 commits into from
Nov 3, 2020
Prev Previous commit
Next Next commit
fixup! Add integration test for CODER_TOKEN static auth
  • Loading branch information
cmoog committed Nov 3, 2020
commit ccf38931906702168775b9bfc6319e32c991e96e
13 changes: 10 additions & 3 deletions ci/integration/statictokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,23 @@ func TestStaticAuth(t *testing.T) {
tcli.GetResult(&result),
)

c.Run(ctx, "rm -rf ~/.config/coder")
// remove loging credentials
c.Run(ctx, "rm -rf ~/.config/coder").Assert(t,
tcli.Success(),
)

cmd := exec.CommandContext(ctx, "sh", "-c", fmt.Sprintf("export CODER_URL=%s && export CODER_TOKEN=$(cat) && coder envs ls", os.Getenv("CODER_URL")))
// make requests with token environment variable authentication
cmd := exec.CommandContext(ctx, "sh", "-c",
fmt.Sprintf("export CODER_URL=%s && export CODER_TOKEN=$(cat) && coder envs ls", os.Getenv("CODER_URL")),
)
cmd.Stdin = strings.NewReader(string(result.Stdout))
c.RunCmd(cmd).Assert(t,
tcli.Success(),
)

// should error when the environment variabels aren't set
c.Run(ctx, "coder envs ls").Assert(t,
tcli.Success(),
tcli.Error(),
)
})
}