~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-22 15:18:24 UTC
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071022151824-eol757lk393ofc38
AuthenticationConfig can be queried for logins too (first step).

* bzrlib/transport/ssh.py:
(_paramiko_auth): Try to get a user from AuthenticationConfig.

* bzrlib/smtp_connection.py:
(SMTPConnection._authenticate): Try to get a user from
AuthenticationConfig.

* bzrlib/transport/ftp.py:
(FtpTransport._create_connection): Try to get a user from
AuthenticationConfig. Credentials are now (user, password) instead
of just password.

* bzrlib/tests/test_ftp_transport.py:
(TestFTPServerUI._add_authorized_user): Cleanup by refactoring.

* bzrlib/config.py:
(AuthenticationConfig.get_user): New method to get logins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1121
1121
class TestAuthenticationConfigFile(tests.TestCase):
1122
1122
    """Test the authentication.conf file matching"""
1123
1123
 
1124
 
    # XXX: test definitions without users.
1125
 
 
1126
1124
    def _got_user_passwd(self, expected_user, expected_password,
1127
1125
                         config, *args, **kwargs):
1128
1126
        credentials = config.get_credentials(*args, **kwargs)
1143
1141
    def test_broken_config(self):
1144
1142
        conf = config.AuthenticationConfig(_file=StringIO('[DEF'))
1145
1143
        self.assertRaises(errors.ParseConfigError, conf._get_config)
 
1144
 
1146
1145
        conf = config.AuthenticationConfig(_file=StringIO(
1147
1146
                """[broken]
1148
1147
scheme=ftp
1149
1148
user=joe
1150
 
verify_certificates=askme
 
1149
verify_certificates=askme # Error: Not a boolean
1151
1150
"""))
1152
1151
        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
1153
1152
 
1345
1344
 
1346
1345
# FIXME: Once we have a way to declare authentication to all test servers, we
1347
1346
# can implement generic tests.
 
1347
# test_user_password_in_url
 
1348
# test_user_in_url_password_from_config
 
1349
# test_user_in_url_password_prompted
 
1350
# test_user_in_config
 
1351
# test_user_getpass.getuser
 
1352
# test_user_prompted ?
1348
1353
class TestAuthenticationRing(tests.TestCaseWithTransport):
1349
1354
    pass