ci: fix setCertificateVerifyProc tests (#30799)

This commit is contained in:
Jeremy Rose 2021-09-01 15:58:29 -07:00 committed by GitHub
parent fd8eb3de1b
commit 8d86d84ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -559,8 +559,8 @@ describe('session module', () => {
const ses = session.fromPartition(`${Math.random()}`); const ses = session.fromPartition(`${Math.random()}`);
let validate: () => void; let validate: () => void;
ses.setCertificateVerifyProc(({ hostname, verificationResult, errorCode }, callback) => { ses.setCertificateVerifyProc(({ hostname, verificationResult, errorCode }, callback) => {
if (hostname !== '127.0.0.1') return callback(-3);
validate = () => { validate = () => {
expect(hostname).to.equal('127.0.0.1');
expect(verificationResult).to.be.oneOf(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID']); expect(verificationResult).to.be.oneOf(['net::ERR_CERT_AUTHORITY_INVALID', 'net::ERR_CERT_COMMON_NAME_INVALID']);
expect(errorCode).to.be.oneOf([-202, -200]); expect(errorCode).to.be.oneOf([-202, -200]);
}; };
@ -578,8 +578,8 @@ describe('session module', () => {
const ses = session.fromPartition(`${Math.random()}`); const ses = session.fromPartition(`${Math.random()}`);
let validate: () => void; let validate: () => void;
ses.setCertificateVerifyProc(({ hostname, certificate, verificationResult, isIssuedByKnownRoot }, callback) => { ses.setCertificateVerifyProc(({ hostname, certificate, verificationResult, isIssuedByKnownRoot }, callback) => {
if (hostname !== '127.0.0.1') return callback(-3);
validate = () => { validate = () => {
expect(hostname).to.equal('127.0.0.1');
expect(certificate.issuerName).to.equal('Intermediate CA'); expect(certificate.issuerName).to.equal('Intermediate CA');
expect(certificate.subjectName).to.equal('localhost'); expect(certificate.subjectName).to.equal('localhost');
expect(certificate.issuer.commonName).to.equal('Intermediate CA'); expect(certificate.issuer.commonName).to.equal('Intermediate CA');
@ -607,6 +607,7 @@ describe('session module', () => {
const ses = session.fromPartition(`${Math.random()}`); const ses = session.fromPartition(`${Math.random()}`);
let numVerificationRequests = 0; let numVerificationRequests = 0;
ses.setCertificateVerifyProc((e, callback) => { ses.setCertificateVerifyProc((e, callback) => {
if (e.hostname !== '127.0.0.1') return callback(-3);
numVerificationRequests++; numVerificationRequests++;
callback(-2); callback(-2);
}); });