Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: assertEquals -> assertEqual #101

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions tests/splitgpg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ class TC_00_Direct(SplitGPGBase):
def test_000_version(self):
cmd = 'qubes-gpg-client-wrapper --version'
p = self.frontend.run(cmd, wait=True)
self.assertEquals(p, 0, '{} failed'.format(cmd))
self.assertEqual(p, 0, '{} failed'.format(cmd))

def test_010_list_keys(self):
cmd = 'qubes-gpg-client-wrapper --list-keys'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(keys, stderr) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))
self.assertIn("Qubes test", keys.decode())

Expand All @@ -101,45 +101,45 @@ def test_020_export_secret_key_deny(self):
cmd = 'qubes-gpg-client-wrapper -a --export-secret-keys user@localhost'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
keys, stderr = p.communicate()
self.assertNotEquals(p.returncode, 0,
self.assertNotEqual(p.returncode, 0,
'{} succeeded unexpectedly: {}'.format(cmd, stderr.decode()))
self.assertEquals(keys.decode(), '')
self.assertEqual(keys.decode(), '')

def test_030_sign_verify(self):
msg = "Test message"
cmd = 'qubes-gpg-client-wrapper -a --sign'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(signature, stderr) = p.communicate(msg.encode())
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))
self.assertNotEquals('', signature.decode())
self.assertNotEqual('', signature.decode())

# verify first through gpg-split
cmd = 'qubes-gpg-client-wrapper'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(decoded_msg, verification_result) = p.communicate(signature)
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), msg)
self.assertEqual(decoded_msg.decode(), msg)
self.assertIn('\ngpg: Good signature from', verification_result.decode())

# verify in frontend directly
cmd = 'gpg2 -a --export user@localhost'
p = self.backend.run(cmd, passio_popen=True, passio_stderr=True)
(pubkey, stderr) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))
cmd = 'gpg2 --import'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate(pubkey)
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}{}'.format(cmd, stdout.decode(), stderr.decode()))
cmd = "gpg2"
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate(signature)
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), msg)
self.assertEqual(decoded_msg.decode(), msg)
self.assertIn('\ngpg: Good signature from', verification_result.decode())

def test_031_sign_verify_detached(self):
Expand All @@ -148,26 +148,26 @@ def test_031_sign_verify_detached(self):
cmd = 'qubes-gpg-client-wrapper -a -b --sign message > signature.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
stdout, stderr = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))

# verify through gpg-split
cmd = 'qubes-gpg-client-wrapper --verify signature.asc message'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), '')
self.assertEqual(decoded_msg.decode(), '')
self.assertIn('\ngpg: Good signature from', verification_result.decode())

# break the message and check again
self.frontend.run('echo "{}" >> message'.format(msg), wait=True)
cmd = 'qubes-gpg-client-wrapper --verify signature.asc message'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate()
self.assertNotEquals(p.returncode, 0,
self.assertNotEqual(p.returncode, 0,
'{} unexpecedly succeeded: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), '')
self.assertEqual(decoded_msg.decode(), '')
self.assertIn('\ngpg: BAD signature from', verification_result.decode())

def test_040_import(self):
Expand Down Expand Up @@ -257,16 +257,16 @@ def test_050_sign_verify_files(self):
cmd = 'qubes-gpg-client-wrapper -a --sign --output /tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
stdout, stderr = p.communicate(msg.encode())
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))

# verify first through gpg-split
cmd = 'qubes-gpg-client-wrapper /tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), msg)
self.assertEqual(decoded_msg.decode(), msg)
self.assertIn('\ngpg: Good signature from', verification_result.decode())

def test_060_output_and_status_fd(self):
Expand All @@ -276,7 +276,7 @@ def test_060_output_and_status_fd(self):
'/tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate(msg.encode())
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, stderr.decode()))
self.assertTrue(all(x.startswith('[GNUPG:]') for x in
stdout.decode().splitlines()), "Non-status output on stdout")
Expand All @@ -285,9 +285,9 @@ def test_060_output_and_status_fd(self):
cmd = 'qubes-gpg-client-wrapper /tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), msg)
self.assertEqual(decoded_msg.decode(), msg)
self.assertIn('\ngpg: Good signature from', verification_result.decode())

