Skip to content

Commit 2a1fcaa

Browse files
committed
send enforcement action for override decisions
1 parent df62af9 commit 2a1fcaa

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

src/olympia/abuse/cinder.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,17 @@ def appeal(self, *, decision_cinder_id, appeal_text, appealer):
169169
else:
170170
raise HTTPError(response.content)
171171

172-
def _send_create_decision(
173-
self, url, data, action, reasoning, policy_uuids, *, success_code=201
174-
):
172+
def _send_create_decision(self, url, data, action, reasoning, policy_uuids):
175173
data = {
176174
**data,
177175
'reasoning': self.get_str(reasoning),
178176
'policy_uuids': policy_uuids,
179-
**(
180-
{
181-
'enforcement_actions_slugs': [action],
182-
'enforcement_actions_update_strategy': 'set',
183-
}
184-
if action is not None
185-
else {}
186-
),
177+
'enforcement_actions_slugs': [action],
178+
'enforcement_actions_update_strategy': 'set',
187179
}
188180
response = requests.post(url, json=data, headers=self.get_cinder_http_headers())
189-
if response.status_code == success_code:
190-
return response.json().get('uuid')
191-
else:
192-
raise HTTPError(response.content)
181+
response.raise_for_status()
182+
return response.json().get('uuid')
193183

194184
def create_decision(self, *, action, reasoning, policy_uuids):
195185
if self.type is None:
@@ -208,12 +198,7 @@ def create_job_decision(self, *, action, reasoning, policy_uuids, job_id):
208198

209199
def create_override_decision(self, *, action, reasoning, policy_uuids, decision_id):
210200
url = f'{settings.CINDER_SERVER_URL}decisions/{decision_id}/override/'
211-
# TODO: send action too once
212-
# https://lindie.app/share/6a21d831b39351d7c6fe898f6d22619af62dde98/PLAT-1834
213-
# implements the same parameters for overrides
214-
return self._send_create_decision(
215-
url, {}, None, reasoning, policy_uuids, success_code=200
216-
)
201+
return self._send_create_decision(url, {}, action, reasoning, policy_uuids)
217202

218203
def close_job(self, *, job_id):
219204
url = f'{settings.CINDER_SERVER_URL}jobs/{job_id}/cancel'

src/olympia/abuse/tests/test_cinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,8 +1428,8 @@ def test_create_override_decision(self):
14281428
)
14291429
request = responses.calls[0].request
14301430
request_body = json.loads(request.body)
1431-
assert b'enforcement_actions_slugs' not in request.body
1432-
assert b'enforcement_actions_update_strategy' not in request.body
1431+
assert request_body['enforcement_actions_slugs'] == ['amo-reject-version-addon']
1432+
assert request_body['enforcement_actions_update_strategy'] == 'set'
14331433
assert request_body['policy_uuids'] == ['12345678']
14341434
assert request_body['reasoning'] == 'some review text'
14351435
assert 'entity' not in request_body

0 commit comments

Comments
 (0)