Skip to content

Commit 8bbb5ca

Browse files
authored
Merge branch 'blackout/Phase-1' into chore/replace-cpp-bracket-code
2 parents 67a9f80 + 8016ea5 commit 8bbb5ca

File tree

48 files changed

+2280
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2280
-41
lines changed

IntegrationTests/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ Before getting started, install Tuist:
1010
brew install tuist
1111
```
1212

13+
### Environment Variables
14+
15+
mParticle API credentials are required **only for recording** new API interactions:
16+
17+
```bash
18+
export MPARTICLE_API_KEY="your-api-key"
19+
export MPARTICLE_API_SECRET="your-api-secret"
20+
```
21+
22+
**Recording mode (`run_wiremock_recorder.sh`):** Real API keys are required to record actual API responses from mParticle servers.
23+
24+
**Verification mode (`run_clean_integration_tests.sh`):** API keys are **optional**. If not set, the tests will automatically use fake keys (`us1-00000000000000000000000000000000`) that match the WireMock URL patterns. This allows running integration tests without exposing real credentials.
25+
26+
**Note:** Fake keys must match the pattern `us1-[a-f0-9]+` to work with WireMock mappings.
27+
1328
Then generate the Xcode project:
1429

1530
```bash

IntegrationTests/Sources/main.swift

Lines changed: 322 additions & 8 deletions
Large diffs are not rendered by default.

