10
10
from debian.deb822 import Changes
11
from zope.component import getUtility
12
from canonical.testing.layers import LaunchpadZopelessLayer
13
from canonical.launchpad.ftests import import_public_test_keys
14
from canonical.testing.layers import (
15
LaunchpadZopelessLayer,
16
ZopelessDatabaseLayer,
13
18
from lp.archiveuploader.changesfile import (
14
19
CannotDetermineFileTypeError,
23
28
UdebBinaryUploadFile,
26
from lp.archiveuploader.tests import AbsolutelyAnythingGoesUploadPolicy
31
from lp.archiveuploader.tests import (
32
AbsolutelyAnythingGoesUploadPolicy,
35
from lp.archiveuploader.uploadpolicy import InsecureUploadPolicy
36
from lp.registry.interfaces.person import IPersonSet
27
37
from lp.services.log.logger import BufferLogger
28
38
from lp.testing import TestCase
39
from lp.testing.keyserver import KeyServerTac
31
42
class TestDetermineFileClassAndName(TestCase):
188
199
self.assertRaises(
190
201
self.createChangesFile, "mypkg_0.1_i386.changes", contents)
204
class TestSignatureVerification(TestCase):
206
layer = ZopelessDatabaseLayer
209
super(TestSignatureVerification, self).setUp()
210
self.useFixture(KeyServerTac())
211
import_public_test_keys()
213
def test_valid_signature_accepted(self):
214
# A correctly signed changes file is excepted, and all its
216
path = datadir('signatures/signed.changes')
217
parsed = ChangesFile(path, InsecureUploadPolicy(), BufferLogger())
219
getUtility(IPersonSet).getByEmail('foo.bar@canonical.com'),
221
expected = "\AFormat: 1.7\n.*foo_1.0-1.diff.gz\Z"
222
self.assertTextMatchesExpressionIgnoreWhitespace(
224
parsed.parsed_content)
226
def test_no_signature_rejected(self):
227
# An unsigned changes file is rejected.
228
path = datadir('signatures/unsigned.changes')
231
ChangesFile, path, InsecureUploadPolicy(), BufferLogger())
233
def test_prefix_ignored(self):
234
# A signed changes file with an unsigned prefix has only the
235
# signed part parsed.
236
path = datadir('signatures/prefixed.changes')
237
parsed = ChangesFile(path, InsecureUploadPolicy(), BufferLogger())
239
getUtility(IPersonSet).getByEmail('foo.bar@canonical.com'),
241
expected = "\AFormat: 1.7\n.*foo_1.0-1.diff.gz\Z"
242
self.assertTextMatchesExpressionIgnoreWhitespace(
244
parsed.parsed_content)
245
self.assertEqual("breezy", parsed.suite_name)
246
self.assertNotIn("evil", parsed.changes_comment)