Closed Bug 593654 Opened 14 years ago Closed 14 years ago

Testing bug

Categories

(mozilla.org :: Miscellaneous, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: khuey, Assigned: mitchell)

Details

Attachments

(1 file)

      No description provided.
Please use https://landfill.bugzilla.org/ for all Bugzilla-related testing.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Comment on attachment 472228 [details] [diff] [review]
Test patch

># HG changeset patch
># User Kyle Huey <khuey@kylehuey.com>
># Date 1283660599 14400
># Node ID 31935d51b8bfdd440800c39406694286cc560f33
># Parent  b84fa4b0a9eed403c7a6b16a7a3f917d60df6d70
>[mq]: credentials
>
>diff -r b84fa4b0a9ee -r 31935d51b8bf bzexport.py
>--- a/bzexport.py	Fri Sep 03 13:17:12 2010 -0400
>+++ b/bzexport.py	Sun Sep 05 00:23:19 2010 -0400
>@@ -67,7 +67,35 @@
>                      )''', re.I | re.X)
> review_re = re.compile(r'r[=?]([^ ]+)')
> 
>-def create_attachment(api_server, userid, cookie, bug,
>+class bzAuth:
>+    """
>+    A helper class to abstract away authentication details.  There are two
>+    allowable types of authentication: userid/cookie and username/password.
>+    We encapsulate it here so that functions that interact with bugzilla
>+    need only call the 'auth' method on the token to get a correct URL.
>+    """
>+    typeCookie = 1
>+    typeExplicit = 2
>+    def __init__(self, userid, cookie, username, password):
>+        assert (userid and cookie) or (username and password)
>+        assert not ((userid or cookie) and (username or password))
>+        if userid:
>+            self._type = self.typeCookie
>+            self._userid = userid
>+            self._cookie = cookie
>+        else:
>+            self._type = self.typeExplicit
>+            self._username = username
>+            self._password = password
>+
>+    def auth(self, url):
>+        if self._type == self.typeCookie:
>+            url += "?userid=%s&cookie=%s" % (self._userid, self._cookie)
>+        else:
>+            url += "?username=%s&password=%s" % (self._username, self._password)
>+        return url
>+
>+def create_attachment(api_server, token, bug,
>                       attachment_contents, description="attachment",
>                       filename="attachment"):
>     """
>@@ -75,7 +103,10 @@
> 
>     """
>     attachment = base64.b64encode(attachment_contents)
>-    url = api_server + "bug/%s/attachment?userid=%s&cookie=%s" % (bug, userid, cookie)
>+    url = api_server + "bug/%s/attachment" % (bug)
>+    url = token.auth(url)

Nit: url = api_server + "bug/%s/attachment?%s" % (bug, token.auth())

You don't actually care what the url is in the method, and can just use python here :-)

>+    print "Final url " + str(url)

Why do we want/need this debugging aid here?

>+    username = ui.config("bzexport", "bz_username", None)
>+    password = ui.config("bzexport", "bz_password", None)
>+    userid = None
>+    cookie = None

Nit [not a blocking nit]: I prefer just username and password we we are using a section name of bzexport.

Go ahead and push to ted's repo ;-)
Attachment #472228 - Flags: review+
Assignee: gerv → mitchell
Component: Hendrix → Miscellaneous
OS: Linux → All
Product: Webtools → mozilla.org
QA Contact: hendrix → miscellaneous
Hardware: x86_64 → All
Version: Trunk → other
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: