diff --git a/bodhi/server/services/updates.py b/bodhi/server/services/updates.py index 826a377984..e0e857c06c 100644 --- a/bodhi/server/services/updates.py +++ b/bodhi/server/services/updates.py @@ -34,7 +34,6 @@ ContentType, UpdateRequest, UpdateStatus, - ReleaseState, Build, Package, Release, @@ -200,11 +199,6 @@ 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 update.status == UpdateStatus.stable and action == UpdateRequest.testing: request.errors.add('body', 'request', "Pushing back to testing a stable update is not allowed") diff --git a/bodhi/server/validators.py b/bodhi/server/validators.py index 060c87306c..9ca32163a0 100644 --- a/bodhi/server/validators.py +++ b/bodhi/server/validators.py @@ -418,6 +418,9 @@ def validate_acls(request, **kwargs): builds = request.validated['builds'] if 'update' in request.validated: + if request.validated['update'].release.state == ReleaseState.archived: + request.errors.add('body', 'update', 'cannot edit Update for an archived Release') + return builds = request.validated['update'].builds if not builds: diff --git a/bodhi/tests/server/services/test_updates.py b/bodhi/tests/server/services/test_updates.py index e4cac9468e..9d10165d53 100644 --- a/bodhi/tests/server/services/test_updates.py +++ b/bodhi/tests/server/services/test_updates.py @@ -1064,7 +1064,7 @@ def test_set_request_archived_release(self, *args): assert res.json_body['status'] == 'error' assert res.json_body['errors'][0]['description'] == ( - "Can't change request for an archived release" + "cannot edit Update for an archived Release" ) @mock.patch(**mock_valid_requirements) @@ -4096,7 +4096,7 @@ def test_request_to_archived_release(self, *args): assert resp.json['status'] == 'error' assert resp.json['errors'][0]['description'] == ( - "Can't change request for an archived release" + "cannot edit Update for an archived Release" ) @mock.patch(**mock_failed_taskotron_results) diff --git a/bodhi/tests/server/test_validators.py b/bodhi/tests/server/test_validators.py index d6c0df9b2f..b04f7e22ae 100644 --- a/bodhi/tests/server/test_validators.py +++ b/bodhi/tests/server/test_validators.py @@ -291,6 +291,20 @@ def test_validate_acls_dummy_committer(self): validators.validate_acls(mock_request) assert not len(mock_request.errors) + @mock.patch.dict('bodhi.server.validators.config', {'acl_system': 'dummy'}) + def test_validate_acls_archived_release(self): + """ Test validate_acls when trying to edit an Update for an archived Release. + """ + mock_request = self.get_mock_request() + mock_request.validated['update'].release.state = models.ReleaseState.archived + validators.validate_acls(mock_request) + error = [{ + 'location': 'body', + 'name': 'update', + 'description': 'cannot edit Update for an archived Release' + }] + assert mock_request.errors == error + @mock.patch.dict('bodhi.server.validators.config', {'acl_system': 'nonexistent'}) def test_validate_acls_invalid_acl_system(self): """ Test validate_acls when the acl system is invalid. diff --git a/news/PR4236.bug b/news/PR4236.bug new file mode 100644 index 0000000000..f88043bb4a --- /dev/null +++ b/news/PR4236.bug @@ -0,0 +1 @@ +Updates for archived releases cannot be edited anymore