fix(tests): Get TLS version from Node instead of hardcoding it (#4700)
This commit is contained in:
parent
bafda9fbe7
commit
a39d553511
@ -39,10 +39,14 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
|
|
||||||
describe('Response.securityDetails', function() {
|
describe('Response.securityDetails', function() {
|
||||||
it('should work', async({page, httpsServer}) => {
|
it('should work', async({page, httpsServer}) => {
|
||||||
const response = await page.goto(httpsServer.EMPTY_PAGE);
|
const [serverRequest, response] = await Promise.all([
|
||||||
|
httpsServer.waitForRequest('/empty.html'),
|
||||||
|
page.goto(httpsServer.EMPTY_PAGE)
|
||||||
|
]);
|
||||||
const securityDetails = response.securityDetails();
|
const securityDetails = response.securityDetails();
|
||||||
expect(securityDetails.issuer()).toBe('puppeteer-tests');
|
expect(securityDetails.issuer()).toBe('puppeteer-tests');
|
||||||
expect(securityDetails.protocol()).toBe('TLS 1.2');
|
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||||
|
expect(securityDetails.protocol()).toBe(protocol);
|
||||||
expect(securityDetails.subjectName()).toBe('puppeteer-tests');
|
expect(securityDetails.subjectName()).toBe('puppeteer-tests');
|
||||||
expect(securityDetails.validFrom()).toBe(1550084863);
|
expect(securityDetails.validFrom()).toBe(1550084863);
|
||||||
expect(securityDetails.validTo()).toBe(33086084863);
|
expect(securityDetails.validTo()).toBe(33086084863);
|
||||||
@ -55,11 +59,15 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
httpsServer.setRedirect('/plzredirect', '/empty.html');
|
httpsServer.setRedirect('/plzredirect', '/empty.html');
|
||||||
const responses = [];
|
const responses = [];
|
||||||
page.on('response', response => responses.push(response));
|
page.on('response', response => responses.push(response));
|
||||||
await page.goto(httpsServer.PREFIX + '/plzredirect');
|
const [serverRequest, ] = await Promise.all([
|
||||||
|
httpsServer.waitForRequest('/plzredirect'),
|
||||||
|
page.goto(httpsServer.PREFIX + '/plzredirect')
|
||||||
|
]);
|
||||||
expect(responses.length).toBe(2);
|
expect(responses.length).toBe(2);
|
||||||
expect(responses[0].status()).toBe(302);
|
expect(responses[0].status()).toBe(302);
|
||||||
const securityDetails = responses[0].securityDetails();
|
const securityDetails = responses[0].securityDetails();
|
||||||
expect(securityDetails.protocol()).toBe('TLS 1.2');
|
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||||
|
expect(securityDetails.protocol()).toBe(protocol);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -288,11 +288,15 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
|||||||
const browser = await puppeteer.connect({browserWSEndpoint, ignoreHTTPSErrors: true});
|
const browser = await puppeteer.connect({browserWSEndpoint, ignoreHTTPSErrors: true});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
let error = null;
|
let error = null;
|
||||||
const response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
|
const [serverRequest, response] = await Promise.all([
|
||||||
|
httpsServer.waitForRequest('/empty.html'),
|
||||||
|
page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e)
|
||||||
|
]);
|
||||||
expect(error).toBe(null);
|
expect(error).toBe(null);
|
||||||
expect(response.ok()).toBe(true);
|
expect(response.ok()).toBe(true);
|
||||||
expect(response.securityDetails()).toBeTruthy();
|
expect(response.securityDetails()).toBeTruthy();
|
||||||
expect(response.securityDetails().protocol()).toBe('TLS 1.2');
|
const protocol = serverRequest.socket.getProtocol().replace('v', ' ');
|
||||||
|
expect(response.securityDetails().protocol()).toBe(protocol);
|
||||||
await page.close();
|
await page.close();
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,6 @@ class TestServer {
|
|||||||
const server = new TestServer(dirPath, port, {
|
const server = new TestServer(dirPath, port, {
|
||||||
key: fs.readFileSync(path.join(__dirname, 'key.pem')),
|
key: fs.readFileSync(path.join(__dirname, 'key.pem')),
|
||||||
cert: fs.readFileSync(path.join(__dirname, 'cert.pem')),
|
cert: fs.readFileSync(path.join(__dirname, 'cert.pem')),
|
||||||
secureProtocol: 'TLSv1_2_method',
|
|
||||||
passphrase: 'aaaa',
|
passphrase: 'aaaa',
|
||||||
});
|
});
|
||||||
await new Promise(x => server._server.once('listening', x));
|
await new Promise(x => server._server.once('listening', x));
|
||||||
|
Loading…
Reference in New Issue
Block a user