~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-19 02:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3944.
  • Revision ID: ian.clatworthy@canonical.com-20090119022415-mo0mcfeiexfktgwt
apply jam's log --short fix (Ian Clatworthy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
"""Tests for finding and reading the bzr config file[s]."""
19
19
# import system imports here
20
 
from bzrlib.util.configobj.configobj import ConfigObj, ConfigObjError
21
20
from cStringIO import StringIO
22
21
import os
23
22
import sys
24
23
 
25
24
#import bzrlib specific imports here
26
 
import bzrlib.config as config
27
 
import bzrlib.errors as errors
28
 
from bzrlib.tests import TestCase, TestCaseInTempDir
 
25
from bzrlib import (
 
26
    branch,
 
27
    bzrdir,
 
28
    config,
 
29
    errors,
 
30
    osutils,
 
31
    mail_client,
 
32
    ui,
 
33
    urlutils,
 
34
    tests,
 
35
    trace,
 
36
    transport,
 
37
    )
 
38
from bzrlib.util.configobj import configobj
29
39
 
30
40
 
31
41
sample_long_alias="log -r-15..-1 --line"
32
 
sample_config_text = ("[DEFAULT]\n"
33
 
                      u"email=Erik B\u00e5gfors <erik@bagfors.nu>\n"
34
 
                      "editor=vim\n"
35
 
                      "gpg_signing_command=gnome-gpg\n"
36
 
                      "log_format=short\n"
37
 
                      "user_global_option=something\n"
38
 
                      "[ALIASES]\n"
39
 
                      "h=help\n"
40
 
                      "ll=" + sample_long_alias + "\n")
41
 
 
42
 
 
43
 
sample_always_signatures = ("[DEFAULT]\n"
44
 
                            "check_signatures=ignore\n"
45
 
                            "create_signatures=always")
46
 
 
47
 
 
48
 
sample_ignore_signatures = ("[DEFAULT]\n"
49
 
                            "check_signatures=require\n"
50
 
                            "create_signatures=never")
51
 
 
52
 
 
53
 
sample_maybe_signatures = ("[DEFAULT]\n"
54
 
                            "check_signatures=ignore\n"
55
 
                            "create_signatures=when-required")
56
 
 
57
 
 
58
 
sample_branches_text = ("[http://www.example.com]\n"
59
 
                        "# Top level policy\n"
60
 
                        "email=Robert Collins <robertc@example.org>\n"
61
 
                        "[http://www.example.com/useglobal]\n"
62
 
                        "# different project, forces global lookup\n"
63
 
                        "recurse=false\n"
64
 
                        "[/b/]\n"
65
 
                        "check_signatures=require\n"
66
 
                        "# test trailing / matching with no children\n"
67
 
                        "[/a/]\n"
68
 
                        "check_signatures=check-available\n"
69
 
                        "gpg_signing_command=false\n"
70
 
                        "user_local_option=local\n"
71
 
                        "# test trailing / matching\n"
72
 
                        "[/a/*]\n"
73
 
                        "#subdirs will match but not the parent\n"
74
 
                        "recurse=False\n"
75
 
                        "[/a/c]\n"
76
 
                        "check_signatures=ignore\n"
77
 
                        "post_commit=bzrlib.tests.test_config.post_commit\n"
78
 
                        "#testing explicit beats globs\n")
79
 
 
 
42
sample_config_text = u"""
 
43
[DEFAULT]
 
44
email=Erik B\u00e5gfors <erik@bagfors.nu>
 
45
editor=vim
 
46
gpg_signing_command=gnome-gpg
 
47
log_format=short
 
48
user_global_option=something
 
49
[ALIASES]
 
50
h=help
 
51
ll=""" + sample_long_alias + "\n"
 
52
 
 
53
 
 
54
sample_always_signatures = """
 
55
[DEFAULT]
 
56
check_signatures=ignore
 
57
create_signatures=always
 
58
"""
 
59
 
 
60
sample_ignore_signatures = """
 
61
[DEFAULT]
 
62
check_signatures=require
 
63
create_signatures=never
 
64
"""
 
65
 
 
66
sample_maybe_signatures = """
 
67
[DEFAULT]
 
68
check_signatures=ignore
 
69
create_signatures=when-required
 
70
"""
 
71
 
 
72
sample_branches_text = """
 
73
[http://www.example.com]
 
74
# Top level policy
 
75
email=Robert Collins <robertc@example.org>
 
76
normal_option = normal
 
77
appendpath_option = append
 
78
appendpath_option:policy = appendpath
 
79
norecurse_option = norecurse
 
80
norecurse_option:policy = norecurse
 
81
[http://www.example.com/ignoreparent]
 
82
# different project: ignore parent dir config
 
83
ignore_parents=true
 
84
[http://www.example.com/norecurse]
 
85
# configuration items that only apply to this dir
 
86
recurse=false
 
87
normal_option = norecurse
 
88
[http://www.example.com/dir]
 
89
appendpath_option = normal
 
90
[/b/]
 
91
check_signatures=require
 
92
# test trailing / matching with no children
 
93
[/a/]
 
94
check_signatures=check-available
 
95
gpg_signing_command=false
 
96
user_local_option=local
 
97
# test trailing / matching
 
98
[/a/*]
 
99
#subdirs will match but not the parent
 
100
[/a/c]
 
101
check_signatures=ignore
 
102
post_commit=bzrlib.tests.test_config.post_commit
 
103
#testing explicit beats globs
 
104
"""
80
105
 
81
106
 
82
107
class InstrumentedConfigObj(object):
96
121
    def __setitem__(self, key, value):
97
122
        self._calls.append(('__setitem__', key, value))
98
123
 
 
124
    def __delitem__(self, key):
 
125
        self._calls.append(('__delitem__', key))
 
126
 
 
127
    def keys(self):
 
128
        self._calls.append(('keys',))
 
129
        return []
 
130
 
99
131
    def write(self, arg):
100
132
        self._calls.append(('write',))
101
133
 
 
134
    def as_bool(self, value):
 
135
        self._calls.append(('as_bool', value))
 
136
        return False
 
137
 
 
138
    def get_value(self, section, name):
 
139
        self._calls.append(('get_value', section, name))
 
140
        return None
 
141
 
102
142
 
103
143
class FakeBranch(object):
104
144
 
105
 
    def __init__(self):
106
 
        self.base = "http://example.com/branches/demo"
107
 
        self.control_files = FakeControlFiles()
108
 
 
109
 
 
110
 
class FakeControlFiles(object):
111
 
 
112
 
    def __init__(self):
113
 
        self.email = 'Robert Collins <robertc@example.net>\n'
 
145
    def __init__(self, base=None, user_id=None):
 
146
        if base is None:
 
147
            self.base = "http://example.com/branches/demo"
 
148
        else:
 
149
            self.base = base
 
150
        self._transport = self.control_files = \
 
151
            FakeControlFilesAndTransport(user_id=user_id)
 
152
 
 
153
    def lock_write(self):
 
154
        pass
 
155
 
 
156
    def unlock(self):
 
157
        pass
 
158
 
 
159
 
 
160
class FakeControlFilesAndTransport(object):
 
161
 
 
162
    def __init__(self, user_id=None):
 
163
        self.files = {}
 
164
        if user_id:
 
165
            self.files['email'] = user_id
 
166
        self._transport = self
114
167
 
115
168
    def get_utf8(self, filename):
116
 
        if filename != 'email':
117
 
            raise NotImplementedError
118
 
        if self.email is not None:
119
 
            return StringIO(self.email)
120
 
        raise errors.NoSuchFile(filename)
 
169
        # from LockableFiles
 
170
        raise AssertionError("get_utf8 should no longer be used")
 
171
 
 
172
    def get(self, filename):
 
173
        # from Transport
 
174
        try:
 
175
            return StringIO(self.files[filename])
 
176
        except KeyError:
 
177
            raise errors.NoSuchFile(filename)
 
178
 
 
179
    def get_bytes(self, filename):
 
180
        # from Transport
 
181
        try:
 
182
            return self.files[filename]
 
183
        except KeyError:
 
184
            raise errors.NoSuchFile(filename)
 
185
 
 
186
    def put(self, filename, fileobj):
 
187
        self.files[filename] = fileobj.read()
 
188
 
 
189
    def put_file(self, filename, fileobj):
 
190
        return self.put(filename, fileobj)
121
191
 
122
192
 
123
193
class InstrumentedConfig(config.Config):
124
194
    """An instrumented config that supplies stubs for template methods."""
125
 
    
 
195
 
126
196
    def __init__(self):
127
197
        super(InstrumentedConfig, self).__init__()
128
198
        self._calls = []
144
214
active = True
145
215
nonactive = False
146
216
"""
147
 
class TestConfigObj(TestCase):
 
217
 
 
218
 
 
219
class TestConfigObj(tests.TestCase):
 
220
 
148
221
    def test_get_bool(self):
149
 
        from bzrlib.config import ConfigObj
150
 
        co = ConfigObj(StringIO(bool_config))
 
222
        co = config.ConfigObj(StringIO(bool_config))
151
223
        self.assertIs(co.get_bool('DEFAULT', 'active'), True)
152
224
        self.assertIs(co.get_bool('DEFAULT', 'inactive'), False)
153
225
        self.assertIs(co.get_bool('UPPERCASE', 'active'), True)
154
226
        self.assertIs(co.get_bool('UPPERCASE', 'nonactive'), False)
155
227
 
156
 
 
157
 
class TestConfig(TestCase):
 
228
    def test_hash_sign_in_value(self):
 
229
        """
 
