How to use the mockttp.generateCACertificate function in mockttp

To help you get started, we’ve selected a few mockttp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opticdev / optic / api-cli / src / lib / TransparentProxyCaptureSession.ts View on Github external
async start(config: ITransparentProxyCaptureSessionConfig) {
    this.config = config
    const configPath = tmp.dirSync({ unsafeCleanup: true }).name
    const certificateInfo = await mockttp.generateCACertificate({
      bits: 2048,
      commonName: 'Optic Labs Corp'
    })
    const certificatePath = path.join(configPath, '.optic', 'certificates')
    await fs.ensureDir(certificatePath);
    const certPath = path.join(certificatePath, 'ca.cert')
    const keyPath = path.join(certificatePath, 'ca.key')
    await fs.writeFile(certPath, certificateInfo.cert)
    await fs.writeFile(keyPath, certificateInfo.key)
    const https = {
      certPath,
      keyPath
    }

    const proxy = mockttp.getLocal({
      cors: true,
github opticdev / optic / api-cli / src / commands / intercept.ts View on Github external
async start(config: IHttpToolkitProxyCaptureSessionConfig) {
    this.config = config
    const configPath = tmp.dirSync({unsafeCleanup: true}).name
    const certificateInfo = await mockttp.generateCACertificate({
      bits: 2048,
      commonName: 'Optic Labs Corp'
    })
    const certificatePath = path.join(configPath, '.optic', 'certificates')
    await fs.ensureDir(certificatePath)
    const certPath = path.join(certificatePath, 'ca.cert')
    const keyPath = path.join(certificatePath, 'ca.key')
    await fs.writeFile(certPath, certificateInfo.cert)
    await fs.writeFile(keyPath, certificateInfo.key)
    const https = {
      certPath,
      keyPath
    }

    const proxy = mockttp.getLocal({
      cors: true,

mockttp

Mock HTTP server for testing HTTP clients and stubbing webservices

Apache-2.0
Latest version published 18 days ago

Package Health Score

80 / 100
Full package analysis