-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
feat(utils): support multiple certificates in resolveServerUrls #20707
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
base: main
Are you sure you want to change the base?
Conversation
test('should handle IPv4 multiple certificates', () => { | ||
const mockServer = createMockServer() | ||
const { options, hostname, config } = createTestConfig() | ||
const httpsOptions = { cert: [createWorkingCert] } | ||
|
||
const result = resolveServerUrls( | ||
mockServer, | ||
options, | ||
hostname, | ||
httpsOptions, | ||
config, | ||
) | ||
|
||
expect(result.local).toContain('https://localhost:3000/') | ||
expect(result.local).toContain('https://foo.localhost:3000/') | ||
expect(result.local).toContain('https://vite.vite.localhost:3000/') | ||
}) |
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.
The test name "should handle IPv4 multiple certificates" doesn't match the implementation, which only tests a single certificate wrapped in an array. For a proper multiple certificate test, consider using an array with at least two certificates:
const httpsOptions = { cert: [createWorkingCert, createAnotherCert] }
This would verify that the code correctly processes multiple certificates and extracts hostnames from all of them.
test('should handle IPv4 multiple certificates', () => { | |
const mockServer = createMockServer() | |
const { options, hostname, config } = createTestConfig() | |
const httpsOptions = { cert: [createWorkingCert] } | |
const result = resolveServerUrls( | |
mockServer, | |
options, | |
hostname, | |
httpsOptions, | |
config, | |
) | |
expect(result.local).toContain('https://localhost:3000/') | |
expect(result.local).toContain('https://foo.localhost:3000/') | |
expect(result.local).toContain('https://vite.vite.localhost:3000/') | |
}) | |
test('should handle IPv4 multiple certificates', () => { | |
const mockServer = createMockServer() | |
const { options, hostname, config } = createTestConfig() | |
const httpsOptions = { cert: [createWorkingCert, createAnotherCert] } | |
const result = resolveServerUrls( | |
mockServer, | |
options, | |
hostname, | |
httpsOptions, | |
config, | |
) | |
expect(result.local).toContain('https://localhost:3000/') | |
expect(result.local).toContain('https://foo.localhost:3000/') | |
expect(result.local).toContain('https://vite.vite.localhost:3000/') | |
expect(result.local).toContain('https://another.cert.localhost:3000/') | |
}) | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Sorry for the confusion in the test cases. Any feedback on the certificate or implementation setup would be welcome. |
Description
Fixes #20681
Added support for multiple certificates in the resolveServerUrls function. Previously, only single certificates were supported, limiting HTTPS server configuration options.
All tests pass (unit, integration, and build tests all pass locally)
Test Coverage Added
Note: Some test parameters use
any
types due to complex interface typing challenges. Type improvements are welcome.