~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-08 16:12:07 UTC
  • mfrom: (3926.1.1 bzr.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090108161207-d95v7ouel5ibahh0
(vila) Authentication.conf supports credential stores. '.netrc' is
        supported with a new plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1263
1263
"""))
1264
1264
        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
1265
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
 
1266
1276
    def test_credentials_for_scheme_host(self):
1267
1277
        conf = config.AuthenticationConfig(_file=StringIO(
1268
1278
                """# Identity on foo.net
1526
1536
            'password ignored in section \[ssh with password\]')
1527
1537
 
1528
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
 
1529
1565
# FIXME: Once we have a way to declare authentication to all test servers, we
1530
1566
# can implement generic tests.
1531
1567
# test_user_password_in_url