-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from hashicorp/b-command-escaping
Fix panic displaying invoked command
- Loading branch information
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
```release-note:bug | ||
Fix rare panic that could occur on authentication error when running a command that had quoted arguments. | ||
``` |
This file contains 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 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,24 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/hcp/internal/pkg/iostreams" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAuthErrorHelp(t *testing.T) { | ||
t.Parallel() | ||
r := require.New(t) | ||
io := iostreams.Test() | ||
|
||
commandPath := "hcp example" | ||
args := []string{"simple", "'single-quote'", `escaped \"inner\"`} | ||
|
||
// Get the help text | ||
helpText := authErrorHelp(io, commandPath, args) | ||
r.Contains(helpText, `$ hcp example simple 'single-quote' "escaped \\\"inner\\\""`) | ||
} |