|
2 | 2 | # pylint: disable=unused-argument |
3 | 3 | # pylint: disable=unused-variable |
4 | 4 |
|
| 5 | +import random |
5 | 6 | import re |
6 | 7 | import subprocess |
7 | 8 | from collections.abc import Callable |
|
16 | 17 | EC2InstanceData, |
17 | 18 | ) |
18 | 19 | from common_library.json_serialization import json_dumps |
19 | | -from common_library.serialization import model_dump_with_secrets |
20 | 20 | from faker import Faker |
21 | 21 | from models_library.api_schemas_clusters_keeper.clusters import ClusterState |
22 | 22 | from models_library.clusters import ( |
23 | 23 | ClusterAuthentication, |
24 | 24 | NoAuthentication, |
25 | 25 | TLSAuthentication, |
26 | 26 | ) |
27 | | -from pydantic import ByteSize, SecretStr, TypeAdapter |
| 27 | +from pydantic import ByteSize, TypeAdapter |
28 | 28 | from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict |
29 | 29 | from settings_library.rabbit import RabbitSettings |
30 | 30 | from simcore_service_clusters_keeper.core.settings import ApplicationSettings |
@@ -207,20 +207,14 @@ def rabbitmq_settings_fixture( |
207 | 207 | ) -> RabbitSettings | None: |
208 | 208 | if request.param == "custom": |
209 | 209 | # Create random RabbitMQ settings using faker |
210 | | - custom_rabbit_settings = RabbitSettings( |
211 | | - RABBIT_HOST=faker.hostname(), |
212 | | - RABBIT_PORT=faker.port_number(), |
213 | | - RABBIT_SECURE=faker.boolean(), |
214 | | - RABBIT_USER=faker.user_name(), |
215 | | - RABBIT_PASSWORD=SecretStr(faker.password()), |
| 210 | + custom_rabbit_settings = random.choice( # noqa: S311 |
| 211 | + RabbitSettings.model_json_schema()["examples"] |
216 | 212 | ) |
217 | 213 | monkeypatch.setenv( |
218 | | - "PRIMARY_EC2_INSTANCES_RABBIT", |
219 | | - json_dumps( |
220 | | - model_dump_with_secrets(custom_rabbit_settings, show_secrets=True) |
221 | | - ), |
| 214 | + "PRIMARY_EC2_INSTANCES_RABBIT", json_dumps(custom_rabbit_settings) |
222 | 215 | ) |
223 | | - return custom_rabbit_settings |
| 216 | + return RabbitSettings.model_validate(custom_rabbit_settings) |
| 217 | + assert request.param == "default" |
224 | 218 | return enabled_rabbitmq |
225 | 219 |
|
226 | 220 |
|
|
0 commit comments