11import pytest
22
3- from nrlf .core .constants import PERMISSION_ALLOW_ALL_POINTER_TYPES
4- from tests .smoke .environment import ConnectMode , EnvironmentConfig , SmokeTestParameters
3+ from nrlf .core .constants import PERMISSION_ALLOW_ALL_POINTER_TYPES , V2Headers
4+ from tests .smoke .environment import EnvironmentConfig , SmokeTestParameters
55from tests .smoke .setup import build_document_reference
6- from tests .utilities .api_clients import ProducerTestClient
6+ from tests .utilities .api_clients import ConnectionMetadata , ProducerTestClient
7+
8+ v2_1dsync_app_id = "SMOKETEST_1DSYNC_V1"
79
810
911@pytest .fixture
@@ -12,12 +14,24 @@ def producer_client_1dsync(
1214) -> ProducerTestClient :
1315 client_config = environment_config .to_client_config (smoke_test_parameters )
1416
15- if environment_config .connect_mode == ConnectMode .INTERNAL :
16- client_config .connection_metadata ["nrl.permissions" ] = [
17- PERMISSION_ALLOW_ALL_POINTER_TYPES
18- ]
19- client_config .connection_metadata ["nrl.app-id" ] = "SMOKETEST1DSYNC"
17+ if environment_config .connect_mode == "internal" :
18+ connection_metadata = ConnectionMetadata .model_validate (
19+ {
20+ "nrl.permissions" : [PERMISSION_ALLOW_ALL_POINTER_TYPES ],
21+ "nrl.app-id" : v2_1dsync_app_id ,
22+ "nrl.ods-code" : smoke_test_parameters .ods_code ,
23+ "client_rp_details" : {
24+ "developer.app.name" : smoke_test_parameters .apigee_app_name ,
25+ "developer.app.id" : smoke_test_parameters .apigee_app_id ,
26+ },
27+ }
28+ )
29+ client_config .connection_metadata = connection_metadata
30+ client_config .custom_headers [V2Headers .X_PROXYGEN_APP_NRL_APP_ID ] = (
31+ v2_1dsync_app_id
32+ )
2033 else :
34+ # can't use app-level perms here without setting up another apigee app, use ODS instead
2135 client_config .custom_headers ["NHSD-End-User-Organisation-ODS" ] = (
2236 "SMOKETEST1DSYNC"
2337 )
@@ -33,7 +47,9 @@ def test_smoke_1dsync_upsert_delete(
3347 """
3448 Smoke test scenario for 1dsync upsert and delete behaviour
3549 """
36- test_ods_code = smoke_test_parameters .ods_code
50+ test_ods_code = producer_client_1dsync .config .custom_headers .get (
51+ "NHSD-End-User-Organisation-ODS"
52+ )
3753 test_docref = build_document_reference (
3854 nhs_number = test_nhs_numbers [0 ], custodian = test_ods_code
3955 )
0 commit comments