~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
"""Tests for finding and reading the bzr config file[s]."""
19
19
# import system imports here
150
150
        self._transport = self.control_files = \
151
151
            FakeControlFilesAndTransport(user_id=user_id)
152
152
 
 
153
    def _get_config(self):
 
154
        return config.TransportConfig(self._transport, 'branch.conf')
 
155
 
153
156
    def lock_write(self):
154
157
        pass
155
158
 
425
428
        locations = config.locations_config_filename()
426
429
        config.ensure_config_dir_exists()
427
430
        local_url = urlutils.local_path_to_url('branch')
428
 
        open(locations, 'wb').write('[%s]\nnickname = foobar' 
 
431
        open(locations, 'wb').write('[%s]\nnickname = foobar'
429
432
                                    % (local_url,))
430
433
        self.assertEqual('foobar', branch.nick)
431
434
 
436
439
 
437
440
        locations = config.locations_config_filename()
438
441
        config.ensure_config_dir_exists()
439
 
        open(locations, 'wb').write('[%s/branch]\nnickname = barry' 
 
442
        open(locations, 'wb').write('[%s/branch]\nnickname = barry'
440
443
                                    % (osutils.getcwd().encode('utf8'),))
441
444
        self.assertEqual('barry', branch.nick)
442
445
 
1427
1430
    def test_set_credentials(self):
1428
1431
        conf = config.AuthenticationConfig()
1429
1432
        conf.set_credentials('name', 'host', 'user', 'scheme', 'password',
1430
 
        99, path='/foo', verify_certificates=False)
 
1433
        99, path='/foo', verify_certificates=False, realm='realm')
1431
1434
        credentials = conf.get_credentials(host='host', scheme='scheme',
1432
 
                                           port=99, path='/foo')
 
1435
                                           port=99, path='/foo',
 
1436
                                           realm='realm')
1433
1437
        CREDENTIALS = {'name': 'name', 'user': 'user', 'password': 'password',
1434
 
                       'verify_certificates': False,}
 
1438
                       'verify_certificates': False, 'scheme': 'scheme', 
 
1439
                       'host': 'host', 'port': 99, 'path': '/foo', 
 
1440
                       'realm': 'realm'}
1435
1441
        self.assertEqual(CREDENTIALS, credentials)
1436
1442
        credentials_from_disk = config.AuthenticationConfig().get_credentials(
1437
 
            host='host', scheme='scheme', port=99, path='/foo')
 
1443
            host='host', scheme='scheme', port=99, path='/foo', realm='realm')
1438
1444
        self.assertEqual(CREDENTIALS, credentials_from_disk)
1439
1445
 
1440
1446
    def test_reset_credentials_different_name(self):
1444
1450
        self.assertIs(None, conf._get_config().get('name'))
1445
1451
        credentials = conf.get_credentials(host='host', scheme='scheme')
1446
1452
        CREDENTIALS = {'name': 'name2', 'user': 'user2', 'password':
1447
 
                       'password', 'verify_certificates': True}
 
1453
                       'password', 'verify_certificates': True, 
 
1454
                       'scheme': 'scheme', 'host': 'host', 'port': None, 
 
1455
                       'path': None, 'realm': None}
1448
1456
        self.assertEqual(CREDENTIALS, credentials)
1449
1457
 
1450
1458