Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
82ce23e4
Commit
82ce23e4
authored
Oct 21, 2012
by
Clément Schreiner
Browse files
Add test for invalid key block. Refactor the test data files' retrieval.
parent
411741cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/tests/test_gnupg.py
View file @
82ce23e4
...
...
@@ -87,10 +87,13 @@ class TestGnuPGController(TestCase):
def
_get_gnupg
(
self
,
gpg_path
=
'/usr/bin/gpg'
):
default_keyring
=
pylons
.
test
.
pylonsapp
.
config
.
get
(
'debexpo.gpg_keyring'
,
None
)
print
default_keyring
gnupg
=
GnuPG
(
gpg_path
,
default_keyring
)
return
gnupg
def
_get_data_file
(
self
,
name
):
gpg_data_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'gpg'
)
return
os
.
path
.
join
(
gpg_data_dir
,
name
)
def
testGnuPGfailure1
(
self
):
"""
Test for debexpo.gpg_path being uninitialised.
...
...
@@ -122,6 +125,13 @@ class TestGnuPGController(TestCase):
key_string
=
gnupg
.
key2string
(
parsed_key_block
.
key
)
self
.
assertEqual
(
key_string
,
test_gpg_key_id
)
def
testParseInvalidKeyBlock
(
self
):
gnupg
=
self
.
_get_gnupg
()
self
.
assertFalse
(
gnupg
.
is_unusable
)
invalid_block
=
self
.
_get_data_file
(
'invalid_key_block'
)
kb
=
gnupg
.
parse_key_block
(
path
=
invalid_block
)
assert
kb
.
key
==
None
def
testSignatureVerification
(
self
):
"""
Verify the signature in the file
...
...
@@ -129,9 +139,8 @@ class TestGnuPGController(TestCase):
"""
gnupg
=
self
.
_get_gnupg
()
self
.
assertFalse
(
gnupg
.
is_unusable
)
gpg_data_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'gpg'
)
signed_file
=
os
.
path
.
join
(
gpg_data_dir
,
'signed_by_355304E4.gpg'
)
pubring
=
os
.
path
.
join
(
gpg_data_dir
,
'pubring_with_355304E4.gpg'
)
signed_file
=
self
.
_get_data_file
(
'signed_by_355304E4.gpg'
)
pubring
=
self
.
_get_data_file
(
'pubring_with_355304E4.gpg'
)
assert
os
.
path
.
exists
(
signed_file
)
assert
os
.
path
.
exists
(
pubring
)
verif
=
gnupg
.
verify_file
(
path
=
signed_file
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment