Skip to content

Commit

Permalink
Cinder sends a 200 for a successfull decision override, not 201 (#23091)
Browse files Browse the repository at this point in the history
  • Loading branch information
eviljeff committed Feb 20, 2025
1 parent 8dcb561 commit 4fdae32
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/olympia/abuse/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ def appeal(self, *, decision_cinder_id, appeal_text, appealer):
else:
raise ConnectionError(response.content)

def _send_create_decision(self, url, data, action, reasoning, policy_uuids):
def _send_create_decision(
self, url, data, action, reasoning, policy_uuids, *, success_code=201
):
data = {
**data,
'reasoning': self.get_str(reasoning),
Expand All @@ -183,7 +185,7 @@ def _send_create_decision(self, url, data, action, reasoning, policy_uuids):
),
}
response = requests.post(url, json=data, headers=self.get_cinder_http_headers())
if response.status_code == 201:
if response.status_code == success_code:
return response.json().get('uuid')
else:
raise ConnectionError(response.content)
Expand All @@ -208,7 +210,9 @@ def create_override_decision(self, *, action, reasoning, policy_uuids, decision_
# TODO: send action too once
# https://lindie.app/share/6a21d831b39351d7c6fe898f6d22619af62dde98/PLAT-1834
# implements the same parameters for overrides
return self._send_create_decision(url, {}, None, reasoning, policy_uuids)
return self._send_create_decision(
url, {}, None, reasoning, policy_uuids, success_code=200
)

def close_job(self, *, job_id):
url = f'{settings.CINDER_SERVER_URL}jobs/{job_id}/cancel'
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/abuse/tests/test_cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ def test_create_override_decision(self):
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/{overridden_decision_id}/override/',
json={'uuid': cinder_id},
status=201,
status=200,
)
responses.add(
responses.POST,
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,7 @@ def _test_report_to_cinder(
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/{overridden_id}/override/',
json={'uuid': uuid.uuid4().hex},
status=201,
status=200,
)
decision.policies.add(
CinderPolicy.objects.create(name='policy', uuid='12345678')
Expand Down
6 changes: 3 additions & 3 deletions src/olympia/reviewers/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ def test_reject_versions_with_resolved_cinder_job(self):
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/13579/override/',
json={'uuid': uuid.uuid4().hex},
status=201,
status=200,
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
Expand Down Expand Up @@ -1509,7 +1509,7 @@ def test_reject_versions_with_resolved_cinder_job_no_third_party(self):
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/13579/override/',
json={'uuid': uuid.uuid4().hex},
status=201,
status=200,
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
Expand Down Expand Up @@ -1554,7 +1554,7 @@ def test_reject_versions_with_multiple_delayed_rejections(self):
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/13579/override/',
json={'uuid': uuid.uuid4().hex},
status=201,
status=200,
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/reviewers/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7556,7 +7556,7 @@ def test_approve_addon_instead(self):
responses.POST,
f'{settings.CINDER_SERVER_URL}decisions/{self.decision.cinder_id}/override/',
json={'uuid': '5678'},
status=201,
status=200,
)

response = self.client.post(self.url, {'choice': 'no'})
Expand Down

0 comments on commit 4fdae32

Please sign in to comment.