← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad-buildd:uuencode-python3 into launchpad-buildd:master

 

Tom Wardill has proposed merging ~twom/launchpad-buildd:uuencode-python3 into launchpad-buildd:master.

Commit message:
Ensure arguments are bytes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad-buildd/+git/launchpad-buildd/+merge/389794
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad-buildd:uuencode-python3 into launchpad-buildd:master.
diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
index 7642fcb..d4a801c 100644
--- a/lpbuildd/snap.py
+++ b/lpbuildd/snap.py
@@ -271,7 +271,8 @@ class SnapBuildProxyMixin():
         url = urlparse(self.proxy_url)
         auth = "{}:{}".format(url.username, url.password)
         headers = {
-            "Authorization": "Basic {}".format(base64.b64encode(auth))
+            "Authorization": "Basic {}".format(
+                base64.b64encode(auth.encode('utf-8')))
             }
         req = Request(self.revocation_endpoint, None, headers)
         req.get_method = lambda: "DELETE"
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index b1236ae..d4780b5 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -4,6 +4,10 @@
 __metaclass__ = type
 
 import os
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 
 from fixtures import (
     EnvironmentVariable,
@@ -448,3 +452,10 @@ class TestSnapBuildManagerIteration(TestCase):
     # but it's hard to see how to test that in a way that's independent of
     # the code under test since the stock twisted.web.proxy doesn't support
     # CONNECT.
+
+    @mock.patch('lpbuildd.snap.urlopen')
+    def test_revokeProxyToken(self, urlopen_mock):
+        self.buildmanager.revocation_endpoint = "http://revoke_endpoint";
+        self.buildmanager.proxy_url = "http://username:password@proxy_url";
+        self.buildmanager.revokeProxyToken()
+        self.assertEqual(1, urlopen_mock.call_count)