Skip to content

Commit

Permalink
Merge branch 'develop' into elevatebart/remove-safelist
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart committed Jun 21, 2022
2 parents 92c32db + 152e828 commit 38c10ae
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 4 deletions.
5 changes: 2 additions & 3 deletions circle.yml
Expand Up @@ -27,8 +27,7 @@ mainBuildFilters: &mainBuildFilters
branches:
only:
- develop
- 10.0-release
- linux-arm64
- issue-22147-nohoist

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand Down Expand Up @@ -129,7 +128,7 @@ commands:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "linux-arm64" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "issue-22147-nohoist" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down
10 changes: 9 additions & 1 deletion cli/lib/exec/spawn.js
Expand Up @@ -30,7 +30,15 @@ const isRenderWorkerRe = /\.RenderWorker-/
// https://github.com/cypress-io/cypress/issues/19299
const isDbusWarning = /Failed to connect to the bus:/

const GARBAGE_WARNINGS = [isXlibOrLibudevRe, isHighSierraWarningRe, isRenderWorkerRe, isDbusWarning]
// Electron began logging these on self-signed certs with 17.0.0-alpha.4.
// Once this is fixed upstream this regex can be removed: https://github.com/electron/electron/issues/34583
// Sample:
// [3801:0606/152837.383892:ERROR:cert_verify_proc_builtin.cc(681)] CertVerifyProcBuiltin for www.googletagmanager.com failed:
// ----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,CN=www.googletagmanager.com) -----
// ERROR: No matching issuer found
const isCertVerifyProcBuiltin = /(^\[.*ERROR:cert_verify_proc_builtin\.cc|^----- Certificate i=0 \(OU=Cypress Proxy|^ERROR: No matching issuer found$)/

const GARBAGE_WARNINGS = [isXlibOrLibudevRe, isHighSierraWarningRe, isRenderWorkerRe, isDbusWarning, isCertVerifyProcBuiltin]

const isGarbageLineWarning = (str) => {
return _.some(GARBAGE_WARNINGS, (re) => {
Expand Down
1 change: 1 addition & 0 deletions cli/scripts/build.js
Expand Up @@ -31,6 +31,7 @@ function preparePackageForNpmRelease (json) {
delete json['private']
// no need to include "nyc" code coverage settings
delete json.nyc
delete json.workspaces

_.extend(json, {
version,
Expand Down
4 changes: 4 additions & 0 deletions cli/test/lib/exec/spawn_spec.js
Expand Up @@ -71,6 +71,10 @@ describe('lib/exec/spawn', function () {
[1957:0406/160550.146820:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1957:0406/160550.147994:ERROR:bus.cc(392)] Failed to connect to the bus: Address does not contain a colon
[3801:0606/152837.383892:ERROR:cert_verify_proc_builtin.cc(681)] CertVerifyProcBuiltin for www.googletagmanager.com failed:
----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,CN=www.googletagmanager.com) -----
ERROR: No matching issuer found
`

const lines = _
Expand Down
6 changes: 6 additions & 0 deletions packages/proxy/lib/http/response-middleware.ts
Expand Up @@ -509,6 +509,12 @@ const MaybeSendRedirectToClient: ResponseMiddleware = function () {

const CopyResponseStatusCode: ResponseMiddleware = function () {
this.res.status(Number(this.incomingRes.statusCode))
// Set custom status message/reason phrase from http response
// https://github.com/cypress-io/cypress/issues/16973
if (this.incomingRes.statusMessage) {
this.res.statusMessage = this.incomingRes.statusMessage
}

this.next()
}

Expand Down
59 changes: 59 additions & 0 deletions packages/server/test/integration/http_requests_spec.js
Expand Up @@ -3783,6 +3783,65 @@ describe('Routes', () => {
})
})

// Set custom status message/reason phrase from http response
// https://github.com/cypress-io/cypress/issues/16973
it('set custom status message when reason phrase is set', function () {
nock(this.server.remoteStates.current().origin)
.post('/companies/validate', {
payload: { name: 'Brian' },
})
.reply(400, function (uri, requestBody) {
this.req.response.statusMessage = 'This is the custom status message'

return {
status: 400,
message: 'This is the reply body',
}
})

return this.rp({
method: 'POST',
url: 'http://localhost:8000/companies/validate',
json: true,
body: {
payload: { name: 'Brian' },
},
headers: {
'x-cypress-status': '400',
},
})
.then((res) => {
expect(res.statusCode).to.eq(400)
expect(res.statusMessage).to.eq('This is the custom status message')
})
})

// use default status message/reason phrase correspond to status code, from http response
// https://github.com/cypress-io/cypress/issues/16973
it('uses default status message when reason phrase is not set', function () {
nock(this.server.remoteStates.current().origin)
.post('/companies/validate', {
payload: { name: 'Brian' },
})
.reply(400)

return this.rp({
method: 'POST',
url: 'http://localhost:8000/companies/validate',
json: true,
body: {
payload: { name: 'Brian' },
},
headers: {
'x-cypress-status': '400',
},
})
.then((res) => {
expect(res.statusCode).to.eq(400)
expect(res.statusMessage).to.eq('Bad Request')
})
})

it('hands back 201 status codes', function () {
nock(this.server.remoteStates.current().origin)
.post('/companies/validate', {
Expand Down

0 comments on commit 38c10ae

Please sign in to comment.