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

Bug 1164878 - Allow users without an authenticated_email field to clo… #36

Merged
1 commit merged into from May 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions relengapi/blueprints/clobberer/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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',))