/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

1st cut merge of bzr.dev r3907

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 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
951
951
        self.assertIs(self.my_config.get_user_option('foo'), None)
952
952
        self.my_config.set_user_option('foo', 'bar')
953
953
        self.assertEqual(
954
 
            self.my_config.branch.control_files.files['branch.conf'],
955
 
            'foo = bar\n')
 
954
            self.my_config.branch.control_files.files['branch.conf'].strip(),
 
955
            'foo = bar')
956
956
        self.assertEqual(self.my_config.get_user_option('foo'), 'bar')
957
957
        self.my_config.set_user_option('foo', 'baz',
958
958
                                       store=config.STORE_LOCATION)
1412
1412
        self.assertEquals(True, credentials.get('verify_certificates'))
1413
1413
 
1414
1414
 
 
1415
class TestAuthenticationStorage(tests.TestCaseInTempDir):
 
1416
 
 
1417
    def test_set_credentials(self):
 
1418
        conf = config.AuthenticationConfig()
 
1419
        conf.set_credentials('name', 'host', 'user', 'scheme', 'password',
 
1420
        99, path='/foo', verify_certificates=False)
 
1421
        credentials = conf.get_credentials(host='host', scheme='scheme',
 
1422
                                           port=99, path='/foo')
 
1423
        CREDENTIALS = {'name': 'name', 'user': 'user', 'password': 'password',
 
1424
                       'verify_certificates': False,}
 
1425
        self.assertEqual(CREDENTIALS, credentials)
 
1426
        credentials_from_disk = config.AuthenticationConfig().get_credentials(
 
1427
            host='host', scheme='scheme', port=99, path='/foo')
 
1428
        self.assertEqual(CREDENTIALS, credentials_from_disk)
 
1429
 
 
1430
    def test_reset_credentials_different_name(self):
 
1431
        conf = config.AuthenticationConfig()
 
1432
        conf.set_credentials('name', 'host', 'user', 'scheme', 'password'),
 
1433
        conf.set_credentials('name2', 'host', 'user2', 'scheme', 'password'),
 
1434
        self.assertIs(None, conf._get_config().get('name'))
 
1435
        credentials = conf.get_credentials(host='host', scheme='scheme')
 
1436
        CREDENTIALS = {'name': 'name2', 'user': 'user2', 'password':
 
1437
                       'password', 'verify_certificates': True}
 
1438
        self.assertEqual(CREDENTIALS, credentials)
 
1439
 
 
1440
 
1415
1441
class TestAuthenticationConfig(tests.TestCase):
1416
1442
    """Test AuthenticationConfig behaviour"""
1417
1443