Skip to content

Commit 3c6dcac

Browse files
AchoArnoldCopilot
andcommitted
refactor: replace emulator with WireMock, add E2E encryption and rate-limit tests
- Replace custom phone emulator with WireMock for FCM and webhook stubs - Refactor tests to use httpsms-go SDK instead of raw HTTP calls - Add TestSendSMS_Encrypted: E2E encryption round-trip verification - Add TestReceiveSMS_Encrypted: incoming encrypted message test - Add TestSendSMS_RateLimit: verify >=6s gap between FCM pushes (10 msg/min) - Add TestSendSMS_OutstandingFlow: verify outstanding message retrieval - All tests assert webhook JWT (HMAC-SHA256, claims validation) - Each test creates isolated phone with random number for parallel execution - Update CI workflow: checkout httpsms-go SDK, increase test timeout to 300s - Simplify seed.sql to only user data (phones created dynamically) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e58acfd commit 3c6dcac

20 files changed

Lines changed: 677 additions & 461 deletions

.github/workflows/integration-test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ jobs:
1818
- name: Checkout 🛎
1919
uses: actions/checkout@v4
2020

21+
- name: Checkout httpsms-go SDK
22+
uses: actions/checkout@v4
23+
with:
24+
repository: NdoleStudio/httpsms-go
25+
path: httpsms-go
26+
2127
- name: Set up Go
2228
uses: actions/setup-go@v5
2329
with:
2430
go-version: "1.23"
2531

32+
- name: Fix SDK replace path for CI
33+
working-directory: ./tests
34+
run: |
35+
sed -i 's|replace github.com/NdoleStudio/httpsms-go => ../../httpsms-go|replace github.com/NdoleStudio/httpsms-go => ../httpsms-go|' go.mod
36+
2637
- name: Generate Firebase credentials
2738
run: |
2839
bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json
@@ -59,7 +70,7 @@ jobs:
5970
6071
- name: Run integration tests 🧪
6172
working-directory: ./tests
62-
run: go test -v -timeout 120s ./...
73+
run: go test -v -timeout 300s ./...
6374

6475
- name: Collect logs on failure 📋
6576
if: failure()

tests/.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ EVENTS_QUEUE_NAME=events-local
77
EVENTS_QUEUE_ENDPOINT=http://localhost:8000/v1/events
88
EVENTS_QUEUE_USER_API_KEY=system-user-api-key
99
EVENTS_QUEUE_USER_ID=system-user-id
10-
FCM_ENDPOINT=http://emulator:9090
10+
FCM_ENDPOINT=http://wiremock:8080
1111
DATABASE_URL=postgresql://dbusername:dbpassword@postgres:5432/httpsms
1212
DATABASE_URL_DEDICATED=postgresql://dbusername:dbpassword@postgres:5432/httpsms
1313
REDIS_URL=redis://@redis:6379

tests/docker-compose.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ services:
2525
timeout: 5s
2626
retries: 10
2727

28-
emulator:
29-
build:
30-
context: ./emulator
28+
wiremock:
29+
image: wiremock/wiremock:3x
3130
ports:
32-
- "9090:9090"
33-
environment:
34-
API_BASE_URL: http://api:8000
35-
PHONE_API_KEY: pk_test-phone-api-key
36-
PORT: "9090"
31+
- "8080:8080"
32+
volumes:
33+
- ./wiremock/mappings:/home/wiremock/mappings:ro
3734
healthcheck:
38-
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/health"]
35+
test: ["CMD", "curl", "-f", "http://localhost:8080/__admin/health"]
3936
interval: 5s
4037
timeout: 5s
4138
retries: 10
@@ -50,7 +47,7 @@ services:
5047
condition: service_healthy
5148
redis:
5249
condition: service_healthy
53-
emulator:
50+
wiremock:
5451
condition: service_healthy
5552
env_file:
5653
- .env.test

tests/emulator/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/emulator/emulator.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/emulator/events.go

Lines changed: 0 additions & 113 deletions
This file was deleted.

tests/emulator/fcm_handler.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/emulator/go.mod

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/emulator/go.sum

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)