• This repository has been archived on 27/Jul/2019
  • Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple library empowering you to record/capture HTTP(s) traffic of an iOS app for mocking/stubbing later.

Capital One built this project to help our engineers as well as users in the community. We are no longer able to fully support the project. We have archived the project as of Jul 27 2019 where it will be available in a read-only state. Feel free to fork the project and maintain your own version.

SWHttpTrafficRecorder Build Status

SWHttpTrafficRecorder provides an easy way to record all the HTTP(s) traffic in the device’s file system while the user is using your app at the same time. It can be used for different purposes, like testing, replaying the workflow or logging an app's network activity for debugging purposes. See OHHTTPStubs, Nocilla or Mocktail for examples of how the recorded files can be used (this library is inspired while using the above frameworks). This library has been developed solely for testing purposes. We highly recommend against using it in production environment. However, if you choose to include it anyway, there are security considerations that must be taken into account.

Note: if you like this library, please feel free to fork or star it using the buttons on the top of this page.

Setup

Integrating in Your Project

CocoaPods

The recommended way to add SWHttpTrafficRecorder to your project. Add SWHttpTrafficRecorder to your Podfile:

pod 'SWHttpTrafficRecorder'
Carthage

Add this repo to your Cartfile:

github "capitalone/SWHttpTrafficRecorder"
Manual

Or since the library contains only two files (SWHttpTrafficRecorder.h and SWHttpTrafficRecorder.m), you can just drop them anywhere in your project and it is done.

Getting Started

Even though the library is highly customizable, you can get started just by inserting one line of code.

Objective C:
[[SWHttpTrafficRecorder sharedRecorder] startRecording];
Swift:
SWHttpTrafficRecorder.sharedRecorder().startRecording()

Note: NSURLConnection and NSURLSession is supported, including AFNetworking, or any networking framework that use Cocoa's URL Loading System.
To use with NSURLSession based requests, you need to provide the NSURLSessionConfiguration to record, see the method - (BOOL)startRecordingAtPath:(NSString *)recordingPath forSessionConfiguration:(NSURLSessionConfiguration *)sessionConfig error:(NSError **) error.

Features

The library can be used to record the HTTP(s) traffic in 3 commonly used formats: Mocktail, response body only and HTTP(s) Raw Message (the format output by curl -is). In addition, it can be used to monitor the HTTP(s) traffic activity between the client and web service through a progress update delegate. Overall, the library is highly customizable, including the following configurable parameters:

  • recordingFormat: The recording format the recorder is going to use. It can be Mocktail, response body only or HTTP(s) Raw Message.
  • fileNamingBlock: The recorded file name. A file is recorded per each HTTP(s) request and its file name can be customized. By default, it uses a combination of the request's last path component, a time stamp and a number.
  • recordingTestBlock: Whether to record or skip a HTTP(s) request.
  • progressDelegate: An delegate when provided which would receive updates of recording process, including when the HTTP(s) requests are received, loaded and recorded.
  • base64TestBlock: Whether to base64 encode a response body. Only applicable to Mocktail format. By default, only images are base64 encoded.
  • urlRegexPatternBlock: URL matching regular expression. Only applicable to Mocktail format. The default is to use the path and replace query parameter values as .*.
  • replacementDict: A dictionarity containing the information over what data to be replaced by corresponding tokens. Only applicable to Mocktail format. If no value is provided, no replacement would be done.
  • createFileInCustomFormatBlock: Using this parameter to customize the recording in any format that you can implement.

Requirements

The library is tested and working in iOS 7 and above. Older version may work but it is not explicitly tested. It only requires Foundation.framework that is probably included in any iOS project.

You may need the latest developer tools in order to build the demo project and run the tests.

Security Consideration

While creating files for HTTP(s) requests, the recorder uses NSFileProtectionComplete for NSFileProtectionKey attribute to improve the file security. It is a generic library that is designed to record and monitor traffic activity, however, each app may apply its own discretion over what to record and monitor based on its own policy and regulation.

Roadmap

The project is in its early stage. We are intending to apply it to different projects both internally and externally, and fix any issues that are found. In addition, we are going to continue to improve it as the following:

  1. Create a testing suite for regression to make sure future contributions do not break existing functionalities;
  2. Provide more documentation and sample code through wiki page.

If you want to help with any of the above or have any other ideas over how to enhance it or fix a bug, pull requests/new issues/comments/questions are highly welcome.