IntegrationTests/common.sh

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ install_application() {
158158

159159
launch_application() {
160160
echo "▶️ Launching application..."
161+
162+
# Launch with environment variables using SIMCTL_CHILD_ prefix
163+
# If not set, the app will use fake keys for verification mode
164+
local launch_cmd="xcrun simctl launch \"$DEVICE_ID\" \"$BUNDLE_ID\""
165+
166+
if [ -n "$MPARTICLE_API_KEY" ]; then
167+
export SIMCTL_CHILD_MPARTICLE_API_KEY="$MPARTICLE_API_KEY"
168+
fi
169+
if [ -n "$MPARTICLE_API_SECRET" ]; then
170+
export SIMCTL_CHILD_MPARTICLE_API_SECRET="$MPARTICLE_API_SECRET"
171+
fi
172+
161173
LAUNCH_OUTPUT=$(xcrun simctl launch "$DEVICE_ID" "$BUNDLE_ID")
162174
APP_PID=$(echo "$LAUNCH_OUTPUT" | awk -F': ' '{print $2}')
163175

@@ -171,7 +183,7 @@ launch_application() {
171183

172184
wait_for_app_completion() {
173185
echo "⏳ Waiting for app to complete execution..."
174-
local MAX_WAIT=60
186+
local MAX_WAIT=120
175187
local WAIT_COUNT=0
176188
while kill -0 "$APP_PID" 2>/dev/null; do
177189
sleep 1
@@ -262,3 +274,47 @@ stop_wiremock_with_logs() {
262274
stop_wiremock
263275
}
264276

277+
create_proxy_mappings() {
278+
echo "📝 Creating proxy mappings for recording mode..."
279+
280+
local PROXY_DIR="${MAPPINGS_DIR}/mappings"
281+
mkdir -p "$PROXY_DIR"
282+
283+
# Create proxy-identify.json
284+
cat > "${PROXY_DIR}/proxy-identify.json" << 'EOF'
285+
{
286+
"priority": 1,
287+
"request": {
288+
"urlPathPattern": "/v1/identify"
289+
},
290+
"response": {
291+
"proxyBaseUrl": "https://identity.mparticle.com"
292+
}
293+
}
294+
EOF
295+
296+
# Create proxy-events.json
297+
cat > "${PROXY_DIR}/proxy-events.json" << 'EOF'
298+
{
299+
"priority": 1,
300+
"request": {
301+
"urlPathPattern": "/v2/events"
302+
},
303+
"response": {
304+
"proxyBaseUrl": "https://nativesdks.mparticle.com"
305+
}
306+
}
307+
EOF
308+
309+
echo "✅ Proxy mappings created"
310+
}
311+
312+
remove_proxy_mappings() {
313+
echo "🗑️ Removing proxy mappings for verification mode..."
314+
315+
rm -f "${MAPPINGS_DIR}/mappings/proxy-identify.json" 2>/dev/null || true
316+
rm -f "${MAPPINGS_DIR}/mappings/proxy-events.json" 2>/dev/null || true
317+
318+
echo "✅ Proxy mappings removed"
319+
}
320+

IntegrationTests/run_clean_integration_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ find_app_path
167167
reset_simulators
168168
find_available_device
169169
find_device
170+
remove_proxy_mappings
170171
escape_mapping_bodies
171172
start_wiremock "verify"
172173
wait_for_wiremock

IntegrationTests/run_wiremock_recorder.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ TARGET_URL=${4:-"https://config2.mparticle.com"}
1010
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1111
source "${SCRIPT_DIR}/common.sh"
1212

13+
# === Check required environment variables for recording ===
14+
if [ -z "$MPARTICLE_API_KEY" ] || [ -z "$MPARTICLE_API_SECRET" ]; then
15+
echo "❌ Error: MPARTICLE_API_KEY and MPARTICLE_API_SECRET environment variables must be set for recording mode"
16+
echo " Real API keys are required to record actual API responses from mParticle servers"
17+
exit 1
18+
fi
19+
1320
# === Build framework and generate project ===
1421
build_framework
1522

@@ -23,6 +30,9 @@ CONTAINER_NAME="wiremock-recorder"
2330
mkdir -p "${MAPPINGS_DIR}/mappings"
2431
mkdir -p "${MAPPINGS_DIR}/__files"
2532

33+
# Create proxy mappings for recording
34+
create_proxy_mappings
35+
2636
# Trap to ensure cleanup on exit
2737
trap stop_wiremock EXIT INT TERM
2838

IntegrationTests/transform_mapping_body.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
'dlc', # Device Locale
4242
'dn', # Device Name
4343
'dosv', # Device OS Version
44+
'el', # Event Length (duration in milliseconds for timed events)
4445
'en', # Event Number (position in session, e.g., 0, 1, 2...)
4546
'est', # Event Start Time
47+
'iba', # Instruction Base Address (memory address for errors)
4648
'ict', # Init Config Time
4749
'id', # ID (various message/event IDs)
4850
'lud', # Last Update Date
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dt":"rh","id":"e3d7fc9b-15d2-4109-b90b-1dc892641c97","ct":1764796657912,"msgs":[],"ci":{"mpid":6504934091054997508,"ck":{"uid":{"c":"g=7f6d2e60-d81a-4edf-a5d6-996c6f15fa70","e":"2035-11-04T19:37:06.7933933Z"}},"das":"7f6d2e60-d81a-4edf-a5d6-996c6f15fa70"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dt":"rh","id":"a7c8f4d7-aeb2-4f55-91e5-91a267afc382","ct":1764858535905,"err":[{"dt":"err","id":"92e1921b-09d0-434c-a3ef-0484baa5c2c3","ct":1764858535905,"msg":"Invalid Consent State provided - please verify the Consent Purposes that you have defined for this workspace.","code":"invalid_consent"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"audience_memberships":[{"audience_id":12345,"audience_name":"Test Audience 1"},{"audience_id":67890,"audience_name":"Test Audience 2"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dt":"rh","id":"71a50897-9ff8-4b56-9a73-9ff4281cf33a","ct":1764789344543,"msgs":[],"ci":{"mpid":6504934091054997508,"ck":{"uid":{"c":"g=a6af0b2e-86ae-4d5f-a0d2-2e5d6d71fcb4","e":"2035-11-04T19:37:06.7933933Z"}},"das":"a6af0b2e-86ae-4d5f-a0d2-2e5d6d71fcb4"}}

0 commit comments

Comments
 (0)