|
| 1 | +import asyncio |
1 | 2 | import random |
2 | 3 | import uuid |
3 | 4 |
|
4 | 5 | import pytest |
| 6 | +from aiohttp import BasicAuth, ClientSession |
5 | 7 |
|
6 | 8 | # Warning: Do not use HEX digits here! |
7 | 9 | NAMES = ( |
@@ -94,12 +96,28 @@ def test_pulp_id_href_filter( |
94 | 96 | redi_results = pulpcore_bindings.ContentguardsContentRedirectApi.list(**{filter: []}) |
95 | 97 | assert redi_results.count == 0 |
96 | 98 |
|
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"]}) |
100 | 103 |
|
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 |
103 | 121 |
|
104 | 122 | @pytest.mark.parallel |
105 | 123 | def test_pulp_type_filter( |
|
0 commit comments