1
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
# Authors: Robert Collins <robert.collins@canonical.com>
4
4
# This program is free software; you can redistribute it and/or modify
1412
1412
self.assertEquals(True, credentials.get('verify_certificates'))
1415
class TestAuthenticationStorage(tests.TestCaseInTempDir):
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)
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)
1441
1415
class TestAuthenticationConfig(tests.TestCase):
1442
1416
"""Test AuthenticationConfig behaviour"""