Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ jobs:
- name: Build project
run: npm run build

- name: Generate self-signed certificates
run: npm run certs
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
shell: bash

- name: Prepare tests
run: npm run test:init
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
Expand Down Expand Up @@ -192,11 +187,6 @@ jobs:
- name: Build project
run: npm run build

- name: Generate self-signed certificates
run: npm run certs
if: '${{!steps.release-check.outputs.IS_RELEASE}}'
shell: bash

- name: Prepare tests
run: npm run test:init
if: '${{ !steps.release-check.outputs.IS_RELEASE }}'
Expand Down
8 changes: 0 additions & 8 deletions certconf

This file was deleted.

23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"scripts": {
"_format": "prettier --loglevel=warn \"{src,tools,scripts,tests,.github}/**/*.{mjs,cjs,js,mts,md,yml,json,html,ts}\" \"*.{mjs,cjs,js,mts,yml,json,html,ts}\" \".*.{mjs,cjs,js,yml,json,html,ts}\" \"!CHANGELOG.md\" \"!**/*/package-lock.json\" \"!.github/**/*.md\"",
"build": "tsc --project tsconfig.build.json",
"certs": "openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj \"/CN=localhost\" -extensions EXT -config certconf",
"clean": "rm -rf dist/",
"dev": "tsc --project tsconfig.build.json --watch",
"docs": "npm run --prefix=site build",
Expand All @@ -44,7 +43,7 @@
"test": "npm run test:dev",
"lint": "eslint --cache \"{src,scripts,tests,.github}/**/*.{mjs,cjs,js,md,html}\" \"*.{mjs,cjs,js,md,html}\"",
"lint:fix": "npm run lint --fix",
"test:dev": "run-s certs test:init:* test:dev:*",
"test:dev": "run-s test:init:* test:dev:*",
"test:dev:vitest": "vitest run tests/unit/ && vitest run tests/integration",
"test:init": "run-s test:init:*",
"test:init:cli-help": "npm run start -- --help",
Expand Down Expand Up @@ -202,6 +201,7 @@
"@vitest/eslint-plugin": "^1.1.36",
"c8": "10.1.3",
"cheerio": "1.0.0",
"dedent": "^1.5.3",
"eslint": "^9.21.0",
"eslint-config-prettier": "^10.0.2",
"eslint-plugin-n": "^17.16.1",
Expand Down
62 changes: 55 additions & 7 deletions tests/integration/commands/dev/dev.zisi.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Handlers are meant to be async outside tests
import { Buffer } from 'buffer'
import fs, { copyFile } from 'fs/promises'
import { Buffer } from 'node:buffer'
import fs from 'node:fs/promises'
import { Agent } from 'node:https'
import os from 'os'
import path from 'path'
import { fileURLToPath } from 'url'
import os from 'node:os'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import type { HandlerEvent } from '@netlify/functions'
import { describe, test } from 'vitest'
import nodeFetch from 'node-fetch'
import execa from 'execa'
import dedent from 'dedent'

import { curl } from '../../utils/curl.js'
import { withDevServer } from '../../utils/dev-server.js'
Expand All @@ -19,6 +21,51 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))

const testMatrix = [{ args: [] }]

const generateSSLCertificate = async () => {
const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), 'certs-'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️ you look like someone who would enjoy removing the tempy dev dep :grindog:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev deps are free!


await fs.writeFile(
path.join(tmpdir, 'certconf'),
dedent`
[dn]
CN=localhost
[req]
distinguished_name = dn
[EXT]
subjectAltName=DNS:localhost
keyUsage=digitalSignature
extendedKeyUsage=serverAuth
`,
)
await execa(
'openssl',
[
'req',
'-x509',
'-out',
'localhost.crt',
'-keyout',
'localhost.key',
'-newkey',
'rsa:2048',
'-nodes',
'-sha256',
'-subj',
'/CN=localhost',
'-extensions',
'EXT',
'-config',
'certconf',
],
{ cwd: tmpdir },
)

return {
cert: path.join(tmpdir, 'localhost.crt'),
key: path.join(tmpdir, 'localhost.key'),
}
}

describe.concurrent.each(testMatrix)('withSiteBuilder with args: $args', ({ args }) => {
test('should handle query params in redirects', async (t) => {
await withSiteBuilder(t, async (builder) => {
Expand Down Expand Up @@ -257,9 +304,10 @@ export const handler = async function () {
})
.build()

const certificatePaths = await generateSSLCertificate()
await Promise.all([
copyFile(path.join(__dirname, '../../../../localhost.crt'), path.join(builder.directory, 'localhost.crt')),
copyFile(path.join(__dirname, '../../../../localhost.key'), path.join(builder.directory, 'localhost.key')),
fs.copyFile(certificatePaths.cert, path.join(builder.directory, 'localhost.crt')),
fs.copyFile(certificatePaths.key, path.join(builder.directory, 'localhost.key')),
])
await withDevServer({ cwd: builder.directory, args }, async ({ port }) => {
const options = {
Expand Down
Loading