Skip to content

Commit

Permalink
Implement exchange delete API
Browse files Browse the repository at this point in the history
  • Loading branch information
aokolish committed Jan 31, 2025
1 parent 35c206e commit df92ef5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,20 +431,22 @@ def exchange_update(exchange_name: str):
def exchange_delete(exchange_name: str):
"""
Delete exchange configuration
Inputs:
* Configuration name
* (optional) whether to also delete the associated bank (defaults to true)
* Exchange name
Returns:
{
"message": "success",
"message": "Exchange deleted",
}
"""
storage = persistence.get_storage()
collab = storage.exchange_get(exchange_name)
if collab is None:
return {"message": "success"}
abort(501, "Not yet implemented")
abort(404, f"exchange '{exchange_name}' not found")

storage.exchange_delete(exchange_name)
return {"message": "Exchange deleted"}


# Signal Types
Expand Down
23 changes: 23 additions & 0 deletions hasher-matcher-actioner/src/OpenMediaMatch/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,26 @@ def test_compare_hashes(app: Flask, client: FlaskClient):
json=bad_input,
)
assert resp.status_code == 400


def test_exchange_delete(app: Flask, client: FlaskClient):
delete_response = client.delete(
"/c/exchange/TEST_EXCHANGE",
)
# test exchange not found
assert delete_response.status_code == 404
assert delete_response.get_json()["message"] == "exchange 'TEST_EXCHANGE' not found"

# create an exchange
post_response = client.post(
"/c/exchanges",
json={"api": "sample", "bank": "FOO_EXCHANGE", "api_json": {}},
)
assert post_response.status_code == 201

# test a successful delete
delete_response = client.delete(
"/c/exchange/FOO_EXCHANGE",
)
assert delete_response.status_code == 200
assert delete_response.get_json()["message"] == "Exchange deleted"

0 comments on commit df92ef5

Please sign in to comment.