Rev 6560: Remove obsolete (and not used anymore) code and its associated tests (covered by other tests in test_http.py). in file:///home/vila/src/bzr/cleanup/extract-auth-obsolete/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Sep 17 06:58:15 UTC 2012


At file:///home/vila/src/bzr/cleanup/extract-auth-obsolete/

------------------------------------------------------------
revno: 6560
revision-id: v.ladeuil+lp at free.fr-20120917065815-aklenqt1f85hp17b
parent: pqm at pqm.ubuntu.com-20120914172235-tvv720qmlchw8270
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: extract-auth-obsolete
timestamp: Mon 2012-09-17 08:58:15 +0200
message:
  Remove obsolete (and not used anymore) code and its associated tests (covered by other tests in test_http.py).
-------------- next part --------------
=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2012-08-04 14:27:47 +0000
+++ b/bzrlib/tests/test_http.py	2012-09-17 06:58:15 +0000
@@ -384,24 +384,6 @@
     _transport = property(_get_pycurl_maybe)
 
 
-class TestHttpUrls(tests.TestCase):
-
-    # TODO: This should be moved to authorization tests once they
-    # are written.
-
-    def test_url_parsing(self):
-        f = FakeManager()
-        url = http.extract_auth('http://example.com', f)
-        self.assertEqual('http://example.com', url)
-        self.assertEqual(0, len(f.credentials))
-        url = http.extract_auth(
-            'http://user:pass@example.com/bzr/bzr.dev', f)
-        self.assertEqual('http://example.com/bzr/bzr.dev', url)
-        self.assertEqual(1, len(f.credentials))
-        self.assertEqual([None, 'example.com', 'user', 'pass'],
-                         f.credentials[0])
-
-
 class TestHttpTransportUrls(tests.TestCase):
     """Test the http urls."""
 

=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py	2012-02-14 14:55:25 +0000
+++ b/bzrlib/transport/http/__init__.py	2012-09-17 06:58:15 +0000
@@ -40,41 +40,6 @@
     ConnectedTransport,
     )
 
-# TODO: This is not used anymore by HttpTransport_urllib
-# (extracting the auth info and prompting the user for a password
-# have been split), only the tests still use it. It should be
-# deleted and the tests rewritten ASAP to stay in sync.
-def extract_auth(url, password_manager):
-    """Extract auth parameters from am HTTP/HTTPS url and add them to the given
-    password manager.  Return the url, minus those auth parameters (which
-    confuse urllib2).
-    """
-    if not re.match(r'^(https?)(\+\w+)?://', url):
-        raise ValueError(
-            'invalid absolute url %r' % (url,))
-    scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
-
-    if '@' in netloc:
-        auth, netloc = netloc.split('@', 1)
-        if ':' in auth:
-            username, password = auth.split(':', 1)
-        else:
-            username, password = auth, None
-        if ':' in netloc:
-            host = netloc.split(':', 1)[0]
-        else:
-            host = netloc
-        username = urlutils.unquote(username)
-        if password is not None:
-            password = urlutils.unquote(password)
-        else:
-            password = ui.ui_factory.get_password(
-                prompt=u'HTTP %(user)s@%(host)s password',
-                user=username, host=host)
-        password_manager.add_password(None, host, username, password)
-    url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))
-    return url
-
 
 class HttpTransportBase(ConnectedTransport):
     """Base class for http implementations.



More information about the bazaar-commits mailing list