Skip to content

Commit

Permalink
Add CLI test for v5 default key usage and signing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Dec 1, 2023
1 parent 3e64e47 commit e0d75cc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/tests/cli_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4032,6 +4032,32 @@ def test_allow_weak_hash(self):
clear_workfiles()
shutil.rmtree(RNP2, ignore_errors=True)

def test_default_v5_key(self):
RNP2 = RNPDIR + '2'
os.mkdir(RNP2, 0o700)
# Import v5 key
ret, out, _ = run_proc(RNPK, ['--homedir', RNP2, '--import', data_path('test_stream_key_load/v5-rsa-sec.asc')])
self.assertEqual(ret, 0)
self.assertRegex(out, r'(?s)^.*sec.*b856a4197113d431.*v5_rsa.*$')
# Attempt to sign using the default key
ret, out, err = run_proc(RNP, ['--homedir', RNP2, '--password', PASSWORD, '--armor', '--sign'], 'Hello')
self.assertEqual(ret, 0)
self.assertNotRegex(err, r'(?s)^.*Default key not found.*$')
self.assertRegex(out, r'(?s)^.*BEGIN PGP MESSAGE.*$')
ret, out, _ = run_proc(RNP, ['--homedir', RNP2, '--verify'], out)
self.assertEqual(ret, 0)
self.assertRegex(out, r'(?s)^.*Hello.*$')
# Attempt to encrypt using the default key
ret, out, err = run_proc(RNP, ['--homedir', RNP2, '--armor', '--encrypt'], 'Hello')
self.assertEqual(ret, 0)
self.assertNotRegex(err, r'(?s)^.*Default key not found.*$')
self.assertRegex(out, r'(?s)^.*BEGIN PGP MESSAGE.*$')
ret, out, _ = run_proc(RNP, ['--homedir', RNP2, '--decrypt'], out)
self.assertEqual(ret, 0)
self.assertRegex(out, r'(?s)^.*Hello.*$')

shutil.rmtree(RNP2, ignore_errors=True)

class Encryption(unittest.TestCase):
'''
Things to try later:
Expand Down

0 comments on commit e0d75cc

Please sign in to comment.