Skip to content

Commit

Permalink
Avoid auto-search running non-interactively (gopasspw#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Dec 1, 2017
1 parent 5278676 commit 39ce4c9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Action) show(ctx context.Context, c *cli.Context, name, key string, rec

sec, err := s.Store.Get(ctx, name)
if err != nil {
if err != store.ErrNotFound || !recurse {
if err != store.ErrNotFound || !recurse || !ctxutil.IsTerminal(ctx) {
return s.exitError(ctx, ExitUnknown, err, "failed to retrieve secret '%s': %s", name, err)
}
color.Yellow("Entry '%s' not found. Starting search...", name)
Expand Down
2 changes: 1 addition & 1 deletion tests/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestSingleMount(t *testing.T) {

out, err = ts.run("show mnt/m1/secret")
assert.Error(t, err)
assert.Equal(t, "Entry 'mnt/m1/secret' not found. Starting search...\nfixed/secret\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'mnt/m1/secret': Entry is not in the password store\n", out)

ts.initSecrets("mnt/m1/")

Expand Down
2 changes: 1 addition & 1 deletion tests/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestShow(t *testing.T) {

out, err = ts.run("show foo")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo': Entry is not in the password store\n", out)

ts.initSecrets("")

Expand Down
4 changes: 2 additions & 2 deletions tests/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestYAMLAndSecret(t *testing.T) {

out, err := ts.run("foo/bar baz")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo/bar' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo/bar': Entry is not in the password store\n", out)

_, err = ts.runCmd([]string{ts.Binary, "insert", "foo/bar"}, []byte("moar"))
assert.NoError(t, err)
Expand Down Expand Up @@ -48,7 +48,7 @@ url: http://www.test.com/`

out, err := ts.run("foo/bar")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo/bar' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo/bar': Entry is not in the password store\n", out)

_, err = ts.runCmd([]string{ts.Binary, "insert", "foo/bar"}, []byte(testBody))
assert.NoError(t, err)
Expand Down
4 changes: 1 addition & 3 deletions utils/protect/protect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ package protect
var ProtectEnabled = false

// Pledge on any other system than OpenBSD doesn't do anything
func Pledge(s string) {
return
}
func Pledge(s string) {}

0 comments on commit 39ce4c9

Please sign in to comment.