-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: bail if encounter insecure ssl cert, to avoid hanging forever #6300
Changes from all commits
104e399
2eafa44
8790ebd
089147a
b2d7c42
e7c463d
25a9853
9f14eff
3a3015c
bb2ce13
ef5ac10
f3bb0bd
157e84a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,6 +321,7 @@ describe('GatherRunner', function() { | |
clearDataForOrigin: createCheck('calledClearStorage'), | ||
blockUrlPatterns: asyncFunc, | ||
setExtraHTTPHeaders: asyncFunc, | ||
listenForSecurityStateChanges: asyncFunc, | ||
}; | ||
|
||
return GatherRunner.setupDriver(driver, {settings: {}}).then(_ => { | ||
|
@@ -379,6 +380,7 @@ describe('GatherRunner', function() { | |
clearDataForOrigin: createCheck('calledClearStorage'), | ||
blockUrlPatterns: asyncFunc, | ||
setExtraHTTPHeaders: asyncFunc, | ||
listenForSecurityStateChanges: asyncFunc, | ||
}; | ||
|
||
return GatherRunner.setupDriver(driver, { | ||
|
@@ -543,9 +545,9 @@ describe('GatherRunner', function() { | |
], | ||
}; | ||
|
||
return GatherRunner.afterPass({url, driver, passConfig}, {TestGatherer: []}).then(vals => { | ||
return GatherRunner.afterPass({url, driver, passConfig}, {TestGatherer: []}).then(passData => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok to revert these lines now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
assert.equal(calledDevtoolsLogCollect, true); | ||
assert.strictEqual(vals.devtoolsLog[0], fakeDevtoolsMessage); | ||
assert.strictEqual(passData.devtoolsLog[0], fakeDevtoolsMessage); | ||
}); | ||
}); | ||
|
||
|
@@ -647,6 +649,7 @@ describe('GatherRunner', function() { | |
mainRecord.localizedFailDescription = 'foobar'; | ||
const error = GatherRunner.getPageLoadError(url, [mainRecord]); | ||
assert.equal(error.message, 'FAILED_DOCUMENT_REQUEST'); | ||
assert.equal(error.code, 'FAILED_DOCUMENT_REQUEST'); | ||
assert.ok(/^Lighthouse was unable to reliably load/.test(error.friendlyMessage)); | ||
}); | ||
|
||
|
@@ -655,6 +658,7 @@ describe('GatherRunner', function() { | |
const records = []; | ||
const error = GatherRunner.getPageLoadError(url, records); | ||
assert.equal(error.message, 'NO_DOCUMENT_REQUEST'); | ||
assert.equal(error.code, 'NO_DOCUMENT_REQUEST'); | ||
assert.ok(/^Lighthouse was unable to reliably load/.test(error.friendlyMessage)); | ||
}); | ||
|
||
|
@@ -665,6 +669,7 @@ describe('GatherRunner', function() { | |
mainRecord.statusCode = 404; | ||
const error = GatherRunner.getPageLoadError(url, [mainRecord]); | ||
assert.equal(error.message, 'ERRORED_DOCUMENT_REQUEST'); | ||
assert.equal(error.code, 'ERRORED_DOCUMENT_REQUEST'); | ||
assert.ok(/^Lighthouse was unable to reliably load/.test(error.friendlyMessage)); | ||
}); | ||
|
||
|
@@ -675,10 +680,49 @@ describe('GatherRunner', function() { | |
mainRecord.statusCode = 500; | ||
const error = GatherRunner.getPageLoadError(url, [mainRecord]); | ||
assert.equal(error.message, 'ERRORED_DOCUMENT_REQUEST'); | ||
assert.equal(error.code, 'ERRORED_DOCUMENT_REQUEST'); | ||
assert.ok(/^Lighthouse was unable to reliably load/.test(error.friendlyMessage)); | ||
}); | ||
}); | ||
|
||
describe('#assertNoSecurityIssues', () => { | ||
it('succeeds when page is secure', () => { | ||
const secureSecurityState = { | ||
securityState: 'secure', | ||
}; | ||
GatherRunner.assertNoSecurityIssues(secureSecurityState); | ||
}); | ||
|
||
it('fails when page is insecure', () => { | ||
const insecureSecurityState = { | ||
explanations: [ | ||
{ | ||
description: 'reason 1.', | ||
securityState: 'insecure', | ||
}, | ||
{ | ||
description: 'blah.', | ||
securityState: 'info', | ||
}, | ||
{ | ||
description: 'reason 2.', | ||
securityState: 'insecure', | ||
}, | ||
], | ||
securityState: 'insecure', | ||
}; | ||
try { | ||
GatherRunner.assertNoSecurityIssues(insecureSecurityState); | ||
assert.fail('expected INSECURE_DOCUMENT_REQUEST LHError'); | ||
} catch (err) { | ||
assert.equal(err.message, 'INSECURE_DOCUMENT_REQUEST'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Some other tests were just testing |
||
assert.equal(err.code, 'INSECURE_DOCUMENT_REQUEST'); | ||
/* eslint-disable-next-line max-len */ | ||
assert.equal(err.friendlyMessage, 'The URL you have provided does not have valid security credentials. reason 1. reason 2.'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('artifact collection', () => { | ||
// Make sure our gatherers never execute in parallel | ||
it('runs gatherer lifecycle methods strictly in sequence', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing it this way, I guess we'll find out if there are issues with listening through the whole page load :)
But it does nicely pave the way for bailing earlier if we want to do that.