~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testconfig.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:
57
57
                        "# test trailing / matching with no children\n"
58
58
                        "[/a/]\n"
59
59
                        "check_signatures=check-available\n"
 
60
                        "gpg_signing_command=false\n"
60
61
                        "# test trailing / matching\n"
61
62
                        "[/a/*]\n"
62
63
                        "#subdirs will match but not the parent\n"
143
144
                         my_config.signature_checking())
144
145
        self.assertEqual(['_get_signature_checking'], my_config._calls)
145
146
 
 
147
    def test_gpg_signing_command_default(self):
 
148
        my_config = config.Config()
 
149
        self.assertEqual('gpg', my_config.gpg_signing_command())
 
150
 
146
151
 
147
152
class TestConfigPath(TestCase):
148
153
 
153
158
 
154
159
    def tearDown(self):
155
160
        os.environ['HOME'] = self.oldenv
 
161
        super(TestConfigPath, self).tearDown()
156
162
    
157
163
    def test_config_dir(self):
158
164
        self.assertEqual(config.config_dir(), '/home/bogus/.bazaar')
184
190
        self.failUnless(my_config._get_parser() is parser)
185
191
 
186
192
 
187
 
 
188
193
class TestGetConfig(TestCase):
189
194
 
190
195
    def test_constructs(self):
218
223
        self.failUnless(location_config is my_config._get_location_config())
219
224
 
220
225
 
221
 
class TestConfigItems(TestCase):
222
 
 
223
 
    def setUp(self):
224
 
        super(TestConfigItems, self).setUp()
225
 
        self.bzr_email = os.environ.get('BZREMAIL')
226
 
        if self.bzr_email is not None:
227
 
            del os.environ['BZREMAIL']
228
 
        self.email = os.environ.get('EMAIL')
229
 
        if self.email is not None:
230
 
            del os.environ['EMAIL']
231
 
        self.oldenv = os.environ.get('HOME', None)
232
 
        os.environ['HOME'] = os.getcwd()
233
 
 
234
 
    def tearDown(self):
235
 
        os.environ['HOME'] = self.oldenv
236
 
        if os.environ.get('BZREMAIL') is not None:
237
 
            del os.environ['BZREMAIL']
238
 
        if self.bzr_email is not None:
239
 
            os.environ['BZREMAIL'] = self.bzr_email
240
 
        if self.email is not None:
241
 
            os.environ['EMAIL'] = self.email
242
 
        super(TestConfigItems, self).tearDown()
243
 
 
244
 
 
245
 
class TestGlobalConfigItems(TestConfigItems):
 
226
class TestGlobalConfigItems(TestCase):
246
227
 
247
228
    def test_user_id(self):
248
229
        config_file = StringIO(sample_config_text)
287
268
                         my_config.signature_checking())
288
269
        self.assertEqual(False, my_config.signature_needed())
289
270
 
290
 
 
291
 
class TestLocationConfig(TestConfigItems):
 
271
    def test_gpg_signing_command(self):
 
272
        config_file = StringIO(sample_config_text)
 
273
        my_config = config.GlobalConfig()
 
274
        my_config._parser = my_config._get_parser(file=config_file)
 
275
        self.assertEqual("gnome-gpg", my_config.gpg_signing_command())
 
276
        self.assertEqual(False, my_config.signature_needed())
 
277
 
 
278
    def test_gpg_signing_command_unset(self):
 
279
        config_file = StringIO("")
 
280
        my_config = config.GlobalConfig()
 
281
        my_config._parser = my_config._get_parser(file=config_file)
 
282
        self.assertEqual("gpg", my_config.gpg_signing_command())
 
283
 
 
284
 
 
285
class TestLocationConfig(TestCase):
292
286
 
293
287
    def test_constructs(self):
294
288
        my_config = config.LocationConfig('http://example.com')
407
401
        self.assertEqual(config.CHECK_ALWAYS,
408
402
                         self.my_config.signature_checking())
409
403
        
410
 
 
411
 
class TestBranchConfigItems(TestConfigItems):
 
404
    def test_gpg_signing_command(self):
 
405
        self.get_location_config('/b')
 
406
        self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command())
 
407
 
 
408
    def test_gpg_signing_command_missing(self):
 
409
        self.get_location_config('/a')
 
410
        self.assertEqual("false", self.my_config.gpg_signing_command())
 
411
 
 
412
 
 
413
class TestBranchConfigItems(TestCase):
412
414
 
413
415
    def test_user_id(self):
414
416
        branch = FakeBranch()
444
446
        (my_config._get_location_config().
445
447
            _get_global_config()._get_parser(config_file))
446
448
        self.assertEqual(config.CHECK_ALWAYS, my_config.signature_checking())
 
449
 
 
450
    def test_gpg_signing_command(self):
 
451
        branch = FakeBranch()
 
452
        my_config = config.BranchConfig(branch)
 
453
        config_file = StringIO(sample_config_text)
 
454
        (my_config._get_location_config().
 
455
            _get_global_config()._get_parser(config_file))
 
456
        self.assertEqual('gnome-gpg', my_config.gpg_signing_command())