Skip to content

Commit f14f893

Browse files
jobselkoggainey
authored andcommitted
Test pulp_id__in validation via raw HTTP
1 parent f34e2d4 commit f14f893

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

pulpcore/tests/functional/api/test_filter.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import asyncio
12
import random
23
import uuid
34

45
import pytest
6+
from aiohttp import BasicAuth, ClientSession
57

68
# Warning: Do not use HEX digits here!
79
NAMES = (
@@ -94,12 +96,28 @@ def test_pulp_id_href_filter(
9496
redi_results = pulpcore_bindings.ContentguardsContentRedirectApi.list(**{filter: []})
9597
assert redi_results.count == 0
9698

97-
# Test that filter fails when not a valid type
98-
with pytest.raises(pulpcore_bindings.ApiException) as exc:
99-
pulpcore_bindings.ContentguardsApi.list(**{filter: ["hello"]})
99+
# Test that pulp_href filter fails when not a valid type
100+
if filter == "pulp_href__in":
101+
with pytest.raises(pulpcore_bindings.ApiException) as exc:
102+
pulpcore_bindings.ContentguardsApi.list(**{filter: ["hello"]})
100103

101-
assert exc.value.status == 400
102-
assert exception_message in exc.value.body
104+
assert exc.value.status == 400
105+
assert exception_message in exc.value.body
106+
107+
@pytest.mark.parallel
108+
def test_pulp_id_filter_invalid_value(self, bindings_cfg, pulp_api_v3_url):
109+
"""Test that the server rejects invalid UUID for pulp_id__in."""
110+
111+
async def _do_request():
112+
auth = BasicAuth(login=bindings_cfg.username, password=bindings_cfg.password)
113+
url = f"{pulp_api_v3_url}contentguards/"
114+
async with ClientSession(auth=auth) as session:
115+
async with session.get(f"{url}?pulp_id__in=hello") as resp:
116+
return resp.status, await resp.text()
117+
118+
status, body = asyncio.run(_do_request())
119+
assert status == 400
120+
assert "Enter a valid UUID" in body
103121

104122
@pytest.mark.parallel
105123
def test_pulp_type_filter(

0 commit comments

Comments
 (0)