Skip to content

Commit

Permalink
Added error on unexisting password show
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Feb 4, 2015
1 parent 4f93a5a commit 0415e85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pypass/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import subprocess
import shutil
import sys
import tempfile

import click
Expand Down Expand Up @@ -155,6 +156,10 @@ def edit(config, path):
@click.argument('path', type=click.STRING)
@click.pass_obj
def show(config, path, clip):
if path not in config['password_store'].get_passwords_list():
click.echo('Error: %s is not in the password store.' % path)
sys.exit()

decrypted_password = \
config['password_store'].get_decypted_password(path).strip()

Expand Down
9 changes: 9 additions & 0 deletions pypass/tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ def test_insert_and_show(self):

self.assertEqual(show_result.output, 'super_secret\n')

def test_show_non_existing_password(self):
# Show the password for test.com
show_result = self.run_cli(
['show', 'test.com'],
)

self.assertEqual(show_result.output,
'Error: test.com is not in the password store.\n')

# Can't get xclip to work in Travis.
@pypass.tests.skipIfTravis
def test_show_clip(self):
Expand Down

0 comments on commit 0415e85

Please sign in to comment.