Skip to content
Permalink
Browse files

updates: Disable the ability to set a request for an archived release…

… (issue #725)
  • Loading branch information...
lmacken committed Dec 4, 2015
1 parent 8756c14 commit 6c4023390588fc9ebfe480bfd37c5d36314b5887
Showing with 29 additions and 1 deletion.
  1. +6 −1 bodhi/services/updates.py
  2. +23 −0 bodhi/tests/functional/test_updates.py
@@ -21,7 +21,7 @@

from bodhi import log
from bodhi.exceptions import BodhiException, LockedUpdateException
from bodhi.models import Update, Build, Bug, CVE, Package, UpdateRequest
from bodhi.models import Update, Build, Bug, CVE, Package, UpdateRequest, ReleaseState
import bodhi.schemas
import bodhi.security
import bodhi.services.errors
@@ -116,6 +116,11 @@ def set_request(request):
"Can't change request on a locked update")
return

if update.release.state is ReleaseState.archived:
request.errors.add('body', 'request',
"Can't change request for an archived release")
return

if action is UpdateRequest.stable:
settings = request.registry.settings
result, reason = update.check_requirements(request.db, settings)
@@ -37,6 +37,7 @@
UpdateStatus,
UpdateRequest,
Release,
ReleaseState,
BuildrootOverride
)

@@ -1859,6 +1860,28 @@ def test_stable_request_after_testing(self, publish, *args):
publish.assert_called_with(
topic='update.request.stable', msg=mock.ANY)

@mock.patch(**mock_taskotron_results)
@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.notifications.publish')
def test_request_to_archived_release(self, publish, *args):
"""Test submitting a stable request to an update for an archived/EOL release.
https://github.com/fedora-infra/bodhi/issues/725
"""
args = self.get_update('bodhi-2.0.0-3.fc17')
resp = self.app.post_json('/updates/', args)
up = self.db.query(Update).filter_by(title=resp.json['title']).one()
up.status = UpdateStatus.pending
up.request = None
up.release.state = ReleaseState.archived
self.db.flush()
resp = self.app.post_json(
'/updates/%s/request' % args['builds'],
{'request': 'testing', 'csrf_token': self.get_csrf_token()},
status=400)
eq_(resp.json['status'], 'error')
eq_(resp.json['errors'][0]['description'],
"Can't change request for an archived release")

@mock.patch(**mock_failed_taskotron_results)
@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.notifications.publish')

0 comments on commit 6c40233

Please sign in to comment.
You can’t perform that action at this time.