Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #36 from mrrrgn/authfix
Browse files Browse the repository at this point in the history
Bug 1164878 - Allow users without an authenticated_email field to clo…
  • Loading branch information
usize committed May 28, 2015
2 parents dd50f1e + 257928f commit e459fe2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions relengapi/blueprints/clobberer/__init__.py
Expand Up @@ -68,9 +68,16 @@ def _add_clobber(session, branch, builddir, slave=None):
in is returned; but is only committed if the commit option is True.
"""
if re.search('^' + BUILDDIR_REL_PREFIX + '.*', builddir) is None:
who = 'anonymous'
if current_user.anonymous is False:
try:
who = current_user.authenticated_email
except AttributeError:
if current_user.anonymous:
who = 'anonymous'
else:
# TokenUser doesn't show up as anonymous; but also has no
# authenticated_email
who = 'automation'

clobber_time = ClobberTime.as_unique(
session,
branch=branch,
Expand Down
12 changes: 12 additions & 0 deletions relengapi/blueprints/clobberer/test_api.py
Expand Up @@ -293,3 +293,15 @@ def test_release_builder_hiding(client):
eq_(rv.status_code, 200)
clobbertimes = json.loads(rv.data)["result"]
eq_(clobbertimes.get(buildername), None)


@test_context
def test_clobber_request_no_identity(client):
del auth_user.authenticated_email
session = test_context._app.db.session(DB_DECLARATIVE_BASE)
rv = client.post_json('/clobberer/clobber', data=[_clobber_args, _clobber_args_with_slave])
eq_(rv.status_code, 200)
clobber = session.query(ClobberTime.who)
# the last clobber should have a who value of automation, since we deleted
# authenticated_email
eq_(clobber.order_by('id').all()[0], ('automation',))

0 comments on commit e459fe2

Please sign in to comment.