一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
37 行
1.4 KiB
TypeScript
37 行
1.4 KiB
TypeScript
import { remove, writeFile } from 'fs-extra';
|
|
import createLocalhostServer from '../../testing/createLocalhostServer';
|
|
import { createTempDir, expectNotThrow, expectThrow } from '../../testing/test-utils';
|
|
import { join } from 'path';
|
|
import shim from '../../shim';
|
|
import setExtraRootCertificates from './setExtraRootCertificates';
|
|
|
|
describe('setExtraRootCertificates', () => {
|
|
it('should support loading extra root certificates from a directory', async () => {
|
|
await using httpsServer1 = await createLocalhostServer((_req, res) => {
|
|
res.writeHead(200);
|
|
res.end('test 1!');
|
|
}, { https: true });
|
|
await using httpsServer2 = await createLocalhostServer((_req, res) => {
|
|
res.writeHead(200);
|
|
res.end('test 2!');
|
|
}, { https: true });
|
|
|
|
const tempDir = await createTempDir();
|
|
try {
|
|
await expectThrow(async () => await shim.fetch(httpsServer1.baseUrl));
|
|
await expectThrow(async () => await shim.fetch(httpsServer2.baseUrl));
|
|
|
|
await writeFile(join(tempDir, 'cert-1.pem'), httpsServer1.cert, 'utf-8');
|
|
await writeFile(join(tempDir, 'cert-2.pem'), httpsServer2.cert, 'utf-8');
|
|
|
|
await setExtraRootCertificates([{ path: tempDir }]);
|
|
|
|
await expectNotThrow(async () => await shim.fetch(httpsServer2.baseUrl));
|
|
await expectNotThrow(async () => await shim.fetch(httpsServer1.baseUrl));
|
|
} finally {
|
|
await remove(tempDir);
|
|
await setExtraRootCertificates([]);
|
|
}
|
|
});
|
|
});
|