Add acceptance tests for `gh auth` commands by jtmcg · Pull Request #9787 · cli/cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion acceptance/acceptance_test.go
25 changes: 25 additions & 0 deletions acceptance/testdata/auth/auth-login-logout.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# We aren't logged in at the moment, but GH_TOKEN will override the
# need to login. We are going to clear GH_TOKEN first to ensure no
# overrides are happening

# Copy $GH_TOKEN to a new env var
env LOGIN_TOKEN=$GH_TOKEN

# Remove GH_TOKEN env var so we don't fall back to it
env GH_TOKEN=''

# Login to the host by feeding the token to stdin
exec echo $LOGIN_TOKEN
stdin stdout
Comment thread
jtmcg marked this conversation as resolved.
exec gh auth login --hostname=$GH_HOST --with-token --insecure-storage

# Check that we are logged in
exec gh auth status --hostname $GH_HOST
stdout $GH_HOST

# Logout of the host
exec gh auth logout --hostname $GH_HOST
stderr 'Logged out of'

# Check that we are logged out
! exec gh auth status --hostname $GH_HOST
10 changes: 10 additions & 0 deletions acceptance/testdata/auth/auth-setup-git.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Check that the credential helper is unset for the host. This command is
# expected to fail before gh auth setup-git is run.
! exec git config --get credential.https://${GH_HOST}.helper

# Run the setup-git command
exec gh auth setup-git

# Check that the credential helper is set to gh
exec git config --get credential.https://${GH_HOST}.helper
stdout '^.*gh auth git-credential$'
3 changes: 3 additions & 0 deletions acceptance/testdata/auth/auth-status.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Check the authentication status
Comment thread
jtmcg marked this conversation as resolved.
exec gh auth status --hostname $GH_HOST
stdout '✓ Logged in to '
3 changes: 3 additions & 0 deletions acceptance/testdata/auth/auth-token.txtar