reviewboard: use privileged RBTools client when setting LDAP association; r=smacleod draft
authorGregory Szorc <gps@mozilla.com>
Thu, 07 Jan 2016 13:38:43 -0800
changeset 6705 c157d16ca73641125cfc07d011fc9bc50edbad75
parent 6704 7c551b82a49953f7c2f63e6e121758bf0c52c4ae
child 6706 941aecdaad4b8e570f03c896bd45a61f524c6e68
push id513
push usergszorc@mozilla.com
push dateWed, 13 Jan 2016 02:13:15 +0000
reviewerssmacleod
reviewboard: use privileged RBTools client when setting LDAP association; r=smacleod 7d30e50718a9 accidentally dropped the "as rbc" from this code, meaning that we use the existing rbc variable/connection to adjust LDAP association. This would almost certainly fail. And, since this entire block is inside an "except APIError," we'd swallow the obvious failure. Derp. There are surprisingly no test failures as a result of this change. Wat. test-ldap-association.t explicitly tests the "LDAP account becomes associate during ssh push" case. How this was working before I don't know.
pylib/reviewboardmods/reviewboardmods/pushhooks.py
--- a/pylib/reviewboardmods/reviewboardmods/pushhooks.py
+++ b/pylib/reviewboardmods/reviewboardmods/pushhooks.py
@@ -517,17 +517,17 @@ def associate_ldap_username(url, ldap_us
                 return False
 
             user = session.get_user()
             username = user.username
 
         # Now that we have proven ownership over the user, take the provided
         # ldap_username and associate it with the account.
         with ReviewBoardClient(url, username=privileged_username,
-                               password=privileged_password):
+                               password=privileged_password) as rbc:
             root = rbc.get_root()
             ext = root.get_extension(
                 extension_name='mozreview.extension.MozReviewExtension')
             ldap = ext.get_ldap_associations().get_item(username)
             ldap.update(ldap_username=ldap_username)
 
     except APIError:
         return False