Skip to content
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

fix(gatsby): Switching from devcert-san to devcert to fix HTTPS issues #16726

Merged
merged 9 commits into from
Feb 29, 2020
14 changes: 8 additions & 6 deletions packages/gatsby/src/utils/__tests__/get-ssl-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
}
})
jest.mock(`devcert-san`, () => {
jest.mock(`devcert`, () => {
return {
default: jest.fn(),
certificateFor: jest.fn(),
}
})

const devcertSan = require(`devcert-san`).default
const certificateFor = require(`devcert`)
Js-Brecht marked this conversation as resolved.
Show resolved Hide resolved
const reporter = require(`gatsby-cli/lib/reporter`)
const getSslCert = require(`../get-ssl-cert`)

describe(`gets ssl certs`, () => {
beforeEach(() => {
reporter.panic.mockClear()
reporter.info.mockClear()
devcertSan.mockClear()
certificateFor.mockClear()
})
describe(`Custom SSL certificate`, () => {
it.each([[{ certFile: `foo` }], [{ keyFile: `bar` }]])(
Expand Down Expand Up @@ -60,11 +60,13 @@ describe(`gets ssl certs`, () => {
describe(`automatic SSL certificate`, () => {
it(`sets up dev cert`, () => {
getSslCert({ name: `mock-cert` })
expect(devcertSan).toBeCalledWith(`mock-cert`, { installCertutil: true })
expect(certificateFor).toBeCalledWith(`mock-cert`, {
installCertutil: true,
})
expect(reporter.info.mock.calls).toMatchSnapshot()
})
it(`panics if certificate can't be created`, () => {
devcertSan.mockImplementation(() => {
certificateFor.mockImplementation(() => {
throw new Error(`mock error message`)
})
getSslCert({ name: `mock-cert` })
Expand Down