~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testgpg.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:41:07 UTC
  • mfrom: (1442.1.60)
  • Revision ID: robertc@robertcollins.net-20051017114107-f5586285d825c105
Merge in first part of GPG support.

This adds check_signatures config support, triams back the transport api
to be leaner and easier to hook in suffixes - non primary streams in the store
associated with the fileid that primary data is stored in, a gpg module which
will encapsulate all signing and checking operations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import sys
23
23
 
24
 
#import bzrlib specific imports here
 
24
import bzrlib.errors as errors
 
25
import bzrlib.gpg as gpg
25
26
from bzrlib.selftest import TestCase, TestCaseInTempDir
26
27
 
 
28
class FakeConfig(object):
 
29
 
 
30
    def gpg_signing_command(self):
 
31
        return "false"
 
32
        
27
33
 
28
34
class TestCommandLine(TestCase):
29
 
    pass
 
35
 
 
36
    def test_signing_command_line(self):
 
37
        my_gpg = gpg.GPGStrategy(FakeConfig())
 
38
        self.assertEqual(['false',  '--clearsign'],
 
39
                         my_gpg._command_line())
 
40
 
 
41
    def test_checks_return_code(self):
 
42
        # This test needs a unix like platform - one with 'false' to run.
 
43
        # if you have one, please make this work :)
 
44
        my_gpg = gpg.GPGStrategy(FakeConfig())
 
45
        self.assertRaises(errors.SigningFailed, my_gpg.sign, 'content')
 
46
 
 
47
    def test_returns_output(self):
 
48
        # This test needs a 'cat' command or similar to work.
 
49
        my_gpg = gpg.GPGStrategy(FakeConfig())
 
50
        my_gpg._command_line = lambda:["cat", "-"]
 
51
        self.assertEqual("some content\nwith newlines\n",
 
52
                         my_gpg.sign("some content\nwith newlines\n"))