Skip to content

WIP: Feature/hote 710/mock support#259

Draft
mikeeq wants to merge 4 commits intomainfrom
feature/hote-710/mock-support
Draft

WIP: Feature/hote 710/mock support#259
mikeeq wants to merge 4 commits intomainfrom
feature/hote-710/mock-support

Conversation

@mikeeq
Copy link
Copy Markdown
Collaborator

@mikeeq mikeeq commented Mar 16, 2026

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copilot AI review requested due to automatic review settings March 16, 2026 15:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new Rust-based “mock-service” Lambda (stubr) and wires it into the LocalStack/Terraform local environment to replace the existing WireMock container, including updating seeded supplier URLs to point at the mock API after deploy.

Changes:

  • Add mock-service/ (Rust Lambda + build/package scripts + docs) that serves existing WireMock mapping JSON via API Gateway proxy routes.
  • Update local deployment flow (package.json) to build/package the mock-service and update supplier.service_url after terraform apply.
  • Replace WireMock container usage in local environment (Terraform + docker-compose) and add new WireMock mapping stubs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
scripts/terraform/post-apply-update-supplier-url.sh New post-apply script to update seeded supplier URLs to the mock-service API Gateway base URL
package.json Extends postinstall/local deploy scripts to include mock-service build/package and URL update
mock-service/src/main.rs Rust Lambda entrypoint: starts stubr and proxies API Gateway requests after stripping /mock/* prefixes
mock-service/scripts/build.sh Builds Lambda bootstrap via cargo lambda and bundles WireMock mappings into dist/
mock-service/scripts/package.sh Zips bootstrap + mappings for Terraform deployment
mock-service/package.json Adds npm wrappers around build/package/clean operations
mock-service/Cargo.toml Declares Rust dependencies for lambda_http + stubr proxy service
mock-service/README.md Documents how the mock-service works and how it’s deployed/used locally and in AWS
mock-service/docs/test-scenario-routing.md Documents patterns for scenario-based routing with file-based stubs (stubr limitations noted)
local-environment/infra/main.tf Adds LocalStack Lambda + dedicated API Gateway for mock-service (proxy integration)
local-environment/infra/outputs.tf Adds outputs for mock-service URLs and updates seeded supplier output description
local-environment/docker-compose.yml Removes the WireMock container from the backend compose profile
database/03-seed-hometest-data.sql Seeds suppliers with a placeholder URL to be replaced post-deploy
local-environment/wiremock/mappings/*.json Adds additional stub mappings (health, jwks, postcode lookups) used by stubr

Comment on lines +10 to +13
echo "Building mock-service (stubr) for Lambda..."

cd "$ROOT_DIR"
cargo lambda build --release --arm64
role = aws_iam_role.lambda_role.arn
handler = "bootstrap"
runtime = "provided.al2023"
architectures = ["arm64"]
Comment on lines +95 to +113
output "mock_api_base_url" {
description = "Base URL for the mock API on LocalStack"
value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}"
}

output "mock_supplier_base_url" {
description = "Supplier mock base URL (use as service_url in supplier table)"
value = "http://localstack-main:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/supplier"
}

output "mock_supplier_base_url_host" {
description = "Supplier mock base URL accessible from host machine"
value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/supplier"
}

output "mock_cognito_jwks_url" {
description = "Mock Cognito JWKS URL"
value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/cognito/.well-known/jwks.json"
}
Comment on lines +57 to +63
let body_text = resp.text().await?;

let mut builder = Response::builder().status(status);
for (name, value) in &resp_headers {
builder = builder.header(name, value);
}
Ok(builder.body(Body::Text(body_text))?)

[dependencies]
lambda_http = "0.13"
lambda_runtime = "0.13"
Comment on lines +20 to +21
zip -r "$ZIP_PATH" bootstrap mappings/


docker exec postgres-db psql \
"postgresql://app_user:STRONG_APP_PASSWORD@localhost:5432/local_hometest_db" \
-c "SET search_path TO hometest; UPDATE supplier SET service_url = '${MOCK_SUPPLIER_URL}' WHERE service_url LIKE '%mock-service-placeholder%' OR service_url LIKE '%wiremock%';"
"private": true,
"scripts": {
"postinstall": "npm --prefix ui install && npm --prefix lambdas install && npm --prefix tests install",
"postinstall": "npm --prefix ui install && npm --prefix lambdas install && npm --prefix mock-service install && npm --prefix tests install",
@lewisbirks
Copy link
Copy Markdown
Contributor

@mikeeq is this needed still?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants