Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Add acceptance tests for gh auth commands
#9787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
665e814
Setup acceptance testing for auth and tests for auth-token and auth-s…
jtmcg 52daa9c
Add --token flag to `gh auth login` to accept a PAT as a flag
jtmcg aaf4c4e
Clean up auth-login-logout acceptance test with native functionality
jtmcg 0614d85
Add acceptance tests for auth-setup-git and formattedStringToEnv help…
jtmcg 59aedc4
Remove comment from gh auth logout
jtmcg 2b480da
Address PR feedback
jtmcg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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$' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Check the authentication status | ||
|
jtmcg marked this conversation as resolved.
|
||
| exec gh auth status --hostname $GH_HOST | ||
| stdout '✓ Logged in to ' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Check authentication token | ||
| exec gh auth token --hostname $GH_HOST | ||
| stdout $GH_TOKEN |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You can’t perform that action at this time.

Uh oh!
There was an error while loading. Please reload this page.