Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/persistent-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ jobs:
env:
ENVIRONMENT: ${{ inputs.environment }}
run: |
account=$(echo "$ENVIRONMENT" | cut -d '-' -f1)
inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack $ENVIRONMENT)
make get-s3-perms ENV=${account} TF_WORKSPACE_NAME=${inactive_stack}
make get-s3-perms ENV=$ENVIRONMENT TF_WORKSPACE_NAME=${inactive_stack} USE_SHARED_RESOURCES=true

- name: Save Build Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
51 changes: 51 additions & 0 deletions scripts/get_s3_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,53 @@ def add_smoke_test_files(secretsmanager, local_path, env_name):
]


def add_sandbox_files(local_path):
"""Add the permissions required for the sandbox environments.
Only call this function if your want to add sandbox permissions.
These permissions are taken from the existing permissions in the API proxy repos.
"""
sandbox_app_id = "NRL-SANDBOX-APP"
nrl_sandbox_perms = {
"RJ11": [
PointerTypes.MENTAL_HEALTH_PLAN.value, # http://snomed.info/sct|736253002
],
# These ones are needed for the Seed data
"Y05868": [
PointerTypes.MENTAL_HEALTH_PLAN.value, # http://snomed.info/sct|736253002
PointerTypes.EMERGENCY_HEALTHCARE_PLAN.value, # http://snomed.info/sct|887701000000100
PointerTypes.NEWS2_CHART.value, # http://snomed.info/sct|1363501000000100
PointerTypes.EOL_COORDINATION_SUMMARY.value, # http://snomed.info/sct|861421000000109
],
"8J008": [
PointerTypes.NEWS2_CHART.value
], # http://snomed.info/sct|1363501000000100
"RY26A": [
PointerTypes.EOL_COORDINATION_SUMMARY.value
], # http://snomed.info/sct|861421000000109
# This one is needed for Smoke Tests
"RM559": [
PointerTypes.MENTAL_HEALTH_PLAN.value
], # http://snomed.info/sct|736253002
}

for ods_code, snomed_codes in nrl_sandbox_perms.items():
_write_permission_file(
Path.joinpath(local_path, "producer", sandbox_app_id),
ods_code,
snomed_codes,
)
_write_permission_file(
Path.joinpath(local_path, "consumer", sandbox_app_id),
ods_code,
snomed_codes,
)
_write_v1_permission_file(
Path.joinpath(local_path, sandbox_app_id),
ods_code,
snomed_codes,
)


def download_files(
s3_client, bucket_name, local_path, file_names, folders, secretsmanager, env_name
):
Expand All @@ -297,6 +344,10 @@ def download_files(
add_feature_test_files(local_path)
add_smoke_test_files(secretsmanager, local_path, env_name)

if env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]:
print(f"Adding sandbox permissions for {env_name} to temporary directory...")
add_sandbox_files(local_path)


def main(use_shared_resources: str, env: str, workspace: str, path_to_store: str):
stack_name = env if use_shared_resources else workspace
Expand Down
2 changes: 1 addition & 1 deletion terraform/infrastructure/etc/dev.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public_domain = "internal-dev.api.service.nhs.uk"
public_sandbox_domain = "internal-dev-sandbox.api.service.nhs.uk"

log_retention_period = 90
enable_reporting = false
enable_reporting = true
30 changes: 22 additions & 8 deletions tests/smoke/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ def producer_client_v1(
environment_config: EnvironmentConfig, smoke_test_parameters: SmokeTestParameters
) -> ProducerTestClient:
config = environment_config.to_client_config(smoke_test_parameters)

if (
environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]
and smoke_test_parameters.ods_code
):
client_ods_code = smoke_test_parameters.ods_code
else:
client_ods_code = smoke_test_parameters.v1_ods_code

if environment_config.connect_mode == ConnectMode.INTERNAL:
config.connection_metadata.ods_code = smoke_test_parameters.v1_ods_code
config.custom_headers["NHSD-End-User-Organisation-ODS"] = (
smoke_test_parameters.v1_ods_code
)
config.connection_metadata.ods_code = client_ods_code
config.custom_headers["NHSD-End-User-Organisation-ODS"] = client_ods_code
return ProducerTestClient(config=config)


Expand All @@ -68,11 +75,18 @@ def consumer_client_v1(
environment_config: EnvironmentConfig, smoke_test_parameters: SmokeTestParameters
) -> ConsumerTestClient:
config = environment_config.to_client_config(smoke_test_parameters)

if (
environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]
and smoke_test_parameters.ods_code
):
client_ods_code = smoke_test_parameters.ods_code
else:
client_ods_code = smoke_test_parameters.v1_ods_code

if environment_config.connect_mode == ConnectMode.INTERNAL:
config.connection_metadata.ods_code = smoke_test_parameters.v1_ods_code
config.custom_headers["NHSD-End-User-Organisation-ODS"] = (
smoke_test_parameters.v1_ods_code
)
config.connection_metadata.ods_code = client_ods_code
config.custom_headers["NHSD-End-User-Organisation-ODS"] = client_ods_code
return ConsumerTestClient(config=config)


Expand Down
10 changes: 8 additions & 2 deletions tests/smoke/scenarios/1dsync_upsert_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def producer_client_1dsync(
if environment_config.connect_mode == ConnectMode.INTERNAL.value:
custom_smoke_test_parameters.nrlf_app_id = "SMOKETEST1DSYNC"

custom_smoke_test_parameters.ods_code = "SMOKETEST1DSYNC"
if environment_config.env_name not in ["dev-sandbox", "qa-sandbox", "int-sandbox"]:
custom_smoke_test_parameters.ods_code = "SMOKETEST1DSYNC"

client_config = environment_config.to_client_config(custom_smoke_test_parameters)

Expand All @@ -25,12 +26,17 @@ def producer_client_1dsync(
def test_smoke_1dsync_upsert_delete(
producer_client_1dsync: ProducerTestClient,
smoke_test_parameters: SmokeTestParameters,
environment_config: EnvironmentConfig,
test_nhs_numbers: list[str],
):
"""
Smoke test scenario for 1dsync upsert and delete behaviour
"""
test_ods_code = "SMOKETEST1DSYNC"
if environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]:
test_ods_code = smoke_test_parameters.ods_code
else:
test_ods_code = "SMOKETEST1DSYNC"

test_docref = build_document_reference(
nhs_number=test_nhs_numbers[0], custodian=test_ods_code
)
Expand Down
14 changes: 11 additions & 3 deletions tests/smoke/scenarios/consumer_search_read_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from tests.smoke.environment import SmokeTestParameters
from tests.smoke.environment import EnvironmentConfig, SmokeTestParameters
from tests.smoke.setup import build_document_reference, upsert_test_pointer
from tests.utilities.api_clients import ConsumerTestClient, ProducerTestClient

Expand All @@ -12,8 +12,16 @@ def test_data_v1(
test_nhs_numbers: list[str],
producer_client_v1: ProducerTestClient,
smoke_test_parameters: SmokeTestParameters,
) -> Generator[str, Any, None]:
test_ods_code = smoke_test_parameters.v1_ods_code
environment_config: EnvironmentConfig,
) -> Generator[dict[str, Any], Any, None]:
if (
environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]
and smoke_test_parameters.ods_code
):
test_ods_code = smoke_test_parameters.ods_code
else:
test_ods_code = smoke_test_parameters.v1_ods_code

test_pointers = [
upsert_test_pointer(
f"{test_ods_code}-smoketest_consumer_search_read_pointer_{n}",
Expand Down
12 changes: 10 additions & 2 deletions tests/smoke/scenarios/producer_crud_v1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tests.smoke.environment import SmokeTestParameters
from tests.smoke.environment import EnvironmentConfig, SmokeTestParameters
from tests.smoke.setup import build_document_reference
from tests.utilities.api_clients import ProducerTestClient

Expand All @@ -7,11 +7,19 @@ def test_smoke_producer_crud_v1(
producer_client_v1: ProducerTestClient,
test_nhs_numbers: list[str],
smoke_test_parameters: SmokeTestParameters,
environment_config: EnvironmentConfig,
):
"""
Smoke test scenario for producer CRUD behaviour
"""
test_ods_code = smoke_test_parameters.v1_ods_code
if (
environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]
and smoke_test_parameters.ods_code
):
test_ods_code = smoke_test_parameters.ods_code
else:
test_ods_code = smoke_test_parameters.v1_ods_code

test_docref = build_document_reference(
nhs_number=test_nhs_numbers[0], custodian=test_ods_code
)
Expand Down
15 changes: 12 additions & 3 deletions tests/smoke/scenarios/producer_search_read_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from tests.smoke.environment import SmokeTestParameters
from tests.smoke.environment import EnvironmentConfig, SmokeTestParameters
from tests.smoke.setup import build_document_reference, upsert_test_pointer
from tests.utilities.api_clients import ProducerTestClient

Expand All @@ -12,8 +12,17 @@ def test_data(
test_nhs_numbers: list[str],
producer_client_v1: ProducerTestClient,
smoke_test_parameters: SmokeTestParameters,
) -> Generator[str, Any, None]:
test_ods_code = smoke_test_parameters.v1_ods_code
environment_config: EnvironmentConfig,
) -> Generator[dict[str, Any], Any, None]:

if (
environment_config.env_name in ["dev-sandbox", "qa-sandbox", "int-sandbox"]
and smoke_test_parameters.ods_code
):
test_ods_code = smoke_test_parameters.ods_code
else:
test_ods_code = smoke_test_parameters.v1_ods_code

test_pointers = [
upsert_test_pointer(
f"{test_ods_code}-smoketest_producer_count_search_read_pointer_{n}",
Expand Down
Loading