~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ssh.py

  • Committer: Vincent Ladeuil
  • Date: 2007-10-20 16:49:14 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-20071020164914-zr8s4gimxnbmvecd
Since all schemes query AuthenticationConfig then prompt user, make that
a method.

* bzrlib/transport/ssh.py:
(_paramiko_auth): Simplified.

* bzrlib/transport/http/_urllib2_wrappers.py:
Add FIXME about https never mentioned in prompts.
(AbstractAuthHandler.get_password): Simplified.

* bzrlib/transport/ftp.py:
(FtpTransport._create_connection): Simplified.

* bzrlib/tests/test_smtp_connection.py:
(TestSMTPConnection.test_smtp_password_from_user): Moved from
TestSMTPConnectionWithUI and given a proper stdout for ui_factory.
(TestSMTPConnectionWithUI): Deleted.

* bzrlib/tests/test_http.py:
(TestAuth.setUp): Mother class already install a SilentUIFactory
and restore the proper one, so there is no need to do that
ourselves.
(TestAuth.restoreUIFactory): Deleted.
(TestAuth.test_prompt_for_password,
TestAuth.test_no_prompt_for_password_when_using_auth_config):
Provides a suitable stdout to TestUIFactory.


* bzrlib/tests/test_ftp_transport.py:
(TestFTPServerUI.setUp, TestFTPServerUI.restoreUIFactory):
Deleted. Mother class already install a SilentUIFactory and
restore the proper one, so there is no need to do that ourselves.
(TestFTPServerUI.test_prompt_for_password,
TestFTPServerUI.test_no_prompt_for_password_when_using_auth_config):
Provides a suitable stdout to TestUIFactory.

* bzrlib/smtp_connection.py:
(SMTPConnection._authenticate): Simplified.

* bzrlib/config.py:
(AuthenticationConfig.get_password): Encapsulate pattern common to
all schemes actually used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
488
488
 
489
489
    # give up and ask for a password
490
490
    auth = config.AuthenticationConfig()
491
 
    config_credentials = auth.get_credentials('ssh', host, port=port,
492
 
                                              user=username)
493
 
    if config_credentials is not None:
494
 
        password = config_credentials['password']
495
 
    else:
496
 
        password = bzrlib.ui.ui_factory.get_password(
497
 
            prompt='SSH %(user)s@%(host)s password',
498
 
            user=username, host=host)
 
491
    password = auth.get_password('ssh', host, username, port=port)
499
492
    try:
500
493
        paramiko_transport.auth_password(username, password)
501
494
    except paramiko.SSHException, e: