~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smtp_connection.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:
92
92
        if self._smtp_username is None:
93
93
            return
94
94
 
95
 
        password = self._smtp_password
96
 
        if password is None:
 
95
        if self._smtp_password is None:
97
96
            auth = config.AuthenticationConfig()
98
 
            config_credentials = auth.get_credentials('smtp', self._smtp_server,
99
 
                                                      user=self._smtp_username)
100
 
            if config_credentials is not None:
101
 
                password = config_credentials['password']
102
 
            else:
103
 
                password = ui.ui_factory.get_password(
104
 
                    'Please enter the SMTP password: %(user)s@%(host)s',
105
 
                    user=self._smtp_username,
106
 
                    host=self._smtp_server)
107
 
 
108
 
        self._smtp_password = password
 
97
            self._smtp_password = auth.get_password(
 
98
                'smtp', self._smtp_server, self._smtp_username)
109
99
 
110
100
        self._connection.login(self._smtp_username, self._smtp_password)
111
101