Skip to content

Commit

Permalink
feat: enable crypto calls in protocol to enable hashing response bodi…
Browse files Browse the repository at this point in the history
…es (#26829)
  • Loading branch information
ryanthemanuel authored May 23, 2023
1 parent 20b5bb0 commit bd5a4d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/server/lib/cloud/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import os from 'os'
import { createGzip } from 'zlib'
import fetch from 'cross-fetch'
import { performance } from 'perf_hooks'
import crypto from 'crypto'

const routes = require('./routes')
const pkg = require('@packages/root')
Expand Down Expand Up @@ -46,6 +47,9 @@ export class ProtocolManager implements ProtocolManagerShape {
now: performance.now,
timeOrigin: performance.timeOrigin,
},
createHash: (text) => {
return crypto.createHash('md5').update(text).digest('hex')
},
},
})

Expand Down Expand Up @@ -78,6 +82,7 @@ export class ProtocolManager implements ProtocolManagerShape {
if (CAPTURE_ERRORS) {
this._errors.push({ captureMethod: 'cdpClient.on', error, args: [event, message] })
} else {
debug('error in cdpClient.on %O', { error, event, message })
throw error
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ declare const performance: {
now(): number
timeOrigin: number
}
declare const createHash: {
(text: string): string
}

export class AppCaptureProtocol implements ProtocolManagerShape {
private Debug: typeof Debug
private performance: typeof performance
private createHash: typeof createHash

constructor () {
this.Debug = Debug
this.performance = performance
this.createHash = createHash
}

setupProtocol = (script, runId) => {
Expand Down
1 change: 1 addition & 0 deletions packages/server/test/unit/cloud/protocol_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('lib/cloud/protocol', () => {
expect((protocol as any).performance).not.to.be.undefined
expect((protocol as any).performance.now).not.to.be.undefined
expect((protocol as any).performance.timeOrigin).not.to.be.undefined
expect((protocol as any).createHash).not.to.be.undefined
})

it('should be able to connect to the browser', async () => {
Expand Down
5 changes: 5 additions & 0 deletions system-tests/lib/protocolStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ declare const performance: {
now(): number
timeOrigin: number
}
declare const createHash: {
(text: string): string
}

export class AppCaptureProtocol implements ProtocolManagerShape {
private Debug: typeof Debug
private performance: typeof performance
private createHash: typeof createHash

constructor () {
this.Debug = Debug
this.performance = performance
this.createHash = createHash
}

setupProtocol = (script, runId) => {
Expand Down

5 comments on commit bd5a4d0

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bd5a4d0 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.13.0/linux-arm64/feat/protocol-bd5a4d02ee4ba154ae3b94c8ab65611947b74bed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bd5a4d0 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.13.0/linux-x64/feat/protocol-bd5a4d02ee4ba154ae3b94c8ab65611947b74bed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bd5a4d0 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.13.0/darwin-arm64/feat/protocol-bd5a4d02ee4ba154ae3b94c8ab65611947b74bed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bd5a4d0 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.13.0/darwin-x64/feat/protocol-bd5a4d02ee4ba154ae3b94c8ab65611947b74bed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bd5a4d0 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.13.0/win32-x64/feat/protocol-bd5a4d02ee4ba154ae3b94c8ab65611947b74bed/cypress.tgz

Please sign in to comment.