def test_grep(self): store = PasswordStore(self.dir) store.insert_password('grep_test.com', 'GREPME') grep_result = self.run_cli(['grep', 'GREPME']) self.assertEqual( grep_result.output, 'grep_test.com:\nGREPME\n' )
def test_edit(self): store = PasswordStore(self.dir) store.insert_password('test.com', 'editme') mock_editor = os.path.join(os.path.dirname(__file__), 'mock_editor.py') self.run_cli(['--EDITOR', mock_editor, 'edit', 'test.com']) edited_content = store.get_decrypted_password('test.com') self.assertEqual(edited_content, 'edited')
def test_show_clip(self): store = PasswordStore(self.dir) store.insert_password('clip_test', 'clipme999\nbutnotthisnewline\nfff') show_result = self.run_cli(['show', '-c', 'clip_test']) self.assertEqual(show_result.output, 'Copied clip_test to clipboard.\n') # Check if the password is in the clipoard xclip = subprocess.Popen(['xclip', '-o', '-selection', 'clipboard'], stdout=subprocess.PIPE) xclip.wait() self.assertEqual(xclip.stdout.read().decode('utf8'), 'clipme999')
def test_show_clip(self): store = PasswordStore(self.dir) store.insert_password('clip_test', 'clipme999\nbutnotthisnewline\nfff') show_result = self.run_cli(['show', '-c', 'clip_test']) self.assertEqual( show_result.output, 'Copied clip_test to clipboard.\n' ) # Check if the password is in the clipoard xclip = subprocess.Popen( ['xclip', '-o', '-selection', 'clipboard'], stdout=subprocess.PIPE) xclip.wait() self.assertEqual(xclip.stdout.read().decode('utf8'), 'clipme999')
def test_generate_in_place(self): self.run_cli(['git', 'init']) store = PasswordStore(self.dir) generate = self.run_cli(['generate', '-i', 'in-place.com'], expect_failure=True) self.assertNotEqual(generate.exit_code, 0) store.insert_password('in-place.com', 'first\nsecond') self.run_cli(['generate', '-i', 'in-place.com', '10']) self.assertLastCommitMessage( 'Replace generated password for in-place.com.') new_content = store.get_decrypted_password('in-place.com') new_password, _, remainder = new_content.partition('\n') self.assertEqual(len(new_password), 10) self.assertEqual(remainder, 'second')