Contributions

We welcome your interest in Capital One’s Open Source Projects. Any contributor to this project must accept and sign a Capital One Contributor Licensing Agreement (CLA). Except for the license granted in this agreement to Capital One and to recipients of software distributed by Capital One, you reserve all right, title, and interest in and to your contributions; this agreement does not impact your rights to use your own contributions for any other purpose.

Link to CLA

More Repositories

1

DataProfiler

What's in your data? Extract schema, statistics and entities from datasets
Python
1,426
star
2

react-native-pathjs-charts

Android and iOS charts based on react-native-svg and paths-js
JavaScript
878
star
3

datacompy

Pandas, Polars, and Spark DataFrame comparison for humans and more!
Python
480
star
4

cqrs-manager-for-distributed-reactive-services

Experimental CQRS and Event Sourcing service
Java
304
star
5

fpe

A format-preserving encryption implementation in Go
Go
202
star
6

rubicon-ml

Capture all information throughout your model's development in a reproducible way and tie results directly to the model code!
Jupyter Notebook
127
star
7

giraffez

User-friendly Teradata client for Python
Python
108
star
8

locopy

locopy: Loading/Unloading to Redshift and Snowflake using Python.
Python
104
star
9

checks-out

Checks-Out pull request approval system
Go
76
star
10

dataCompareR

dataCompareR is an R package that allows users to compare two datasets and view a report on the similarities and differences.
R
75
star
11

stack-deployment-tool

Go
66
star
12

bash_shell_mock

A shell script mocking utility/framework for the BASH shell
Shell
66
star
13

architecture-viewer

Visualize your PlantUML sequence diagrams as interactive architecture diagrams!
JavaScript
60
star
14

go-future-context

A simple Future (Promise) library for Go.
Go
54
star
15

AI_Dictionary_English_Spanish

TeX
49
star
16

acronym-decoder

Acronym Decoder
TypeScript
43
star
17

synthetic-data

Generating complex, nonlinear datasets appropriate for use with deep learning/black box models which 'need' nonlinearity

Python
43
star
18

Particle-Cloud-Framework

Python
36
star
19

slackbot-destroyer

📣 ❌ Slack integration that can destroy all incoming messages from Slackbot.
Python
34
star
20

global-attribution-mapping

GAM (Global Attribution Mapping) explains the landscape of neural network predictions across subpopulations
Python
33
star
21

federated-model-aggregation

The Federated Model Aggregation (FMA) Service is a collection of installable python components that make up the generic workflow/infrastructure needed for federated learning.
Python
30
star
22

oas-nodegen

A library for generating completely customizable code from the Open API Specification (FKA Swagger) RESTful API documentation using the scripting power of Node.js.
JavaScript
28
star
23

easy-screenshots

Android Instrumentation Test Screenshots made Easy.
Java
21
star
24

edgetest

edgetest is a tox-inspired python library that will loop through your project's dependencies, and check if your project is compatible with the latest version of each dependency
Python
19
star
25

ablation

Evaluating XAI methods through ablation studies.
Python
15
star
26

serverless-shell

⚡️🐚 Serverless Shell with environment variables plugin
JavaScript
14
star
27

OAuthClient

Awesome OAuth Client for Java.
Java
13
star
28

otvPlots

ovtPlots: An R Package for Variable Level Monitoring
R
13
star
29

json-syntax

Generates functions to convert Python classes to and from JSON friendly objects.
Python
12
star
30

screen-object

screen-object (ruby gem for mobile app automation)
Ruby
12
star
31

jwt-security

JavaScript
11
star
32

BankAccountStarter-API-reference-app

CSS
10
star
33

CreditOffers-API-reference-app

JavaScript
10
star
34

Rewards-API-reference-app

JavaScript
10
star
35

local-crontab

🗺️⏰ Convert local crontabs to UTC crontabs
JavaScript
8
star
36

modtracker

JSON unmarshaling in Go that includes detection of modified fields
Go
7
star
37

grpc-cucumber-js

JavaScript
7
star
38

edgetest-hub

hub plugin for edgetest
Python
2
star
39

oas-nodegen-example

Example project that shows how to customize generated code to fit a specific design pattern using oas-nodegen
Java
2
star
40

edgetest-conda

Conda plugin for edgetest
Python
1
star
41

edgetest-pip-tools

pip-tools plugin for edgetest
Python
1
star