~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: 2008-12-19 10:37:42 UTC
  • mto: (3920.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3921.
  • Revision ID: v.ladeuil+lp@free.fr-20081219103742-3jgozfsnv5ojjyu4
Fix bug #300347 by allowing querying authentication.conf if no
user is supplied.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractAuthHandler.auth_required): Restore the no user/no auth
check.
(AbstractAuthHandler.auth_match): Don't try to get a password if
we couldn't get a user.

* bzrlib/tests/test_http.py:
(TestAuth.test_user_from_auth_conf): Reproduce bug #300347.

* NEWS: 
Point to the right bug number. Give credit to Ben for pointing the
root bug in _urllib2_wrappers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
# actual code more or less do that, tests should be written to
47
47
# ensure that.
48
48
 
49
 
import getpass
50
49
import httplib
51
50
import socket
52
51
import urllib
975
974
                # We already tried that, give up
976
975
                return None
977
976
 
 
977
            if auth.get('user', None) is None:
 
978
                # Without a known user, we can't authenticate
 
979
                return None
 
980
 
978
981
            # Housekeeping
979
982
            request.connection.cleanup_pipe()
980
983
            response = self.parent.open(request)
1044
1047
 
1045
1048
        if user is None:
1046
1049
            user = auth_conf.get_user(auth['protocol'], auth['host'],
1047
 
                                 port=auth['port'], path=auth['path'],
1048
 
                                 realm=realm)
1049
 
            if user is None:
1050
 
                # Default to local user
1051
 
                user = getpass.getuser()
1052
 
 
1053
 
        if password is None:
 
1050
                                      port=auth['port'], path=auth['path'],
 
1051
                                      realm=realm)
 
1052
        if user is not None and password is None:
1054
1053
            password = auth_conf.get_password(
1055
1054
                auth['protocol'], auth['host'], user, port=auth['port'],
1056
1055
                path=auth['path'], realm=realm,