# HG changeset patch # User Matt Harbison # Date 2019-02-05 22:02:40 # Node ID 349c8879becd13143db74894490299b56524d1e1 # Parent 46432c04f01071b7cdb762eec3e506cb3e7837fd py3: ensure the HTTP password manager returns strings, not bytes The digest handler calls into the password manager on its own, and it apparently expects strings. Perhaps the Basic authentication handler didn't hit this because of its manual password fetch and format in retry_http_basic_auth(). The `pycompat.bytesurl()` on the user and password just above the first url.py diff seems unnecessary, because the password proxy in ui is converting to bytes IIUC. diff --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -65,7 +65,7 @@ class passwordmgr(object): user, passwd = pycompat.bytesurl(user), pycompat.bytesurl(passwd) if user and passwd: self._writedebug(user, passwd) - return (user, passwd) + return (pycompat.strurl(user), pycompat.strurl(passwd)) if not user or not passwd: res = httpconnectionmod.readauthforuri(self.ui, authuri, user) @@ -93,7 +93,7 @@ class passwordmgr(object): self.passwddb.add_password(realm, authuri, user, passwd) self._writedebug(user, passwd) - return (user, passwd) + return (pycompat.strurl(user), pycompat.strurl(passwd)) def _writedebug(self, user, passwd): msg = _('http auth: user %s, password %s\n') diff --git a/tests/test-http.t b/tests/test-http.t --- a/tests/test-http.t +++ b/tests/test-http.t @@ -225,9 +225,8 @@ test http authentication > return opener > EOF - $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py || true - abort: HTTP Error 403: bad user (py3 !) - 5fed3813f7f5 (no-py3 !) + $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py + 5fed3813f7f5 #if no-reposimplestore $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1 @@ -383,14 +382,13 @@ test http authentication "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull "GET /?cmd=capabilities HTTP/1.1" 401 - x-hgtest-authtype:Digest - "GET /?cmd=capabilities HTTP/1.1" 403 - x-hgtest-authtype:Digest (py3 !) - "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) - "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !) + "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest + "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest + "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest + "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest + "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest + "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest + "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !) "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !) "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !) @@ -461,7 +459,6 @@ check error log $ cat error.log $ cat errors2.log - $LOCALIP - - [$ERRDATE$] HG error: No hash found for user/realm "b'user'/mercurial" (glob) (py3 !) check abort error reporting while pulling/cloning