def test_070_log_file_to_logger_fd(self):
Expand All @@ -297,7 +297,7 @@ def test_070_log_file_to_logger_fd(self):
'--verbose --output /tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate(msg.encode())
self.assertEquals(p.returncode, 0, '{} failed: {}'.format(cmd,
self.assertEqual(p.returncode, 0, '{} failed: {}'.format(cmd,
stderr.decode()))
self.assertTrue(all(x.startswith('[GNUPG:]') for x in
stdout.decode().splitlines()), "Non-status output on stdout")
Expand All @@ -310,9 +310,9 @@ def test_070_log_file_to_logger_fd(self):
cmd = 'qubes-gpg-client-wrapper /tmp/signed.asc'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
decoded_msg, verification_result = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'{} failed: {}'.format(cmd, verification_result.decode()))
self.assertEquals(decoded_msg.decode(), msg)
self.assertEqual(decoded_msg.decode(), msg)
self.assertIn('\ngpg: Good signature from', verification_result.decode())

def _check_if_options_takes_argument(self, prog, option, message_fmts):
Expand All @@ -332,18 +332,18 @@ def _check_if_options_takes_argument(self, prog, option, message_fmts):
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate()
stderr = stderr.decode()
self.assertNotEquals(p.returncode, 0,
self.assertNotEqual(p.returncode, 0,
cmd + ' should have failed: ' + stderr)
if option == '--list-options' and 'qubes' in prog:
self.assertEquals(stderr,
self.assertEqual(stderr,
"qubes-gpg-client: Unknown list option --garbage-1\n")
return True
if option == '--verify-options' and 'qubes' in prog:
self.assertEquals(stderr,
self.assertEqual(stderr,
"qubes-gpg-client: Unknown verify option --garbage-1\n")
return True
if option == '--export-options' and 'qubes' in prog:
self.assertEquals(stderr,
self.assertEqual(stderr,
"qubes-gpg-client: Unknown export option --garbage-1\n")
return True
for message_fmt in message_fmts:
Expand All @@ -367,7 +367,7 @@ def test_080_option_parser(self):
cmd = 'gpg --dump-options'
p = self.frontend.run(cmd, passio_popen=True, passio_stderr=True)
(stdout, stderr) = p.communicate()
self.assertEquals(p.returncode, 0, '{} failed: {}'.format(cmd,
self.assertEqual(p.returncode, 0, '{} failed: {}'.format(cmd,
stderr.decode()))
all_options = stdout.decode().splitlines()
noarg_options = []
Expand All @@ -386,7 +386,7 @@ def test_080_option_parser(self):
continue
gpg_needs_arg = self._check_if_options_takes_argument(
'gpg2', opt, ['invalid option "{}"'])
self.assertEquals(gpg_needs_arg, splitgpg_needs_arg,
self.assertEqual(gpg_needs_arg, splitgpg_needs_arg,
'gpg and splitgpg disagrees on {} option: {}, {}'.format(
opt, gpg_needs_arg, splitgpg_needs_arg))
if not gpg_needs_arg:
Expand Down Expand Up @@ -480,7 +480,7 @@ def get_key_fpr(self):
cmd = '/usr/bin/qubes-gpg-client-wrapper -K --with-colons'
p = self.frontend.run(cmd, passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0, 'Failed to determin key id')
self.assertEqual(p.returncode, 0, 'Failed to determin key id')
keyid = stdout.decode('utf-8').split('\n')[1]
keyid = keyid.split(':')[9]
keyid = keyid[-16:]
Expand Down Expand Up @@ -558,7 +558,7 @@ def test_000_send_receive_default(self):
self.scriptpath, self.tb_name, self.profile_dir, self.imap_pw),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Thunderbird send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand All @@ -570,7 +570,7 @@ def test_010_send_receive_inline_signed_only(self):
self.scriptpath, self.tb_name, self.profile_dir, self.imap_pw),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Thunderbird send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand All @@ -582,7 +582,7 @@ def test_020_send_receive_inline_with_attachment(self):
self.scriptpath, self.tb_name, self.profile_dir, self.imap_pw),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Thunderbird send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand Down Expand Up @@ -635,7 +635,7 @@ def test_000_send_receive_signed_encrypted(self):
self.scriptpath),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Evolution send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand All @@ -646,7 +646,7 @@ def test_010_send_receive_signed_only(self):
self.scriptpath),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Evolution send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand All @@ -658,7 +658,7 @@ def test_020_send_receive_with_attachment(self):
self.scriptpath),
passio_popen=True)
(stdout, _) = p.communicate()
self.assertEquals(p.returncode, 0,
self.assertEqual(p.returncode, 0,
'Evolution send/receive failed: {}'.format(
stdout.decode('ascii', 'ignore')))

Expand Down