Skip to content

Commit

Permalink
Fix bugs in oonifindings related to Explorer integration (#891)
Browse files Browse the repository at this point in the history
* Make publish behave like current backend

* Add checks for publish behaviour of explorer

* Setting of ID in creation is optional
  • Loading branch information
hellais authored Oct 11, 2024
1 parent 13806de commit e881725
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ooniapi/services/oonifindings/src/oonifindings/routers/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def utcnow_seconds():


class OONIFindingId(BaseModel):
incident_id: str = Field(alias="id")
incident_id: Optional[str] = Field(alias="id", default=None)


class OONIFindingWithMail(OONIFindingId):
Expand Down Expand Up @@ -501,7 +501,7 @@ def delete_oonifinding(
)
def update_oonifinding_publish_status(
action: str,
publish_request: OONIFindingCreateUpdate,
publish_request: OONIFindingId,
response: Response,
db=Depends(get_postgresql_session),
):
Expand Down
9 changes: 4 additions & 5 deletions ooniapi/services/oonifindings/tests/test_oonifindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
SAMPLE_EMAIL = "[email protected]"

SAMPLE_OONIFINDING = {
"id": "",
"title": "sample oonifinding",
"short_description": "sample oonifinding description",
"reported_by": "sample user",
Expand Down Expand Up @@ -148,12 +147,12 @@ def test_oonifinding_publish(client, client_with_hashed_email):
r = client_with_user_role.post("api/v1/incidents/publish", json=incident_payload)
assert r.status_code == 401, "only admins can publish incidents"

incident_payload["id"] = "sample id"
r = client_with_admin_role.post("api/v1/incidents/publish", json=incident_payload)
r = client_with_admin_role.post("api/v1/incidents/publish", json={"id": "12341512"})
assert r.status_code == 404, "valid incident id should be passed"

incident_payload["id"] = incident_id
r = client_with_admin_role.post("api/v1/incidents/publish", json=incident_payload)
r = client_with_admin_role.post(
"api/v1/incidents/publish", json={"id": incident_id}
)
assert r.status_code == 200
assert r.json()["r"] == 1
assert r.json()["id"] == incident_id
Expand Down

0 comments on commit e881725

Please sign in to comment.