Hello! We are running our annual fundraising. Please consider making a donation if you value this freely available service or want to support people around the world working towards liberatory social change. https://riseup.net/donate.

Commit d9a9a419 authored by anarcat's avatar anarcat
Browse files

skip relevant tests if keys have expired

we hardcode the expiry date for now, because we have a chicken and egg
problem: to load the expiry dates, we need a working GPG library, and
we are not so strong with expiration parsing yet, especially since
there can be many expiration dates buried in subkeys, which I'm not
confident we can parse.

furthermore, the proper solution here is to remove expired keys from
the test suite, but that is difficult for keys such as zack's that
have very peculiar confugs.

this allows us to re-enable tests in build as reproducible builds
should just skip those tests now.

it is useful to run tests in builds because it makes sure we run the
test suite within the build environment. even though we run tests in
the release process, that can be forgotten and may run in a different
parent c0d7237d
monkeysign (2.1.5) UNRELEASED; urgency=medium
* fix tests with Debian CI
* fix FTBS errors in reproducible builds due to test suite failing in
the future
-- Antoine Beaupré <anarcat@debian.org> Tue, 11 Oct 2016 11:29:10 -0400
......@@ -22,15 +22,6 @@ override_dh_auto_build:
# disable tests because they fail in the future. this breaks
# reproducible builds, which build in 398 days it also will cause
# FTBFS issues eventually. unfortunately, it means we eventually ship
# a broken test suite, but until we replace expired keys with
# auto-generated ones, there is no easy fix since gpg 1.x doesn't
# support --faked-system-time, even though it is documented as such.
# workaround a limitation in distutils, see
......@@ -30,7 +30,7 @@ import re
sys.path.insert(0, os.path.dirname(__file__) + '/..')
from monkeysign.gpg import *
from test_lib import find_test_file, skipUnlessUnicodeLocale
from test_lib import find_test_file, skipUnlessUnicodeLocale, skipIfDatePassed
class TestContext(unittest.TestCase):
"""Tests for the Context class.
......@@ -224,12 +224,14 @@ class TestKeyringWithKeys(TestKeyringBase):
with self.assertRaises(GpgRuntimeError):
self.gpg.sign_key('7B75921E', True)
def test_sign_key_all_uids(self):
"""test signature of all uids of a key"""
self.assertTrue(self.gpg.sign_key('7B75921E', True))
self.gpg.context.call_command(['list-sigs', '7B75921E'])
self.assertRegexpMatches(self.gpg.context.stdout, 'sig:::1:86E4E70A96F47C6A:[^:]*::::Second Test Key <unittests@monkeysphere.info>:10x:')
def test_sign_key_single_uid(self):
"""test signing a key with a single uid"""
......@@ -244,6 +246,7 @@ class TestKeyringWithKeys(TestKeyringBase):
self.gpg.context.call_command(['list-sigs', '7B75921E'])
self.assertRegexpMatches(self.gpg.context.stdout, 'sig:::1:86E4E70A96F47C6A:[^:]*::::Second Test Key <unittests@monkeysphere.info>:10x:')
def test_sign_key_as_user(self):
"""normal signature with a signing user specified"""
self.gpg.context.set_option('local-user', '96F47C6A')
......@@ -352,6 +355,7 @@ class TestKeyringWithAbnormalKeys(TestKeyringBase):
def test_wrongly_place_sigs(self):
"""test zack's key
......@@ -81,5 +81,16 @@ def skipUnlessUnicodeLocale():
return lambda func: func
def skipIfDatePassed(date, fmt='%Y-%m-%dT%H:%M:%S%Z'):
# date is in ISO-8601 format by default
# XXX: should be auto-generated from the key material, or we
# should be able to use gpg --faked-system-time but that doesn't
# work in 1.x
if time.gmtime() >= time.strptime(date, fmt):
return unittest.skip('date %s is in the past' % date)
return lambda func: func
if __name__ == '__main__':
......@@ -62,7 +62,7 @@ from monkeysign.gpg import TempKeyring, GpgRuntimeError
import test_lib
# optimized because called often
from test_lib import find_test_file
from test_lib import find_test_file, skipIfDatePassed
class CliBaseTest(unittest.TestCase):
......@@ -186,6 +186,7 @@ class CliTestCase(CliBaseTest):
class CliTestDialog(CliBaseTest):
def setUp(self):
......@@ -221,6 +222,8 @@ this tests for bug #716675"""
self.write_to_callback("\n\n", callback) # say 'default' twice
class CliTestSpacedFingerprint(CliTestDialog):
def setUp(self):
......@@ -250,6 +253,8 @@ class BasicTests(BaseTestCase):
del self.ui
class SigningTests(BaseTestCase):
pattern = '7B75921E'
......@@ -406,6 +411,8 @@ this duplicates tests from the gpg code, but is necessary to test later function
self.assertIn(EmailFactory.body, contents)
class EmailFactoryTest(BaseTestCase):
pattern = '7B75921E'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment