~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.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:
1017
1017
                host = netloc
1018
1018
                port = None
1019
1019
            auth = config.AuthenticationConfig()
1020
 
            config_credentials = auth.get_credentials(
1021
 
                scheme, host, port, user=user, path=path)
1022
 
            if config_credentials is not None:
1023
 
                password = config_credentials['password']
1024
 
            else:
1025
 
                # Prompt user only if we can't find a password
1026
 
                if realm:
1027
 
                    realm_prompt = " Realm: '%s'" % realm
1028
 
                else:
1029
 
                    realm_prompt = ''
1030
 
                password = ui.ui_factory.get_password(
1031
 
                    prompt=self.password_prompt, user=user, host=netloc,
1032
 
                    realm=realm_prompt)
 
1020
            password = auth.get_password(
 
1021
                scheme, host, user, port=port, path=path, realm=realm,
 
1022
                prompt=self.password_prompt)
1033
1023
            if password is not None:
1034
1024
                self.add_password(realm, authuri, user, password)
1035
1025
        return password
1203
1193
    the auth request attribute.
1204
1194
    """
1205
1195
 
 
1196
    # FIXME: should mention http/https as part of the prompt
1206
1197
    password_prompt = 'HTTP %(user)s@%(host)s%(realm)s password'
1207
1198
    auth_required_header = 'www-authenticate'
1208
1199
    auth_header = 'Authorization'
1227
1218
    the proxy_auth request attribute..
1228
1219
    """
1229
1220
 
 
1221
    # FIXME: should mention http/https as part of the prompt
1230
1222
    password_prompt = 'Proxy %(user)s@%(host)s%(realm)s password'
1231
1223
    auth_required_header = 'proxy-authenticate'
1232
1224
    # FIXME: the correct capitalization is Proxy-Authorization,