reviewboard: use privileged RBTools client when setting LDAP association; r=smacleod
draft
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.
--- 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