Skip to content

Commit 856df02

Browse files
committed
Tests GPG interfaces when gpg command isn't installed
Signed-off-by: Joshua Lock <jlock@vmware.com>
1 parent 1554024 commit 856df02

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ matrix:
88
env: TOXENV=py27
99
- python: "2.7"
1010
env: TOXENV=purepy27
11+
before_install:
12+
- sudo apt-get remove -y gnupg gnupg2
13+
after_script:
14+
- sudo apt-get install -y gnupg gnupg2
1115
- python: "3.5"
1216
env: TOXENV=py35
1317
- python: "3.6"
@@ -18,6 +22,10 @@ matrix:
1822
env: TOXENV=py38
1923
- python: "3.8"
2024
env: TOXENV=purepy38
25+
before_install:
26+
- sudo apt-get remove -y gnupg gnupg2
27+
after_script:
28+
- sudo apt-get install -y gnupg gnupg2
2129

2230
install:
2331
- pip install -U tox coveralls

tests/check_public_interfaces.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444

4545
import securesystemslib.exceptions
46+
import securesystemslib.gpg.constants
47+
import securesystemslib.gpg.functions
48+
import securesystemslib.gpg.util
4649
import securesystemslib.interface
4750
import securesystemslib.keys
4851

@@ -194,6 +197,18 @@ def test_purepy_ed25519(self):
194197
pub, 'ed25519', bsig, data)
195198
self.assertEqual(False, invalid)
196199

200+
def test_gpg_cmds(self):
201+
"""Ensure functions calling GPG commands throw an appropriate error"""
202+
203+
with self.assertRaises(securesystemslib.exceptions.UnsupportedLibraryError):
204+
securesystemslib.gpg.functions.create_signature('bar')
205+
206+
with self.assertRaises(securesystemslib.exceptions.UnsupportedLibraryError):
207+
securesystemslib.gpg.functions.export_pubkey('f00')
208+
209+
with self.assertRaises(securesystemslib.exceptions.UnsupportedLibraryError):
210+
securesystemslib.gpg.util.get_version()
211+
197212

198213
if __name__ == '__main__':
199214
suite = unittest.TestLoader().loadTestsFromTestCase(TestPublicInterfaces)

0 commit comments

Comments
 (0)