Skip to content

Commit

Permalink
Fix: parse refs and hashes fields correctly for messages API (#346)
Browse files Browse the repository at this point in the history
Problem: the new validation system did not parse the `refs`
and `hashes` list parameters correctly.

Solution: apply the list validator to these fields as well.
  • Loading branch information
odesenfans committed Oct 27, 2022
1 parent 868a6d1 commit aa38b38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/aleph/web/controllers/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ def validate_field_dependencies(cls, values):

@validator(
"addresses",
"refs",
"content_hashes",
"content_keys",
"content_types",
"chains",
"channels",
"tags",
"hashes",
pre=True,
)
def split_str(cls, v):
Expand Down
12 changes: 12 additions & 0 deletions tests/api/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ async def test_get_messages_filter_by_content_hash(fixture_messages, ccn_api_cli
)


@pytest.mark.asyncio
async def test_get_messages_multiple_hashes(fixture_messages, ccn_api_client):
hashes = [
"2953f0b52beb79fc0ed1bc455346fdcb530611605e16c636778a0d673d7184af",
"bc411ae2ba89289458d0168714457e7c9394a29ca83159240585591f4f46444a",
]
response = await ccn_api_client.get(MESSAGES_URI, params={"hashes": ",".join(hashes)})
assert response.status == 200, await response.text()
messages = (await response.json())["messages"]
assert len(messages) == 2


@pytest.mark.asyncio
async def test_get_messages_filter_by_invalid_content_hash(
fixture_messages, ccn_api_client
Expand Down

0 comments on commit aa38b38

Please sign in to comment.