Clean up auth-login-logout acceptance test with native functionality

The previous commit introduced two new functions, setEnvVar and
deleteEnvVar that are duplicative of functionality native to testscripts.
This commit switches to the native functionality and removes the
duplicative functions introduced in the previous commit.

Additionally, it removes the `--token` flag that was added to
`gh auth login`
This commit is contained in:
Tyler McGoffin 2024-10-21 09:22:27 -07:00
parent 52daa9cf7d
commit aaf4c4e4e3
3 changed files with 11 additions and 38 deletions

View file

@ -104,18 +104,14 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
}
if tokenStdin {
if opts.Token == "" {
defer opts.IO.In.Close()
token, err := io.ReadAll(opts.IO.In)
if err != nil {
return fmt.Errorf("failed to read token from standard input: %w", err)
}
opts.Token = strings.TrimSpace(string(token))
defer opts.IO.In.Close()
token, err := io.ReadAll(opts.IO.In)
if err != nil {
return fmt.Errorf("failed to read token from standard input: %w", err)
}
opts.Token = strings.TrimSpace(string(token))
}
// I think this is dead code because the token will always be set if we make it past
// the conditional above (lines 106-115)
if opts.IO.CanPrompt() && opts.Token == "" {
opts.Interactive = true
}
@ -143,7 +139,6 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
cmd.Flags().StringSliceVarP(&opts.Scopes, "scopes", "s", nil, "Additional authentication scopes to request")
cmd.Flags().BoolVar(&tokenStdin, "with-token", false, "Read token from standard input")
cmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open a browser to authenticate")
cmd.Flags().StringVarP(&opts.Token, "token", "t", "", "Authenticate using a personal access token")
cmdutil.StringEnumFlag(cmd, &opts.GitProtocol, "git-protocol", "p", "", []string{"ssh", "https"}, "The protocol to use for git operations on this host")
// secure storage became the default on 2023/4/04; this flag is left as a no-op for backwards compatibility