Skip to content

Commit cd8bc0d

Browse files
committed
move proxy fixture to conftest
so it can be re-used
1 parent 83f2260 commit cd8bc0d

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

tests/conftest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from tempfile import TemporaryDirectory
1212

1313
import pytest
14+
import utils
1415
from consul.aio import Consul
1516
from jupyterhub.utils import exponential_backoff
1617
from traitlets.log import get_logger
@@ -288,6 +289,36 @@ async def auth_external_etcd_proxy(
288289
proxy.etcd.close()
289290

290291

292+
@pytest.fixture(
293+
params=[
294+
"no_auth_consul_proxy",
295+
"auth_consul_proxy",
296+
"no_auth_etcd_proxy",
297+
"auth_etcd_proxy",
298+
"file_proxy_toml",
299+
"file_proxy_yaml",
300+
"external_consul_proxy",
301+
"auth_external_consul_proxy",
302+
"external_etcd_proxy",
303+
"auth_external_etcd_proxy",
304+
"external_file_proxy_toml",
305+
"external_file_proxy_yaml",
306+
]
307+
)
308+
def proxy(request):
309+
"""Parameterized fixture to run all the tests with every proxy implementation"""
310+
proxy = request.getfixturevalue(request.param)
311+
# wait for public endpoint to be reachable
312+
asyncio.run(
313+
exponential_backoff(
314+
utils.check_host_up_http,
315+
f"Proxy public url {proxy.public_url} cannot be reached",
316+
url=proxy.public_url,
317+
)
318+
)
319+
return proxy
320+
321+
291322
#########################################################################
292323
# Fixtures for launching traefik, with each backend and with or without #
293324
# authentication #

tests/test_proxy.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,36 +138,6 @@ async def _launch_backends(n=1):
138138
proc.wait()
139139

140140

141-
@pytest.fixture(
142-
params=[
143-
"no_auth_consul_proxy",
144-
"auth_consul_proxy",
145-
"no_auth_etcd_proxy",
146-
"auth_etcd_proxy",
147-
"file_proxy_toml",
148-
"file_proxy_yaml",
149-
"external_consul_proxy",
150-
"auth_external_consul_proxy",
151-
"external_etcd_proxy",
152-
"auth_external_etcd_proxy",
153-
"external_file_proxy_toml",
154-
"external_file_proxy_yaml",
155-
]
156-
)
157-
def proxy(request):
158-
"""Parameterized fixture to run all the tests with every proxy implementation"""
159-
proxy = request.getfixturevalue(request.param)
160-
# wait for public endpoint to be reachable
161-
asyncio.run(
162-
exponential_backoff(
163-
utils.check_host_up_http,
164-
f"Proxy public url {proxy.public_url} cannot be reached",
165-
url=proxy.public_url,
166-
)
167-
)
168-
return proxy
169-
170-
171141
async def wait_for_services(urls):
172142
# Wait until traefik and the backend are ready
173143
await exponential_backoff(

tests/test_traefik_api_auth.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@
77
pytestmark = pytest.mark.asyncio
88

99

10-
@pytest.fixture(
11-
params=[
12-
"file_proxy_toml",
13-
"file_proxy_yaml",
14-
"no_auth_etcd_proxy",
15-
"auth_etcd_proxy",
16-
"no_auth_consul_proxy",
17-
"auth_consul_proxy",
18-
]
19-
)
20-
def proxy(request):
21-
return request.getfixturevalue(request.param)
22-
23-
2410
@pytest.mark.parametrize(
2511
"username, password, expected_rc",
2612
[("api_admin", "admin", 200), ("api_admin", "1234", 401), ("", "", 401)],

0 commit comments

Comments
 (0)