230
        Before 4.5.0, ConfigObj did not quote # signs in values, so they'd be
 
231
        treated as comments when read in again. (#86838)
 
232
        """
 
233
        co = config.ConfigObj()
 
234
        co['test'] = 'foo#bar'
 
235
        lines = co.write()
 
236
        self.assertEqual(lines, ['test = "foo#bar"'])
 
237
        co2 = config.ConfigObj(lines)
 
238
        self.assertEqual(co2['test'], 'foo#bar')
 
239
 
 
240
 
 
241
erroneous_config = """[section] # line 1
 
242
good=good # line 2
 
243
[section] # line 3
 
244
whocares=notme # line 4
 
245
"""
 
246
 
 
247
 
 
248
class TestConfigObjErrors(tests.TestCase):
 
249
 
 
250
    def test_duplicate_section_name_error_line(self):
 
251
        try:
 
252
            co = configobj.ConfigObj(StringIO(erroneous_config),
 
253
                                     raise_errors=True)
 
254
        except config.configobj.DuplicateError, e:
 
255
            self.assertEqual(3, e.line_number)
 
256
        else:
 
257
            self.fail('Error in config file not detected')
 
258
 
 
259
 
 
260
class TestConfig(tests.TestCase):
158
261
 
159
262
    def test_constructs(self):
160
263
        config.Config()
161
 
 
 
264
 
162
265
    def test_no_default_editor(self):
163
266
        self.assertRaises(NotImplementedError, config.Config().get_editor)
164
267
 
210
313
        self.assertEqual('long', my_config.log_format())
211
314
 
212
315
 
213
 
class TestConfigPath(TestCase):
 
316
class TestConfigPath(tests.TestCase):
214
317
 
215
318
    def setUp(self):
216
319
        super(TestConfigPath, self).setUp()
217
 
        self.old_home = os.environ.get('HOME', None)
218
 
        self.old_appdata = os.environ.get('APPDATA', None)
219
320
        os.environ['HOME'] = '/home/bogus'
220
 
        os.environ['APPDATA'] = \
221
 
            r'C:\Documents and Settings\bogus\Application Data'
 
321
        if sys.platform == 'win32':
 
322
            os.environ['BZR_HOME'] = \
 
323
                r'C:\Documents and Settings\bogus\Application Data'
 
324
            self.bzr_home = \
 
325
                'C:/Documents and Settings/bogus/Application Data/bazaar/2.0'
 
326
        else:
 
327
            self.bzr_home = '/home/bogus/.bazaar'
222
328
 
223
 
    def tearDown(self):
224
 
        if self.old_home is None:
225
 
            del os.environ['HOME']
226
 
        else:
227
 
            os.environ['HOME'] = self.old_home
228
 
        if self.old_appdata is None:
229
 
            del os.environ['APPDATA']
230
 
        else:
231
 
            os.environ['APPDATA'] = self.old_appdata
232
 
        super(TestConfigPath, self).tearDown()
233
 
    
234
329
    def test_config_dir(self):
235
 
        if sys.platform == 'win32':
236
 
            self.assertEqual(config.config_dir(), 
237
 
                'C:/Documents and Settings/bogus/Application Data/bazaar/2.0')
238
 
        else:
239
 
            self.assertEqual(config.config_dir(), '/home/bogus/.bazaar')
 
330
        self.assertEqual(config.config_dir(), self.bzr_home)
240
331
 
241
332
    def test_config_filename(self):
242
 
        if sys.platform == 'win32':
243
 
            self.assertEqual(config.config_filename(), 
244
 
                'C:/Documents and Settings/bogus/Application Data/bazaar/2.0/bazaar.conf')
245
 
        else:
246
 
            self.assertEqual(config.config_filename(),
247
 
                             '/home/bogus/.bazaar/bazaar.conf')
 
333
        self.assertEqual(config.config_filename(),
 
334
                         self.bzr_home + '/bazaar.conf')
248
335
 
249
336
    def test_branches_config_filename(self):
250
 
        if sys.platform == 'win32':
251
 
            self.assertEqual(config.branches_config_filename(), 
252
 
                'C:/Documents and Settings/bogus/Application Data/bazaar/2.0/branches.conf')
253
 
        else:
254
 
            self.assertEqual(config.branches_config_filename(),
255
 
                             '/home/bogus/.bazaar/branches.conf')
256
 
 
257
 
class TestIniConfig(TestCase):
 
337
        self.assertEqual(config.branches_config_filename(),
 
338
                         self.bzr_home + '/branches.conf')
 
339
 
 
340
    def test_locations_config_filename(self):
 
341
        self.assertEqual(config.locations_config_filename(),
 
342
                         self.bzr_home + '/locations.conf')
 
343
 
 
344
    def test_authentication_config_filename(self):
 
345
        self.assertEqual(config.authentication_config_filename(),
 
346
                         self.bzr_home + '/authentication.conf')
 
347
 
 
348
 
 
349
class TestIniConfig(tests.TestCase):
258
350
 
259
351
    def test_contructs(self):
260
352
        my_config = config.IniBasedConfig("nothing")
264
356
        my_config = config.IniBasedConfig(None)
265
357
        self.failUnless(
266
358
            isinstance(my_config._get_parser(file=config_file),
267
 
                        ConfigObj))
 
359
                        configobj.ConfigObj))
268
360
 
269
361
    def test_cached(self):
270
362
        config_file = StringIO(sample_config_text.encode('utf-8'))
273
365
        self.failUnless(my_config._get_parser() is parser)
274
366
 
275
367
 
276
 
class TestGetConfig(TestCase):
 
368
class TestGetConfig(tests.TestCase):
277
369
 
278
370
    def test_constructs(self):
279
371
        my_config = config.GlobalConfig()
280
372
 
281
373
    def test_calls_read_filenames(self):
282
 
        # replace the class that is constructured, to check its parameters
 
374
        # replace the class that is constructed, to check its parameters
283
375
        oldparserclass = config.ConfigObj
284
376
        config.ConfigObj = InstrumentedConfigObj
285
377
        my_config = config.GlobalConfig()
292
384
                                          'utf-8')])
293
385
 
294
386
 
295
 
class TestBranchConfig(TestCaseInTempDir):
 
387
class TestBranchConfig(tests.TestCaseWithTransport):
296
388
 
297
389
    def test_constructs(self):
298
390
        branch = FakeBranch()
306
398
        self.assertEqual(branch.base, location_config.location)
307
399
        self.failUnless(location_config is my_config._get_location_config())
308
400
 
309
 
 
310
 
class TestGlobalConfigItems(TestCase):
 
401
    def test_get_config(self):
 
402
        """The Branch.get_config method works properly"""
 
403
        b = bzrdir.BzrDir.create_standalone_workingtree('.').branch
 
404
        my_config = b.get_config()
 
405
        self.assertIs(my_config.get_user_option('wacky'), None)
 
406
        my_config.set_user_option('wacky', 'unlikely')
 
407
        self.assertEqual(my_config.get_user_option('wacky'), 'unlikely')
 
408
 
 
409
        # Ensure we get the same thing if we start again
 
410
        b2 = branch.Branch.open('.')
 
411
        my_config2 = b2.get_config()
 
412
        self.assertEqual(my_config2.get_user_option('wacky'), 'unlikely')
 
413
 
 
414
    def test_has_explicit_nickname(self):
 
415
        b = self.make_branch('.')
 
416
        self.assertFalse(b.get_config().has_explicit_nickname())
 
417
        b.nick = 'foo'
 
418
        self.assertTrue(b.get_config().has_explicit_nickname())
 
419
 
 
420
    def test_config_url(self):
 
421
        """The Branch.get_config will use section that uses a local url"""
 
422
        branch = self.make_branch('branch')
 
423
        self.assertEqual('branch', branch.nick)
 
424
 
 
425
        locations = config.locations_config_filename()
 
426
        config.ensure_config_dir_exists()
 
427
        local_url = urlutils.local_path_to_url('branch')
 
428
        open(locations, 'wb').write('[%s]\nnickname = foobar' 
 
429
                                    % (local_url,))
 
430
        self.assertEqual('foobar', branch.nick)
 
431
 
 
432
    def test_config_local_path(self):
 
433
        """The Branch.get_config will use a local system path"""
 
434
        branch = self.make_branch('branch')
 
435
        self.assertEqual('branch', branch.nick)
 
436
 
 
437
        locations = config.locations_config_filename()
 
438
        config.ensure_config_dir_exists()
 
439
        open(locations, 'wb').write('[%s/branch]\nnickname = barry' 
 
440
                                    % (osutils.getcwd().encode('utf8'),))
 
441
        self.assertEqual('barry', branch.nick)
 
442
 
 
443
    def test_config_creates_local(self):
 
444
        """Creating a new entry in config uses a local path."""
 
445
        branch = self.make_branch('branch', format='knit')
 
446
        branch.set_push_location('http://foobar')
 
447
        locations = config.locations_config_filename()
 
448
        local_path = osutils.getcwd().encode('utf8')
 
449
        # Surprisingly ConfigObj doesn't create a trailing newline
 
450
        self.check_file_contents(locations,
 
451
                                 '[%s/branch]\n'
 
452
                                 'push_location = http://foobar\n'
 
453
                                 'push_location:policy = norecurse\n'
 
454
                                 % (local_path,))
 
455
 
 
456
    def test_autonick_urlencoded(self):
 
457
        b = self.make_branch('!repo')
 
458
        self.assertEqual('!repo', b.get_config().get_nickname())
 
459
 
 
460
    def test_warn_if_masked(self):
 
461
        _warning = trace.warning
 
462
        warnings = []
 
463
        def warning(*args):
 
464
            warnings.append(args[0] % args[1:])
 
465
 
 
466
        def set_option(store, warn_masked=True):
 
467
            warnings[:] = []
 
468
            conf.set_user_option('example_option', repr(store), store=store,
 
469
                                 warn_masked=warn_masked)
 
470
        def assertWarning(warning):
 
471
            if warning is None:
 
472
                self.assertEqual(0, len(warnings))
 
473
            else:
 
474
                self.assertEqual(1, len(warnings))
 
475
                self.assertEqual(warning, warnings[0])
 
476
        trace.warning = warning
 
477
        try:
 
478
            branch = self.make_branch('.')
 
479
            conf = branch.get_config()
 
480
            set_option(config.STORE_GLOBAL)
 
481
            assertWarning(None)
 
482
            set_option(config.STORE_BRANCH)
 
483
            assertWarning(None)
 
484
            set_option(config.STORE_GLOBAL)
 
485
            assertWarning('Value "4" is masked by "3" from branch.conf')
 
486
            set_option(config.STORE_GLOBAL, warn_masked=False)
 
487
            assertWarning(None)
 
488
            set_option(config.STORE_LOCATION)
 
489
            assertWarning(None)
 
490
            set_option(config.STORE_BRANCH)
 
491
            assertWarning('Value "3" is masked by "0" from locations.conf')
 
492
            set_option(config.STORE_BRANCH, warn_masked=False)
 
493
            assertWarning(None)
 
494
        finally:
 
495
            trace.warning = _warning
 
496
 
 
497
 
 
498
class TestGlobalConfigItems(tests.TestCase):
311
499
 
312
500
    def test_user_id(self):
313
501
        config_file = StringIO(sample_config_text.encode('utf-8'))
387
575
        my_config = self._get_sample_config()
388
576
        self.assertEqual("something",
389
577
                         my_config.get_user_option('user_global_option'))
390
 
        
 
578
 
391
579
    def test_post_commit_default(self):
392
580
        my_config = self._get_sample_config()
393
581
        self.assertEqual(None, my_config.post_commit())
400
588
        my_config = self._get_sample_config()
401
589
        self.assertEqual('help', my_config.get_alias('h'))
402
590
 
 
591
    def test_get_aliases(self):
 
592
        my_config = self._get_sample_config()
 
593
        aliases = my_config.get_aliases()
 
594
        self.assertEqual(2, len(aliases))
 
595
        sorted_keys = sorted(aliases)
 
596
        self.assertEqual('help', aliases[sorted_keys[0]])
 
597
        self.assertEqual(sample_long_alias, aliases[sorted_keys[1]])
 
598
 
403
599
    def test_get_no_alias(self):
404
600
        my_config = self._get_sample_config()
405
601
        self.assertEqual(None, my_config.get_alias('foo'))
409
605
        self.assertEqual(sample_long_alias, my_config.get_alias('ll'))
410
606
 
411
607
 
412
 
class TestLocationConfig(TestCaseInTempDir):
 
608
class TestGlobalConfigSavingOptions(tests.TestCaseInTempDir):
 
609
 
 
610
    def test_empty(self):
 
611
        my_config = config.GlobalConfig()
 
612
        self.assertEqual(0, len(my_config.get_aliases()))
 
613
 
 
614
    def test_set_alias(self):
 
615
        my_config = config.GlobalConfig()
 
616
        alias_value = 'commit --strict'
 
617
        my_config.set_alias('commit', alias_value)
 
618
        new_config = config.GlobalConfig()
 
619
        self.assertEqual(alias_value, new_config.get_alias('commit'))
 
620
 
 
621
    def test_remove_alias(self):
 
622
        my_config = config.GlobalConfig()
 
623
        my_config.set_alias('commit', 'commit --strict')
 
624
        # Now remove the alias again.
 
625
        my_config.unset_alias('commit')
 
626
        new_config = config.GlobalConfig()
 
627
        self.assertIs(None, new_config.get_alias('commit'))
 
628
 
 
629
 
 
630
class TestLocationConfig(tests.TestCaseInTempDir):
413
631
 
414
632
    def test_constructs(self):
415
633
        my_config = config.LocationConfig('http://example.com')
419
637
        # This is testing the correct file names are provided.
420
638
        # TODO: consolidate with the test for GlobalConfigs filename checks.
421
639
        #
422
 
        # replace the class that is constructured, to check its parameters
 
640
        # replace the class that is constructed, to check its parameters
423
641
        oldparserclass = config.ConfigObj
424
642
        config.ConfigObj = InstrumentedConfigObj
425
 
        my_config = config.LocationConfig('http://www.example.com')
426
643
        try:
 
644
            my_config = config.LocationConfig('http://www.example.com')
427
645
            parser = my_config._get_parser()
428
646
        finally:
429
647
            config.ConfigObj = oldparserclass
430
648
        self.failUnless(isinstance(parser, InstrumentedConfigObj))
431
649
        self.assertEqual(parser._calls,
432
 
                         [('__init__', config.branches_config_filename(),
 
650
                         [('__init__', config.locations_config_filename(),
433
651
                           'utf-8')])
 
652
        config.ensure_config_dir_exists()
 
653
        #os.mkdir(config.config_dir())
 
654
        f = file(config.branches_config_filename(), 'wb')
 
655
        f.write('')
 
656
        f.close()
 
657
        oldparserclass = config.ConfigObj
 
658
        config.ConfigObj = InstrumentedConfigObj
 
659
        try:
 
660
            my_config = config.LocationConfig('http://www.example.com')
 
661
            parser = my_config._get_parser()
 
662
        finally:
 
663
            config.ConfigObj = oldparserclass
434
664
 
435
665
    def test_get_global_config(self):
436
 
        my_config = config.LocationConfig('http://example.com')
 
666
        my_config = config.BranchConfig(FakeBranch('http://example.com'))
437
667
        global_config = my_config._get_global_config()
438
668
        self.failUnless(isinstance(global_config, config.GlobalConfig))
439
669
        self.failUnless(global_config is my_config._get_global_config())
440
670
 
441
 
    def test__get_section_no_match(self):
442
 
        self.get_location_config('/')
443
 
        self.assertEqual(None, self.my_config._get_section())
444
 
        
445
 
    def test__get_section_exact(self):
446
 
        self.get_location_config('http://www.example.com')
447
 
        self.assertEqual('http://www.example.com',
448
 
                         self.my_config._get_section())
449
 
   
450
 
    def test__get_section_suffix_does_not(self):
451
 
        self.get_location_config('http://www.example.com-com')
452
 
        self.assertEqual(None, self.my_config._get_section())
453
 
 
454
 
    def test__get_section_subdir_recursive(self):
455
 
        self.get_location_config('http://www.example.com/com')
456
 
        self.assertEqual('http://www.example.com',
457
 
                         self.my_config._get_section())
458
 
 
459
 
    def test__get_section_subdir_matches(self):
460
 
        self.get_location_config('http://www.example.com/useglobal')
461
 
        self.assertEqual('http://www.example.com/useglobal',
462
 
                         self.my_config._get_section())
463
 
 
464
 
    def test__get_section_subdir_nonrecursive(self):
465
 
        self.get_location_config(
466
 
            'http://www.example.com/useglobal/childbranch')
467
 
        self.assertEqual('http://www.example.com',
468
 
                         self.my_config._get_section())
469
 
 
470
 
    def test__get_section_subdir_trailing_slash(self):
471
 
        self.get_location_config('/b')
472
 
        self.assertEqual('/b/', self.my_config._get_section())
473
 
 
474
 
    def test__get_section_subdir_child(self):
475
 
        self.get_location_config('/a/foo')
476
 
        self.assertEqual('/a/*', self.my_config._get_section())
477
 
 
478
 
    def test__get_section_subdir_child_child(self):
479
 
        self.get_location_config('/a/foo/bar')
480
 
        self.assertEqual('/a/', self.my_config._get_section())
481
 
 
482
 
    def test__get_section_trailing_slash_with_children(self):
483
 
        self.get_location_config('/a/')
484
 
        self.assertEqual('/a/', self.my_config._get_section())
485
 
 
486
 
    def test__get_section_explicit_over_glob(self):
487
 
        self.get_location_config('/a/c')
488
 
        self.assertEqual('/a/c', self.my_config._get_section())
489
 
 
 
671
    def test__get_matching_sections_no_match(self):
 
672
        self.get_branch_config('/')
 
673
        self.assertEqual([], self.my_location_config._get_matching_sections())
 
674
 
 
675
    def test__get_matching_sections_exact(self):
 
676
        self.get_branch_config('http://www.example.com')
 
677
        self.assertEqual([('http://www.example.com', '')],
 
678
                         self.my_location_config._get_matching_sections())
 
679
 
 
680
    def test__get_matching_sections_suffix_does_not(self):
 
681
        self.get_branch_config('http://www.example.com-com')
 
682
        self.assertEqual([], self.my_location_config._get_matching_sections())
 
683
 
 
684
    def test__get_matching_sections_subdir_recursive(self):
 
685
        self.get_branch_config('http://www.example.com/com')
 
686
        self.assertEqual([('http://www.example.com', 'com')],
 
687
                         self.my_location_config._get_matching_sections())
 
688
 
 
689
    def test__get_matching_sections_ignoreparent(self):
 
690
        self.get_branch_config('http://www.example.com/ignoreparent')
 
691
        self.assertEqual([('http://www.example.com/ignoreparent', '')],
 
692
                         self.my_location_config._get_matching_sections())
 
693
 
 
694
    def test__get_matching_sections_ignoreparent_subdir(self):
 
695
        self.get_branch_config(
 
696
            'http://www.example.com/ignoreparent/childbranch')
 
697
        self.assertEqual([('http://www.example.com/ignoreparent',
 
698
                           'childbranch')],
 
699
                         self.my_location_config._get_matching_sections())
 
700
 
 
701
    def test__get_matching_sections_subdir_trailing_slash(self):
 
702
        self.get_branch_config('/b')
 
703
        self.assertEqual([('/b/', '')],
 
704
                         self.my_location_config._get_matching_sections())
 
705
 
 
706
    def test__get_matching_sections_subdir_child(self):
 
707
        self.get_branch_config('/a/foo')
 
708
        self.assertEqual([('/a/*', ''), ('/a/', 'foo')],
 
709
                         self.my_location_config._get_matching_sections())
 
710
 
 
711
    def test__get_matching_sections_subdir_child_child(self):
 
712
        self.get_branch_config('/a/foo/bar')
 
713
        self.assertEqual([('/a/*', 'bar'), ('/a/', 'foo/bar')],
 
714
                         self.my_location_config._get_matching_sections())
 
715
 
 
716
    def test__get_matching_sections_trailing_slash_with_children(self):
 
717
        self.get_branch_config('/a/')
 
718
        self.assertEqual([('/a/', '')],
 
719
                         self.my_location_config._get_matching_sections())
 
720
 
 
721
    def test__get_matching_sections_explicit_over_glob(self):
 
722
        # XXX: 2006-09-08 jamesh
 
723
        # This test only passes because ord('c') > ord('*').  If there
 
724
        # was a config section for '/a/?', it would get precedence
 
725
        # over '/a/c'.
 
726
        self.get_branch_config('/a/c')
 
727
        self.assertEqual([('/a/c', ''), ('/a/*', ''), ('/a/', 'c')],
 
728
                         self.my_location_config._get_matching_sections())
 
729
 
 
730
    def test__get_option_policy_normal(self):
 
731
        self.get_branch_config('http://www.example.com')
 
732
        self.assertEqual(
 
733
            self.my_location_config._get_config_policy(
 
734
            'http://www.example.com', 'normal_option'),
 
735
            config.POLICY_NONE)
 
736
 
 
737
    def test__get_option_policy_norecurse(self):
 
738
        self.get_branch_config('http://www.example.com')
 
739
        self.assertEqual(
 
740
            self.my_location_config._get_option_policy(
 
741
            'http://www.example.com', 'norecurse_option'),
 
742
            config.POLICY_NORECURSE)
 
743
        # Test old recurse=False setting:
 
744
        self.assertEqual(
 
745
            self.my_location_config._get_option_policy(
 
746
            'http://www.example.com/norecurse', 'normal_option'),
 
747
            config.POLICY_NORECURSE)
 
748
 
 
749
    def test__get_option_policy_normal(self):
 
750
        self.get_branch_config('http://www.example.com')
 
751
        self.assertEqual(
 
752
            self.my_location_config._get_option_policy(
 
753
            'http://www.example.com', 'appendpath_option'),
 
754
            config.POLICY_APPENDPATH)
490
755
 
491
756
    def test_location_without_username(self):
492
 
        self.get_location_config('http://www.example.com/useglobal')
 
757
        self.get_branch_config('http://www.example.com/ignoreparent')
493
758
        self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>',
494
759
                         self.my_config.username())
495
760
 
496
761
    def test_location_not_listed(self):
497
762
        """Test that the global username is used when no location matches"""
498
 
        self.get_location_config('/home/robertc/sources')
 
763
        self.get_branch_config('/home/robertc/sources')
499
764
        self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>',
500
765
                         self.my_config.username())
501
766
 
502
767
    def test_overriding_location(self):
503
 
        self.get_location_config('http://www.example.com/foo')
 
768
        self.get_branch_config('http://www.example.com/foo')
504
769
        self.assertEqual('Robert Collins <robertc@example.org>',
505
770
                         self.my_config.username())
506
771
 
507
772
    def test_signatures_not_set(self):
508
 
        self.get_location_config('http://www.example.com',
 
773
        self.get_branch_config('http://www.example.com',
509
774
                                 global_config=sample_ignore_signatures)
510
775
        self.assertEqual(config.CHECK_ALWAYS,
511
776
                         self.my_config.signature_checking())
513
778
                         self.my_config.signing_policy())
514
779
 
515
780
    def test_signatures_never(self):
516
 
        self.get_location_config('/a/c')
 
781
        self.get_branch_config('/a/c')
517
782
        self.assertEqual(config.CHECK_NEVER,
518
783
                         self.my_config.signature_checking())
519
 
        
 
784
 
520
785
    def test_signatures_when_available(self):
521
 
        self.get_location_config('/a/', global_config=sample_ignore_signatures)
 
786
        self.get_branch_config('/a/', global_config=sample_ignore_signatures)
522
787
        self.assertEqual(config.CHECK_IF_POSSIBLE,
523
788
                         self.my_config.signature_checking())
524
 
        
 
789
 
525
790
    def test_signatures_always(self):
526
 
        self.get_location_config('/b')
 
791
        self.get_branch_config('/b')
527
792
        self.assertEqual(config.CHECK_ALWAYS,
528
793
                         self.my_config.signature_checking())
529
 
        
 
794
 
530
795
    def test_gpg_signing_command(self):
531
 
        self.get_location_config('/b')
 
796
        self.get_branch_config('/b')
532
797
        self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command())
533
798
 
534
799
    def test_gpg_signing_command_missing(self):
535
 
        self.get_location_config('/a')
 
800
        self.get_branch_config('/a')
536
801
        self.assertEqual("false", self.my_config.gpg_signing_command())
537
802
 
538
803
    def test_get_user_option_global(self):
539
 
        self.get_location_config('/a')
 
804
        self.get_branch_config('/a')
540
805
        self.assertEqual('something',
541
806
                         self.my_config.get_user_option('user_global_option'))
542
807
 
543
808
    def test_get_user_option_local(self):
544
 
        self.get_location_config('/a')
 
809
        self.get_branch_config('/a')
545
810
        self.assertEqual('local',
546
811
                         self.my_config.get_user_option('user_local_option'))
547
 
        
 
812
 
 
813
    def test_get_user_option_appendpath(self):
 
814
        # returned as is for the base path:
 
815
        self.get_branch_config('http://www.example.com')
 
816
        self.assertEqual('append',
 
817
                         self.my_config.get_user_option('appendpath_option'))
 
818
        # Extra path components get appended:
 
819
        self.get_branch_config('http://www.example.com/a/b/c')
 
820
        self.assertEqual('append/a/b/c',
 
821
                         self.my_config.get_user_option('appendpath_option'))
 
822
        # Overriden for http://www.example.com/dir, where it is a
 
823
        # normal option:
 
824
        self.get_branch_config('http://www.example.com/dir/a/b/c')
 
825
        self.assertEqual('normal',
 
826
                         self.my_config.get_user_option('appendpath_option'))
 
827
 
 
828
    def test_get_user_option_norecurse(self):
 
829
        self.get_branch_config('http://www.example.com')
 
830
        self.assertEqual('norecurse',
 
831
                         self.my_config.get_user_option('norecurse_option'))
 
832
        self.get_branch_config('http://www.example.com/dir')
 
833
        self.assertEqual(None,
 
834
                         self.my_config.get_user_option('norecurse_option'))
 
835
        # http://www.example.com/norecurse is a recurse=False section
 
836
        # that redefines normal_option.  Subdirectories do not pick up
 
837
        # this redefinition.
 
838
        self.get_branch_config('http://www.example.com/norecurse')
 
839
        self.assertEqual('norecurse',
 
840
                         self.my_config.get_user_option('normal_option'))
 
841
        self.get_branch_config('http://www.example.com/norecurse/subdir')
 
842
        self.assertEqual('normal',
 
843
                         self.my_config.get_user_option('normal_option'))
 
844
 
 
845
    def test_set_user_option_norecurse(self):
 
846
        self.get_branch_config('http://www.example.com')
 
847
        self.my_config.set_user_option('foo', 'bar',
 
848
                                       store=config.STORE_LOCATION_NORECURSE)
 
849
        self.assertEqual(
 
850
            self.my_location_config._get_option_policy(
 
851
            'http://www.example.com', 'foo'),
 
852
            config.POLICY_NORECURSE)
 
853
 
 
854
    def test_set_user_option_appendpath(self):
 
855
        self.get_branch_config('http://www.example.com')
 
856
        self.my_config.set_user_option('foo', 'bar',
 
857
                                       store=config.STORE_LOCATION_APPENDPATH)
 
858
        self.assertEqual(
 
859
            self.my_location_config._get_option_policy(
 
860
            'http://www.example.com', 'foo'),
 
861
            config.POLICY_APPENDPATH)
 
862
 
 
863
    def test_set_user_option_change_policy(self):
 
864
        self.get_branch_config('http://www.example.com')
 
865
        self.my_config.set_user_option('norecurse_option', 'normal',
 
866
                                       store=config.STORE_LOCATION)
 
867
        self.assertEqual(
 
868
            self.my_location_config._get_option_policy(
 
869
            'http://www.example.com', 'norecurse_option'),
 
870
            config.POLICY_NONE)
 
871
 
 
872
    def test_set_user_option_recurse_false_section(self):
 
873
        # The following section has recurse=False set.  The test is to
 
874
        # make sure that a normal option can be added to the section,
 
875
        # converting recurse=False to the norecurse policy.
 
876
        self.get_branch_config('http://www.example.com/norecurse')
 
877
        self.callDeprecated(['The recurse option is deprecated as of 0.14.  '
 
878
                             'The section "http://www.example.com/norecurse" '
 
879
                             'has been converted to use policies.'],
 
880
                            self.my_config.set_user_option,
 
881
                            'foo', 'bar', store=config.STORE_LOCATION)
 
882
        self.assertEqual(
 
883
            self.my_location_config._get_option_policy(
 
884
            'http://www.example.com/norecurse', 'foo'),
 
885
            config.POLICY_NONE)
 
886
        # The previously existing option is still norecurse:
 
887
        self.assertEqual(
 
888
            self.my_location_config._get_option_policy(
 
889
            'http://www.example.com/norecurse', 'normal_option'),
 
890
            config.POLICY_NORECURSE)
 
891
 
548
892
    def test_post_commit_default(self):
549
 
        self.get_location_config('/a/c')
 
893
        self.get_branch_config('/a/c')
550
894
        self.assertEqual('bzrlib.tests.test_config.post_commit',
551
895
                         self.my_config.post_commit())
552
896
 
553
 
    def get_location_config(self, location, global_config=None):
 
897
    def get_branch_config(self, location, global_config=None):
554
898
        if global_config is None:
555
899
            global_file = StringIO(sample_config_text.encode('utf-8'))
556
900
        else:
557
901
            global_file = StringIO(global_config.encode('utf-8'))
558
902
        branches_file = StringIO(sample_branches_text.encode('utf-8'))
559
 
        self.my_config = config.LocationConfig(location)
560
 
        self.my_config._get_parser(branches_file)
 
903
        self.my_config = config.BranchConfig(FakeBranch(location))
 
904
        # Force location config to use specified file
 
905
        self.my_location_config = self.my_config._get_location_config()
 
906
        self.my_location_config._get_parser(branches_file)
 
907
        # Force global config to use specified file
561
908
        self.my_config._get_global_config()._get_parser(global_file)
562
909
 
563
910
    def test_set_user_setting_sets_and_saves(self):
564
 
        self.get_location_config('/a/c')
 
911
        self.get_branch_config('/a/c')
565
912
        record = InstrumentedConfigObj("foo")
566
 
        self.my_config._parser = record
 
913
        self.my_location_config._parser = record
567
914
 
568
915
        real_mkdir = os.mkdir
569
916
        self.created = False
574
921
 
575
922
        os.mkdir = checked_mkdir
576
923
        try:
577
 
            self.my_config.set_user_option('foo', 'bar')
 
924
            self.callDeprecated(['The recurse option is deprecated as of '
 
925
                                 '0.14.  The section "/a/c" has been '
 
926
                                 'converted to use policies.'],
 
927
                                self.my_config.set_user_option,
 
928
                                'foo', 'bar', store=config.STORE_LOCATION)
578
929
        finally:
579
930
            os.mkdir = real_mkdir
580
931
 
584
935
                          ('__setitem__', '/a/c', {}),
585
936
                          ('__getitem__', '/a/c'),
586
937
                          ('__setitem__', 'foo', 'bar'),
 
938
                          ('__getitem__', '/a/c'),
 
939
                          ('as_bool', 'recurse'),
 
940
                          ('__getitem__', '/a/c'),
 
941
                          ('__delitem__', 'recurse'),
 
942
                          ('__getitem__', '/a/c'),
 
943
                          ('keys',),
 
944
                          ('__getitem__', '/a/c'),
 
945
                          ('__contains__', 'foo:policy'),
587
946
                          ('write',)],
588
947
                         record._calls[1:])
589
948
 
590
 
 
591
 
class TestBranchConfigItems(TestCase):
 
949
    def test_set_user_setting_sets_and_saves2(self):
 
950
        self.get_branch_config('/a/c')
 
951
        self.assertIs(self.my_config.get_user_option('foo'), None)
 
952
        self.my_config.set_user_option('foo', 'bar')
 
953
        self.assertEqual(
 
954
            self.my_config.branch.control_files.files['branch.conf'].strip(),
 
955
            'foo = bar')
 
956
        self.assertEqual(self.my_config.get_user_option('foo'), 'bar')
 
957
        self.my_config.set_user_option('foo', 'baz',
 
958
                                       store=config.STORE_LOCATION)
 
959
        self.assertEqual(self.my_config.get_user_option('foo'), 'baz')
 
960
        self.my_config.set_user_option('foo', 'qux')
 
961
        self.assertEqual(self.my_config.get_user_option('foo'), 'baz')
 
962
 
 
963
    def test_get_bzr_remote_path(self):
 
964
        my_config = config.LocationConfig('/a/c')
 
965
        self.assertEqual('bzr', my_config.get_bzr_remote_path())
 
966
        my_config.set_user_option('bzr_remote_path', '/path-bzr')
 
967
        self.assertEqual('/path-bzr', my_config.get_bzr_remote_path())
 
968
        os.environ['BZR_REMOTE_PATH'] = '/environ-bzr'
 
969
        self.assertEqual('/environ-bzr', my_config.get_bzr_remote_path())
 
970
 
 
971
 
 
972
precedence_global = 'option = global'
 
973
precedence_branch = 'option = branch'
 
974
precedence_location = """
 
975
[http://]
 
976
recurse = true
 
977
option = recurse
 
978
[http://example.com/specific]
 
979
option = exact
 
980
"""
 
981
 
 
982
 
 
983
class TestBranchConfigItems(tests.TestCaseInTempDir):
 
984
 
 
985
    def get_branch_config(self, global_config=None, location=None,
 
986
                          location_config=None, branch_data_config=None):
 
987
        my_config = config.BranchConfig(FakeBranch(location))
 
988
        if global_config is not None:
 
989
            global_file = StringIO(global_config.encode('utf-8'))
 
990
            my_config._get_global_config()._get_parser(global_file)
 
991
        self.my_location_config = my_config._get_location_config()
 
992
        if location_config is not None:
 
993
            location_file = StringIO(location_config.encode('utf-8'))
 
994
            self.my_location_config._get_parser(location_file)
 
995
        if branch_data_config is not None:
 
996
            my_config.branch.control_files.files['branch.conf'] = \
 
997
                branch_data_config
 
998
        return my_config
592
999
 
593
1000
    def test_user_id(self):
594
 
        branch = FakeBranch()
 
1001
        branch = FakeBranch(user_id='Robert Collins <robertc@example.net>')
595
1002
        my_config = config.BranchConfig(branch)
596
1003
        self.assertEqual("Robert Collins <robertc@example.net>",
597
 
                         my_config._get_user_id())
598
 
        branch.control_files.email = "John"
599
 
        self.assertEqual("John", my_config._get_user_id())
 
1004
                         my_config.username())
 
1005
        my_config.branch.control_files.files['email'] = "John"
 
1006
        my_config.set_user_option('email',
 
1007
                                  "Robert Collins <robertc@example.org>")
 
1008
        self.assertEqual("John", my_config.username())
 
1009
        del my_config.branch.control_files.files['email']
 
1010
        self.assertEqual("Robert Collins <robertc@example.org>",
 
1011
                         my_config.username())
600
1012
 
601
1013
    def test_not_set_in_branch(self):
602
 
        branch = FakeBranch()
603
 
        my_config = config.BranchConfig(branch)
604
 
        branch.control_files.email = None
605
 
        config_file = StringIO(sample_config_text.encode('utf-8'))
606
 
        (my_config._get_location_config().
607
 
            _get_global_config()._get_parser(config_file))
 
1014
        my_config = self.get_branch_config(sample_config_text)
608
1015
        self.assertEqual(u"Erik B\u00e5gfors <erik@bagfors.nu>",
609
1016
                         my_config._get_user_id())
610
 
        branch.control_files.email = "John"
 
1017
        my_config.branch.control_files.files['email'] = "John"
611
1018
        self.assertEqual("John", my_config._get_user_id())
612
1019
 
613
 
    def test_BZREMAIL_OVERRIDES(self):
614
 
        os.environ['BZREMAIL'] = "Robert Collins <robertc@example.org>"
 
1020
    def test_BZR_EMAIL_OVERRIDES(self):
 
1021
        os.environ['BZR_EMAIL'] = "Robert Collins <robertc@example.org>"
615
1022
        branch = FakeBranch()
616
1023
        my_config = config.BranchConfig(branch)
617
1024
        self.assertEqual("Robert Collins <robertc@example.org>",
618
1025
                         my_config.username())
619
 
    
 
1026
 
620
1027
    def test_signatures_forced(self):
621
 
        branch = FakeBranch()
622
 
        my_config = config.BranchConfig(branch)
623
 
        config_file = StringIO(sample_always_signatures)
624
 
        (my_config._get_location_config().
625
 
            _get_global_config()._get_parser(config_file))
 
1028
        my_config = self.get_branch_config(
 
1029
            global_config=sample_always_signatures)
 
1030
        self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
 
1031
        self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy())
 
1032
        self.assertTrue(my_config.signature_needed())
 
1033
 
 
1034
    def test_signatures_forced_branch(self):
 
1035
        my_config = self.get_branch_config(
 
1036
            global_config=sample_ignore_signatures,
 
1037
            branch_data_config=sample_always_signatures)
626
1038
        self.assertEqual(config.CHECK_NEVER, my_config.signature_checking())
627
1039
        self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy())
628
1040
        self.assertTrue(my_config.signature_needed())
629
1041
 
630
1042
    def test_gpg_signing_command(self):
631
 
        branch = FakeBranch()
632
 
        my_config = config.BranchConfig(branch)
 
1043
        my_config = self.get_branch_config(
 
1044
            # branch data cannot set gpg_signing_command
 
1045
            branch_data_config="gpg_signing_command=pgp")
633
1046
        config_file = StringIO(sample_config_text.encode('utf-8'))
634
 
        (my_config._get_location_config().
635
 
            _get_global_config()._get_parser(config_file))
 
1047
        my_config._get_global_config()._get_parser(config_file)
636
1048
        self.assertEqual('gnome-gpg', my_config.gpg_signing_command())
637
1049
 
638
1050
    def test_get_user_option_global(self):
639
1051
        branch = FakeBranch()
640
1052
        my_config = config.BranchConfig(branch)
641
1053
        config_file = StringIO(sample_config_text.encode('utf-8'))
642
 
        (my_config._get_location_config().
643
 
            _get_global_config()._get_parser(config_file))
 
1054
        (my_config._get_global_config()._get_parser(config_file))
644
1055
        self.assertEqual('something',
645
1056
                         my_config.get_user_option('user_global_option'))
646
1057
 
647
1058
    def test_post_commit_default(self):
648
1059
        branch = FakeBranch()
649
 
        branch.base='/a/c'
650
 
        my_config = config.BranchConfig(branch)
651
 
        config_file = StringIO(sample_config_text.encode('utf-8'))
652
 
        (my_config._get_location_config().
653
 
            _get_global_config()._get_parser(config_file))
654
 
        branch_file = StringIO(sample_branches_text)
655
 
        my_config._get_location_config()._get_parser(branch_file)
656
 
        self.assertEqual('bzrlib.tests.test_config.post_commit',
657
 
                         my_config.post_commit())
658
 
 
659
 
 
660
 
class TestMailAddressExtraction(TestCase):
 
1060
        my_config = self.get_branch_config(sample_config_text, '/a/c',
 
1061
                                           sample_branches_text)
 
1062
        self.assertEqual(my_config.branch.base, '/a/c')
 
1063
        self.assertEqual('bzrlib.tests.test_config.post_commit',
 
1064
                         my_config.post_commit())
 
1065
        my_config.set_user_option('post_commit', 'rmtree_root')
 
1066
        # post-commit is ignored when bresent in branch data
 
1067
        self.assertEqual('bzrlib.tests.test_config.post_commit',
 
1068
                         my_config.post_commit())
 
1069
        my_config.set_user_option('post_commit', 'rmtree_root',
 
1070
                                  store=config.STORE_LOCATION)
 
1071
        self.assertEqual('rmtree_root', my_config.post_commit())
 
1072
 
 
1073
    def test_config_precedence(self):
 
1074
        my_config = self.get_branch_config(global_config=precedence_global)
 
1075
        self.assertEqual(my_config.get_user_option('option'), 'global')
 
1076
        my_config = self.get_branch_config(global_config=precedence_global,
 
1077
                                      branch_data_config=precedence_branch)
 
1078
        self.assertEqual(my_config.get_user_option('option'), 'branch')
 
1079
        my_config = self.get_branch_config(global_config=precedence_global,
 
1080
                                      branch_data_config=precedence_branch,
 
1081
                                      location_config=precedence_location)
 
1082
        self.assertEqual(my_config.get_user_option('option'), 'recurse')
 
1083
        my_config = self.get_branch_config(global_config=precedence_global,
 
1084
                                      branch_data_config=precedence_branch,
 
1085
                                      location_config=precedence_location,
 
1086
                                      location='http://example.com/specific')
 
1087
        self.assertEqual(my_config.get_user_option('option'), 'exact')
 
1088
 
 
1089
    def test_get_mail_client(self):
 
1090
        config = self.get_branch_config()
 
1091
        client = config.get_mail_client()
 
1092
        self.assertIsInstance(client, mail_client.DefaultMail)
 
1093
 
 
1094
        # Specific clients
 
1095
        config.set_user_option('mail_client', 'evolution')
 
1096
        client = config.get_mail_client()
 
1097
        self.assertIsInstance(client, mail_client.Evolution)
 
1098
 
 
1099
        config.set_user_option('mail_client', 'kmail')
 
1100
        client = config.get_mail_client()
 
1101
        self.assertIsInstance(client, mail_client.KMail)
 
1102
 
 
1103
        config.set_user_option('mail_client', 'mutt')
 
1104
        client = config.get_mail_client()
 
1105
        self.assertIsInstance(client, mail_client.Mutt)
 
1106
 
 
1107
        config.set_user_option('mail_client', 'thunderbird')
 
1108
        client = config.get_mail_client()
 
1109
        self.assertIsInstance(client, mail_client.Thunderbird)
 
1110
 
 
1111
        # Generic options
 
1112
        config.set_user_option('mail_client', 'default')
 
1113
        client = config.get_mail_client()
 
1114
        self.assertIsInstance(client, mail_client.DefaultMail)
 
1115
 
 
1116
        config.set_user_option('mail_client', 'editor')
 
1117
        client = config.get_mail_client()
 
1118
        self.assertIsInstance(client, mail_client.Editor)
 
1119
 
 
1120
        config.set_user_option('mail_client', 'mapi')
 
1121
        client = config.get_mail_client()
 
1122
        self.assertIsInstance(client, mail_client.MAPIClient)
 
1123
 
 
1124
        config.set_user_option('mail_client', 'xdg-email')
 
1125
        client = config.get_mail_client()
 
1126
        self.assertIsInstance(client, mail_client.XDGEmail)
 
1127
 
 
1128
        config.set_user_option('mail_client', 'firebird')
 
1129
        self.assertRaises(errors.UnknownMailClient, config.get_mail_client)
 
1130
 
 
1131
 
 
1132
class TestMailAddressExtraction(tests.TestCase):
661
1133
 
662
1134
    def test_extract_email_address(self):
663
1135
        self.assertEqual('jane@test.com',
664
1136
                         config.extract_email_address('Jane <jane@test.com>'))
665
 
        self.assertRaises(errors.BzrError,
 
1137
        self.assertRaises(errors.NoEmailInUsername,
666
1138
                          config.extract_email_address, 'Jane Tester')
 
1139
 
 
1140
    def test_parse_username(self):
 
1141
        self.assertEqual(('', 'jdoe@example.com'),
 
1142
                         config.parse_username('jdoe@example.com'))
 
1143
        self.assertEqual(('', 'jdoe@example.com'),
 
1144
                         config.parse_username('<jdoe@example.com>'))
 
1145
        self.assertEqual(('John Doe', 'jdoe@example.com'),
 
1146
                         config.parse_username('John Doe <jdoe@example.com>'))
 
1147
        self.assertEqual(('John Doe', ''),
 
1148
                         config.parse_username('John Doe'))
 
1149
        self.assertEqual(('John Doe', 'jdoe@example.com'),
 
1150
                         config.parse_username('John Doe jdoe@example.com'))
 
1151
 
 
1152
class TestTreeConfig(tests.TestCaseWithTransport):
 
1153
 
 
1154
    def test_get_value(self):
 
1155
        """Test that retreiving a value from a section is possible"""
 
1156
        branch = self.make_branch('.')
 
1157
        tree_config = config.TreeConfig(branch)
 
1158
        tree_config.set_option('value', 'key', 'SECTION')
 
1159
        tree_config.set_option('value2', 'key2')
 
1160
        tree_config.set_option('value3-top', 'key3')
 
1161
        tree_config.set_option('value3-section', 'key3', 'SECTION')
 
1162
        value = tree_config.get_option('key', 'SECTION')
 
1163
        self.assertEqual(value, 'value')
 
1164
        value = tree_config.get_option('key2')
 
1165
        self.assertEqual(value, 'value2')
 
1166
        self.assertEqual(tree_config.get_option('non-existant'), None)
 
1167
        value = tree_config.get_option('non-existant', 'SECTION')
 
1168
        self.assertEqual(value, None)
 
1169
        value = tree_config.get_option('non-existant', default='default')
 
1170
        self.assertEqual(value, 'default')
 
1171
        self.assertEqual(tree_config.get_option('key2', 'NOSECTION'), None)
 
1172
        value = tree_config.get_option('key2', 'NOSECTION', default='default')
 
1173
        self.assertEqual(value, 'default')
 
1174
        value = tree_config.get_option('key3')
 
1175
        self.assertEqual(value, 'value3-top')
 
1176
        value = tree_config.get_option('key3', 'SECTION')
 
1177
        self.assertEqual(value, 'value3-section')
 
1178
 
 
1179
 
 
1180
class TestTransportConfig(tests.TestCaseWithTransport):
 
1181
 
 
1182
    def test_get_value(self):
 
1183
        """Test that retreiving a value from a section is possible"""
 
1184
        bzrdir_config = config.TransportConfig(transport.get_transport('.'),
 
1185
                                               'control.conf')
 
1186
        bzrdir_config.set_option('value', 'key', 'SECTION')
 
1187
        bzrdir_config.set_option('value2', 'key2')
 
1188
        bzrdir_config.set_option('value3-top', 'key3')
 
1189
        bzrdir_config.set_option('value3-section', 'key3', 'SECTION')
 
1190
        value = bzrdir_config.get_option('key', 'SECTION')
 
1191
        self.assertEqual(value, 'value')
 
1192
        value = bzrdir_config.get_option('key2')
 
1193
        self.assertEqual(value, 'value2')
 
1194
        self.assertEqual(bzrdir_config.get_option('non-existant'), None)
 
1195
        value = bzrdir_config.get_option('non-existant', 'SECTION')
 
1196
        self.assertEqual(value, None)
 
1197
        value = bzrdir_config.get_option('non-existant', default='default')
 
1198
        self.assertEqual(value, 'default')
 
1199
        self.assertEqual(bzrdir_config.get_option('key2', 'NOSECTION'), None)
 
1200
        value = bzrdir_config.get_option('key2', 'NOSECTION',
 
1201
                                         default='default')
 
1202
        self.assertEqual(value, 'default')
 
1203
        value = bzrdir_config.get_option('key3')
 
1204
        self.assertEqual(value, 'value3-top')
 
1205
        value = bzrdir_config.get_option('key3', 'SECTION')
 
1206
        self.assertEqual(value, 'value3-section')
 
1207
 
 
1208
    def test_set_unset_default_stack_on(self):
 
1209
        my_dir = self.make_bzrdir('.')
 
1210
        bzrdir_config = config.BzrDirConfig(my_dir.transport)
 
1211
        self.assertIs(None, bzrdir_config.get_default_stack_on())
 
1212
        bzrdir_config.set_default_stack_on('Foo')
 
1213
        self.assertEqual('Foo', bzrdir_config._config.get_option(
 
1214
                         'default_stack_on'))
 
1215
        self.assertEqual('Foo', bzrdir_config.get_default_stack_on())
 
1216
        bzrdir_config.set_default_stack_on(None)
 
1217
        self.assertIs(None, bzrdir_config.get_default_stack_on())
 
1218
 
 
1219
 
 
1220
class TestAuthenticationConfigFile(tests.TestCase):
 
1221
    """Test the authentication.conf file matching"""
 
1222
 
 
1223
    def _got_user_passwd(self, expected_user, expected_password,
 
1224
                         config, *args, **kwargs):
 
1225
        credentials = config.get_credentials(*args, **kwargs)
 
1226
        if credentials is None:
 
1227
            user = None
 
1228
            password = None
 
1229
        else:
 
1230
            user = credentials['user']
 
1231
            password = credentials['password']
 
1232
        self.assertEquals(expected_user, user)
 
1233
        self.assertEquals(expected_password, password)
 
1234
 
 
1235
    def test_empty_config(self):
 
1236
        conf = config.AuthenticationConfig(_file=StringIO())
 
1237
        self.assertEquals({}, conf._get_config())
 
1238
        self._got_user_passwd(None, None, conf, 'http', 'foo.net')
 
1239
 
 
1240
    def test_missing_auth_section_header(self):
 
1241
        conf = config.AuthenticationConfig(_file=StringIO('foo = bar'))
 
1242
        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
 
1243
 
 
1244
    def test_auth_section_header_not_closed(self):
 
1245
        conf = config.AuthenticationConfig(_file=StringIO('[DEF'))
 
1246
        self.assertRaises(errors.ParseConfigError, conf._get_config)
 
1247
 
 
1248
    def test_auth_value_not_boolean(self):
 
1249
        conf = config.AuthenticationConfig(_file=StringIO(
 
1250
                """[broken]
 
1251
scheme=ftp
 
1252
user=joe
 
1253
verify_certificates=askme # Error: Not a boolean
 
1254
"""))
 
1255
        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
 
1256
 
 
1257
    def test_auth_value_not_int(self):
 
1258
        conf = config.AuthenticationConfig(_file=StringIO(
 
1259
                """[broken]
 
1260
scheme=ftp
 
1261
user=joe
 
1262
port=port # Error: Not an int
 
1263
"""))
 
1264
        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
 
1265
 
 
1266
    def test_unknown_password_encoding(self):
 
1267
        conf = config.AuthenticationConfig(_file=StringIO(
 
1268
                """[broken]
 
1269
scheme=ftp
 
1270
user=joe
 
1271
password_encoding=unknown
 
1272
"""))
 
1273
        self.assertRaises(ValueError, conf.get_password,
 
1274
                          'ftp', 'foo.net', 'joe')
 
1275
 
 
1276
    def test_credentials_for_scheme_host(self):
 
1277
        conf = config.AuthenticationConfig(_file=StringIO(
 
1278
                """# Identity on foo.net
 
1279
[ftp definition]
 
1280
scheme=ftp
 
1281
host=foo.net
 
1282
user=joe
 
1283
password=secret-pass
 
1284
"""))
 
1285
        # Basic matching
 
1286
        self._got_user_passwd('joe', 'secret-pass', conf, 'ftp', 'foo.net')
 
1287
        # different scheme
 
1288
        self._got_user_passwd(None, None, conf, 'http', 'foo.net')
 
1289
        # different host
 
1290
        self._got_user_passwd(None, None, conf, 'ftp', 'bar.net')
 
1291
 
 
1292
    def test_credentials_for_host_port(self):
 
1293
        conf = config.AuthenticationConfig(_file=StringIO(
 
1294
                """# Identity on foo.net
 
1295
[ftp definition]
 
1296
scheme=ftp
 
1297
port=10021
 
1298
host=foo.net
 
1299
user=joe
 
1300
password=secret-pass
 
1301
"""))
 
1302
        # No port
 
1303
        self._got_user_passwd('joe', 'secret-pass',
 
1304
                              conf, 'ftp', 'foo.net', port=10021)
 
1305
        # different port
 
1306
        self._got_user_passwd(None, None, conf, 'ftp', 'foo.net')
 
1307
 
 
1308
    def test_for_matching_host(self):
 
1309
        conf = config.AuthenticationConfig(_file=StringIO(
 
1310
                """# Identity on foo.net
 
1311
[sourceforge]
 
1312
scheme=bzr
 
1313
host=bzr.sf.net
 
1314
user=joe
 
1315
password=joepass
 
1316
[sourceforge domain]
 
1317
scheme=bzr
 
1318
host=.bzr.sf.net
 
1319
user=georges
 
1320
password=bendover
 
1321
"""))
 
1322
        # matching domain
 
1323
        self._got_user_passwd('georges', 'bendover',
 
1324
                              conf, 'bzr', 'foo.bzr.sf.net')
 
1325
        # phishing attempt
 
1326
        self._got_user_passwd(None, None,
 
1327
                              conf, 'bzr', 'bbzr.sf.net')
 
1328
 
 
1329
    def test_for_matching_host_None(self):
 
1330
        conf = config.AuthenticationConfig(_file=StringIO(
 
1331
                """# Identity on foo.net
 
1332
[catchup bzr]
 
1333
scheme=bzr
 
1334
user=joe
 
1335
password=joepass
 
1336
[DEFAULT]
 
1337
user=georges
 
1338
password=bendover
 
1339
"""))
 
1340
        # match no host
 
1341
        self._got_user_passwd('joe', 'joepass',
 
1342
                              conf, 'bzr', 'quux.net')
 
1343
        # no host but different scheme
 
1344
        self._got_user_passwd('georges', 'bendover',
 
1345
                              conf, 'ftp', 'quux.net')
 
1346
 
 
1347
    def test_credentials_for_path(self):
 
1348
        conf = config.AuthenticationConfig(_file=StringIO(
 
1349
                """
 
1350
[http dir1]
 
1351
scheme=http
 
1352
host=bar.org
 
1353
path=/dir1
 
1354
user=jim
 
1355
password=jimpass
 
1356
[http dir2]
 
1357
scheme=http
 
1358
host=bar.org
 
1359
path=/dir2
 
1360
user=georges
 
1361
password=bendover
 
1362
"""))
 
1363
        # no path no dice
 
1364
        self._got_user_passwd(None, None,
 
1365
                              conf, 'http', host='bar.org', path='/dir3')
 
1366
        # matching path
 
1367
        self._got_user_passwd('georges', 'bendover',
 
1368
                              conf, 'http', host='bar.org', path='/dir2')
 
1369
        # matching subdir
 
1370
        self._got_user_passwd('jim', 'jimpass',
 
1371
                              conf, 'http', host='bar.org',path='/dir1/subdir')
 
1372
 
 
1373
    def test_credentials_for_user(self):
 
1374
        conf = config.AuthenticationConfig(_file=StringIO(
 
1375
                """
 
1376
[with user]
 
1377
scheme=http
 
1378
host=bar.org
 
1379
user=jim
 
1380
password=jimpass
 
1381
"""))
 
1382
        # Get user
 
1383
        self._got_user_passwd('jim', 'jimpass',
 
1384
                              conf, 'http', 'bar.org')
 
1385
        # Get same user
 
1386
        self._got_user_passwd('jim', 'jimpass',
 
1387
                              conf, 'http', 'bar.org', user='jim')
 
1388
        # Don't get a different user if one is specified
 
1389
        self._got_user_passwd(None, None,
 
1390
                              conf, 'http', 'bar.org', user='georges')
 
1391
 
 
1392
    def test_credentials_for_user_without_password(self):
 
1393
        conf = config.AuthenticationConfig(_file=StringIO(
 
1394
                """
 
1395
[without password]
 
1396
scheme=http
 
1397
host=bar.org
 
1398
user=jim
 
1399
"""))
 
1400
        # Get user but no password
 
1401
        self._got_user_passwd('jim', None,
 
1402
                              conf, 'http', 'bar.org')
 
1403
 
 
1404
    def test_verify_certificates(self):
 
1405
        conf = config.AuthenticationConfig(_file=StringIO(
 
1406
                """
 
1407
[self-signed]
 
1408
scheme=https
 
1409
host=bar.org
 
1410
user=jim
 
1411
password=jimpass
 
1412
verify_certificates=False
 
1413
[normal]
 
1414
scheme=https
 
1415
host=foo.net
 
1416
user=georges
 
1417
password=bendover
 
1418
"""))
 
1419
        credentials = conf.get_credentials('https', 'bar.org')
 
1420
        self.assertEquals(False, credentials.get('verify_certificates'))
 
1421
        credentials = conf.get_credentials('https', 'foo.net')
 
1422
        self.assertEquals(True, credentials.get('verify_certificates'))
 
1423
 
 
1424
 
 
1425
class TestAuthenticationStorage(tests.TestCaseInTempDir):
 
1426
 
 
1427
    def test_set_credentials(self):
 
1428
        conf = config.AuthenticationConfig()
 
1429
        conf.set_credentials('name', 'host', 'user', 'scheme', 'password',
 
1430
        99, path='/foo', verify_certificates=False)
 
1431
        credentials = conf.get_credentials(host='host', scheme='scheme',
 
1432
                                           port=99, path='/foo')
 
1433
        CREDENTIALS = {'name': 'name', 'user': 'user', 'password': 'password',
 
1434
                       'verify_certificates': False,}
 
1435
        self.assertEqual(CREDENTIALS, credentials)
 
1436
        credentials_from_disk = config.AuthenticationConfig().get_credentials(
 
1437
            host='host', scheme='scheme', port=99, path='/foo')
 
1438
        self.assertEqual(CREDENTIALS, credentials_from_disk)
 
1439
 
 
1440
    def test_reset_credentials_different_name(self):
 
1441
        conf = config.AuthenticationConfig()
 
1442
        conf.set_credentials('name', 'host', 'user', 'scheme', 'password'),
 
1443
        conf.set_credentials('name2', 'host', 'user2', 'scheme', 'password'),
 
1444
        self.assertIs(None, conf._get_config().get('name'))
 
1445
        credentials = conf.get_credentials(host='host', scheme='scheme')
 
1446
        CREDENTIALS = {'name': 'name2', 'user': 'user2', 'password':
 
1447
                       'password', 'verify_certificates': True}
 
1448
        self.assertEqual(CREDENTIALS, credentials)
 
1449
 
 
1450
 
 
1451
class TestAuthenticationConfig(tests.TestCase):
 
1452
    """Test AuthenticationConfig behaviour"""
 
1453
 
 
1454
    def _check_default_prompt(self, expected_prompt_format, scheme,
 
1455
                              host=None, port=None, realm=None, path=None):
 
1456
        if host is None:
 
1457
            host = 'bar.org'
 
1458
        user, password = 'jim', 'precious'
 
1459
        expected_prompt = expected_prompt_format % {
 
1460
            'scheme': scheme, 'host': host, 'port': port,
 
1461
            'user': user, 'realm': realm}
 
1462
 
 
1463
        stdout = tests.StringIOWrapper()
 
1464
        ui.ui_factory = tests.TestUIFactory(stdin=password + '\n',
 
1465
                                            stdout=stdout)
 
1466
        # We use an empty conf so that the user is always prompted
 
1467
        conf = config.AuthenticationConfig()
 
1468
        self.assertEquals(password,
 
1469
                          conf.get_password(scheme, host, user, port=port,
 
1470
                                            realm=realm, path=path))
 
1471
        self.assertEquals(stdout.getvalue(), expected_prompt)
 
1472
 
 
1473
    def test_default_prompts(self):
 
1474
        # HTTP prompts can't be tested here, see test_http.py
 
1475
        self._check_default_prompt('FTP %(user)s@%(host)s password: ', 'ftp')
 
1476
        self._check_default_prompt('FTP %(user)s@%(host)s:%(port)d password: ',
 
1477
                                   'ftp', port=10020)
 
1478
 
 
1479
        self._check_default_prompt('SSH %(user)s@%(host)s:%(port)d password: ',
 
1480
                                   'ssh', port=12345)
 
1481
        # SMTP port handling is a bit special (it's handled if embedded in the
 
1482
        # host too)
 
1483
        # FIXME: should we: forbid that, extend it to other schemes, leave
 
1484
        # things as they are that's fine thank you ?
 
1485
        self._check_default_prompt('SMTP %(user)s@%(host)s password: ',
 
1486
                                   'smtp')
 
1487
        self._check_default_prompt('SMTP %(user)s@%(host)s password: ',
 
1488
                                   'smtp', host='bar.org:10025')
 
1489
        self._check_default_prompt(
 
1490
            'SMTP %(user)s@%(host)s:%(port)d password: ',
 
1491
            'smtp', port=10025)
 
1492
 
 
1493
    def test_ssh_password_emits_warning(self):
 
1494
        conf = config.AuthenticationConfig(_file=StringIO(
 
1495
                """
 
1496
[ssh with password]
 
1497
scheme=ssh
 
1498
host=bar.org
 
1499
user=jim
 
1500
password=jimpass
 
1501
"""))
 
1502
        entered_password = 'typed-by-hand'
 
1503
        stdout = tests.StringIOWrapper()
 
1504
        ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
 
1505
                                            stdout=stdout)
 
1506
 
 
1507
        # Since the password defined in the authentication config is ignored,
 
1508
        # the user is prompted
 
1509
        self.assertEquals(entered_password,
 
1510
                          conf.get_password('ssh', 'bar.org', user='jim'))
 
1511
        self.assertContainsRe(
 
1512
            self._get_log(keep_log_file=True),
 
1513
            'password ignored in section \[ssh with password\]')
 
1514
 
 
1515
    def test_ssh_without_password_doesnt_emit_warning(self):
 
1516
        conf = config.AuthenticationConfig(_file=StringIO(
 
1517
                """
 
1518
[ssh with password]
 
1519
scheme=ssh
 
1520
host=bar.org
 
1521
user=jim
 
1522
"""))
 
1523
        entered_password = 'typed-by-hand'
 
1524
        stdout = tests.StringIOWrapper()
 
1525
        ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
 
1526
                                            stdout=stdout)
 
1527
 
 
1528
        # Since the password defined in the authentication config is ignored,
 
1529
        # the user is prompted
 
1530
        self.assertEquals(entered_password,
 
1531
                          conf.get_password('ssh', 'bar.org', user='jim'))
 
1532
        # No warning shoud be emitted since there is no password. We are only
 
1533
        # providing "user".
 
1534
        self.assertNotContainsRe(
 
1535
            self._get_log(keep_log_file=True),
 
1536
            'password ignored in section \[ssh with password\]')
 
1537
 
 
1538
 
 
1539
class TestCredentialStoreRegistry(tests.TestCase):
 
1540
 
 
1541
    def _get_cs_registry(self):
 
1542
        return config.credential_store_registry
 
1543
 
 
1544
    def test_default_credential_store(self):
 
1545
        r = self._get_cs_registry()
 
1546
        default = r.get_credential_store(None)
 
1547
        self.assertIsInstance(default, config.PlainTextCredentialStore)
 
1548
 
 
1549
    def test_unknown_credential_store(self):
 
1550
        r = self._get_cs_registry()
 
1551
        # It's hard to imagine someone creating a credential store named
 
1552
        # 'unknown' so we use that as an never registered key.
 
1553
        self.assertRaises(KeyError, r.get_credential_store, 'unknown')
 
1554
 
 
1555
 
 
1556
class TestPlainTextCredentialStore(tests.TestCase):
 
1557
 
 
1558
    def test_decode_password(self):
 
1559
        r = config.credential_store_registry
 
1560
        plain_text = r.get_credential_store()
 
1561
        decoded = plain_text.decode_password(dict(password='secret'))
 
1562
        self.assertEquals('secret', decoded)
 
1563
 
 
1564
 
 
1565
# FIXME: Once we have a way to declare authentication to all test servers, we
 
1566
# can implement generic tests.
 
1567
# test_user_password_in_url
 
1568
# test_user_in_url_password_from_config
 
1569
# test_user_in_url_password_prompted
 
1570
# test_user_in_config
 
1571
# test_user_getpass.getuser
 
1572
# test_user_prompted ?
 
1573
class TestAuthenticationRing(tests.TestCaseWithTransport):
 
1574
    pass