You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-2Lines changed: 66 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,9 +197,67 @@ Each captured flow includes the method, URL, headers, and parsed JSON request/re
197
197
198
198
---
199
199
200
-
## 🙌 Contributions
200
+
## 📚 Use Cases
201
+
202
+
### ✅ Automated Network Testing for Android & iOS
201
203
202
-
Feel free to extend this tool with more proxy automation, better cert handling, or a simple UI for the control endpoints.
204
+
You can integrate `mitmproxy` recording into your mobile test lifecycle to verify network behavior during test execution.
205
+
206
+
---
207
+
208
+
### 🔁 Example Flow:
209
+
210
+
1.**Start mitmproxy with the addon** (before your test suite):
211
+
212
+
```bash
213
+
mitmdump -p 8080 -s proxy-session-controller.py
214
+
```
215
+
216
+
2.**Start recording flows** (before your test begins):
217
+
218
+
```bash
219
+
curl http://localhost:9999/start_recording
220
+
```
221
+
222
+
3.**Run your UI/E2E test** that performs network requests from the Android emulator or iOS simulator.
223
+
224
+
4.**Stop recording after the test is finished**:
225
+
226
+
```bash
227
+
curl http://localhost:9999/stop_recording
228
+
```
229
+
230
+
5.**Validate the output** in `flows.json` using a custom validation script.
231
+
232
+
---
233
+
234
+
### 🧪 Example: Test Validation Script (Python)
235
+
236
+
```python
237
+
import json
238
+
239
+
withopen("flows.json") as f:
240
+
flows = json.load(f)
241
+
242
+
expected_url ="https://api.example.com/data"
243
+
matched =any(flow["request"]["url"] == expected_url for flow in flows)
244
+
245
+
assert matched, f"Expected request to {expected_url} not found!"
246
+
print("[✓] Network request verified.")
247
+
```
248
+
249
+
---
250
+
251
+
### 💡 Use With Your Test Framework
252
+
253
+
In your test framework (e.g., XCTest for iOS, Espresso or UIAutomator for Android), you can:
254
+
255
+
- Trigger `/start_recording` in the test setup phase
256
+
- Run the UI interaction
257
+
- Trigger `/stop_recording` in the test teardown
258
+
- Run a validation script after the test completes
259
+
260
+
This allows you to **assert that expected network calls were made**, validate request payloads, and check response data without needing to modify your app code.
203
261
204
262
---
205
263
@@ -219,3 +277,9 @@ networksetup -listallnetworkservices | tail +2 | while read -r interface; do
219
277
networksetup -setsecurewebproxystate "$interface" off
220
278
done
221
279
```
280
+
281
+
---
282
+
283
+
## 🙌 Contributions
284
+
285
+
Feel free to extend this tool with more proxy automation, better cert handling, or a simple UI for the control endpoints.
0 commit comments