forked from intel/bmap-tools
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current tests do not take into account whether the `gpg` package has been installed or not. If it is missing, the tests should be skipped. Furthermore, the output of the tests must be checked in order to decide whether tests fail due to an exception or whether the desired error message is displayed. Signed-off-by: Jörg Sommer <[email protected]>
- Loading branch information
Showing
1 changed file
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
import sys | ||
import tempfile | ||
import tests.helpers | ||
import gpg | ||
import shutil | ||
|
||
|
||
|
@@ -39,10 +38,14 @@ def test_valid_signature(self): | |
self.tmpfile, | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
) | ||
self.assertEqual(completed_process.returncode, 0, completed_process.stdout) | ||
self.assertEqual(completed_process.returncode, 0) | ||
self.assertEqual(completed_process.stdout, b"") | ||
self.assertIn( | ||
b"successfully verified bmap file signature", completed_process.stderr | ||
) | ||
|
||
def test_unknown_signer(self): | ||
completed_process = subprocess.run( | ||
|
@@ -57,10 +60,12 @@ def test_unknown_signer(self): | |
self.tmpfile, | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
) | ||
self.assertEqual(completed_process.returncode, 1, completed_process.stdout) | ||
self.assertEqual(completed_process.returncode, 1) | ||
self.assertEqual(completed_process.stdout, b"") | ||
self.assertIn(b"discovered a BAD GPG signature", completed_process.stderr) | ||
|
||
def test_wrong_signature(self): | ||
completed_process = subprocess.run( | ||
|
@@ -75,10 +80,12 @@ def test_wrong_signature(self): | |
self.tmpfile, | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
) | ||
self.assertEqual(completed_process.returncode, 1, completed_process.stdout) | ||
self.assertEqual(completed_process.returncode, 1) | ||
self.assertEqual(completed_process.stdout, b"") | ||
self.assertIn(b"discovered a BAD GPG signature", completed_process.stderr) | ||
|
||
def test_wrong_signature_uknown_signer(self): | ||
completed_process = subprocess.run( | ||
|
@@ -93,10 +100,12 @@ def test_wrong_signature_uknown_signer(self): | |
self.tmpfile, | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
) | ||
self.assertEqual(completed_process.returncode, 1, completed_process.stdout) | ||
self.assertEqual(completed_process.returncode, 1) | ||
self.assertEqual(completed_process.stdout, b"") | ||
self.assertIn(b"discovered a BAD GPG signature", completed_process.stderr) | ||
|
||
def test_clearsign(self): | ||
completed_process = subprocess.run( | ||
|
@@ -109,12 +118,21 @@ def test_clearsign(self): | |
self.tmpfile, | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
) | ||
self.assertEqual(completed_process.returncode, 0, completed_process.stdout) | ||
self.assertEqual(completed_process.returncode, 0) | ||
self.assertEqual(completed_process.stdout, b"") | ||
self.assertIn( | ||
b"successfully verified bmap file signature", completed_process.stderr | ||
) | ||
|
||
def setUp(self): | ||
try: | ||
import gpg | ||
except ImportError: | ||
self.skipTest("python module 'gpg' missing") | ||
|
||
os.makedirs("tests/test-data/signatures", exist_ok=True) | ||
for gnupghome, userid in [ | ||
("tests/test-data/gnupg/", "correct <[email protected]>"), | ||
|