ProxyHelper

ProxyHelper

mitmproxy helper functions.

mitmproxy writes to a file in realtime, so you can just check the file whenever you want.

Constructor

new ProxyHelper()

Source:

Members

getLogs

Source:

Retrieves and parses the network request logs captured by mitmproxy.

Example
// Define this variable outside the tests to allow us to split the assertions and the retrieval itself into different steps.
let proxyLogs

describe('FINISH - retrieve, validate, and check the proxy logs for for the run', async function () {
  it('should fetch network logs (from mitmproxy in the Docker container)', function () {
    // this helper returns a promise which resolves into the proxy output for the run
    proxyLogs = await proxyHelper.getLogs()
  })

  // now you have an instance of ProxyLogs
  it('should have the expected properties on the returned ProxyLogs object', async function () {
    // logs
    chai.expect(proxyLogs.logs).to.be.an('object').with.property('allSteps').that.is.an('array').with.length.greaterThan(0)
    chai.expect(proxyLogs.logs).to.be.an('object').with.property('step1').that.is.an('array').with.length.greaterThan(0)

    // raw logs
    chai.expect(proxyLogs.rawLogs).to.be.an('object').with.property('allSteps').that.is.an('array').with.length.greaterThan(0)
    chai.expect(proxyLogs.rawLogs).to.be.an('object').with.property('step1').that.is.an('array').with.length.greaterThan(0)

    // steps
    chai.expect(proxyLogs.steps).to.be.an('object').with.property('stepsSoFar').that.is.a('number').greaterThan(0)
    chai.expect(proxyLogs.steps).to.be.an('object').with.property('stepInfo').that.is.an('object').with.property('1').that.is.an('object').with.keys(['name', 'start', 'end'])

    // getFilteredLogs function
    chai.expect(proxyLogs.getFilteredLogs).to.be.an('function')
  })

  it('should find a single TiQ session counter, in the first step', async function () {
    chai.expect(proxyLogs.getFilteredLogs('/utag.v.js?').allSteps).to.have.lengthOf(1)
    chai.expect(proxyLogs.getFilteredLogs('/utag.v.js?').step1).to.have.lengthOf(1)
  })
})