Repository navigation
fix(@angular/build): resolve dev-server sslKey and sslCert relative to the workspace root
#34399
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
Open
MeAkib
wants to merge
4
commits into
angular:main
Choose a base branch
from
MeAkib:fix/dev-server-ssl-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e6056d3
fix(@angular/build): resolve dev-server `sslKey` and `sslCert` relati…
MeAkib a41acae
fixup! fix(@angular/build): resolve dev-server `sslKey` and `sslCert`…
MeAkib 08e9727
fixup! fix(@angular/build): resolve dev-server `sslKey` and `sslCert`…
MeAkib 83c6edd
fixup! fix(@angular/build): resolve dev-server `sslKey` and `sslCert`…
MeAkib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/angular/build/src/builders/dev-server/tests/options/ssl_spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| import assert from 'node:assert'; | ||
| import { mkdtemp, writeFile } from 'node:fs/promises'; | ||
| import { join } from 'node:path'; | ||
| import { executeDevServer } from '../../index'; | ||
| import { describeServeBuilder } from '../jasmine-helpers'; | ||
| import { BASE_OPTIONS, DEV_SERVER_BUILDER_INFO } from '../setup'; | ||
|
|
||
| const SSL_KEY = `-----BEGIN PRIVATE KEY----- | ||
| MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgEpythQjrJo9bm8GM | ||
| LFacGutCqc/XxDZ3dDkSMYZYZ2ehRANCAARvwtZ3OwP1uLhrcLp7nemvaWqkA+FN | ||
| NDjOA3OZKhyVHYog1jNTawJJjwk66upbXGFL8622yU1INWbZFxvrSANl | ||
| -----END PRIVATE KEY----- | ||
| `; | ||
|
|
||
| const SSL_CERT = `-----BEGIN CERTIFICATE----- | ||
| MIIBfzCCASWgAwIBAgIUUoRhwzxAE3y5nrOW8de+cJEIVvQwCgYIKoZIzj0EAwIw | ||
| FDESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTI2MTAxOTA4NTUyNVoYDzIxMjYwOTI1 | ||
| MDg1NTI1WjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjO | ||
| PQMBBwNCAARvwtZ3OwP1uLhrcLp7nemvaWqkA+FNNDjOA3OZKhyVHYog1jNTawJJ | ||
| jwk66upbXGFL8622yU1INWbZFxvrSANlo1MwUTAdBgNVHQ4EFgQUWyqB1QeFcs6L | ||
| LL7Utsybm6+XFvIwHwYDVR0jBBgwFoAUWyqB1QeFcs6LLL7Utsybm6+XFvIwDwYD | ||
| VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiBazry25W+Qewb/WzadhmdY | ||
| YDGdshNZCk0g0DI3ctNjlgIhAKm2X8pmqdkM38Yh8QDN0cHBsAcDfRYffDnjJ3tP | ||
| dpnU | ||
| -----END CERTIFICATE----- | ||
| `; | ||
|
|
||
| describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupTarget) => { | ||
| describe('option: "ssl"', () => { | ||
| beforeEach(async () => { | ||
| setupTarget(harness); | ||
|
|
||
| // Application code is not needed for these tests | ||
| await harness.writeFile('src/main.ts', ''); | ||
| }); | ||
|
|
||
| it('resolves "sslKey" and "sslCert" relative to the workspace root', async () => { | ||
| await harness.writeFile('ssl/server.key', SSL_KEY); | ||
| await harness.writeFile('ssl/server.crt', SSL_CERT); | ||
|
|
||
| harness.useTarget('serve', { | ||
| ...BASE_OPTIONS, | ||
| ssl: true, | ||
| sslKey: 'ssl/server.key', | ||
| sslCert: 'ssl/server.crt', | ||
| }); | ||
|
|
||
| const { result } = await harness.executeOnce(); | ||
|
|
||
| expect(result?.success).toBeTrue(); | ||
| expect(result?.baseUrl).toMatch(/^https:\/\/[^/]+:\d+\//); | ||
| }); | ||
|
|
||
| it('supports absolute "sslKey" and "sslCert" paths outside the workspace', async () => { | ||
| const baseTmpDir = process.env['TEST_TMPDIR']; | ||
| assert(baseTmpDir, 'TEST_TMPDIR is not set'); | ||
| const certsDir = await mkdtemp(join(baseTmpDir, 'angular-cli-ssl-')); | ||
| const sslKey = join(certsDir, 'server.key'); | ||
| const sslCert = join(certsDir, 'server.crt'); | ||
| await writeFile(sslKey, SSL_KEY); | ||
| await writeFile(sslCert, SSL_CERT); | ||
|
|
||
| harness.useTarget('serve', { | ||
| ...BASE_OPTIONS, | ||
| ssl: true, | ||
| sslKey, | ||
| sslCert, | ||
| }); | ||
|
|
||
| const { result } = await harness.executeOnce(); | ||
|
|
||
| expect(result?.success).toBeTrue(); | ||
| expect(result?.baseUrl).toMatch(/^https:\/\/[^/]+:\d+\//); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
build-angular
dev-serverwith esbuild target doesnt pass through here - it has ownnormalizeOptionsinpackages/angular_devkit/build_angular/src/builders/dev-server/options.tsand handssslCert/sslKeyas is toserveWithViteso
ng servefrom project dir with relative ssl paths still fails for build-angular usersfirst version in
vite/server.tscovered both builders, same two lines in that file would keep them in sync