Skip to content

Commit bc33eb7

Browse files
committed
chore: fix ci
Signed-off-by: dhmlau <dhmlau@ca.ibm.com>
1 parent 25080e7 commit bc33eb7

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/http-caching-proxy/src/__tests__/integration/http-caching-proxy.integration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {once} from 'node:events';
1414
import http from 'node:http';
1515
import {AddressInfo} from 'node:net';
1616
import path from 'node:path';
17+
import {URL} from 'node:url';
1718
import {rimraf} from 'rimraf';
1819
import tunnel, {ProxyOptions as TunnelProxyOptions} from 'tunnel';
19-
import {URL} from 'node:url';
2020
import {HttpCachingProxy, ProxyOptions} from '../../http-caching-proxy';
2121

2222
const CACHE_DIR = path.join(__dirname, '.cache');
@@ -84,7 +84,9 @@ describe('HttpCachingProxy', () => {
8484
// Increase the timeout to accommodate slow network connections
8585
this.timeout(30000);
8686

87-
await givenRunningProxy();
87+
// Disable SSL validation for this test to avoid certificate issues
88+
// with example.com in different Node.js versions and environments
89+
await givenRunningProxy({rejectUnauthorized: false});
8890
const result = await makeRequest({
8991
url: 'https://example.com',
9092
});

packages/http-caching-proxy/src/http-caching-proxy.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import debugFactory from 'debug';
88
import {once} from 'node:events';
99
import {
1010
createServer,
11+
Server as HttpServer,
1112
IncomingMessage,
1213
OutgoingHttpHeaders,
13-
Server as HttpServer,
1414
ServerResponse,
1515
} from 'node:http';
1616
import {AddressInfo} from 'node:net';
@@ -48,13 +48,22 @@ export interface ProxyOptions {
4848
* Timeout to connect to the target service
4949
*/
5050
timeout?: number;
51+
52+
/**
53+
* Whether to reject unauthorized SSL certificates.
54+
* Set to false to allow self-signed certificates in test environments.
55+
*
56+
* Default: true (strict SSL validation)
57+
*/
58+
rejectUnauthorized?: boolean;
5159
}
5260

5361
const DEFAULT_OPTIONS = {
5462
port: 0,
5563
ttl: 24 * 60 * 60 * 1000,
5664
logError: true,
5765
timeout: 0,
66+
rejectUnauthorized: true,
5867
};
5968

6069
interface CachedMetadata {
@@ -89,6 +98,10 @@ export class HttpCachingProxy {
8998
// http status code. Please note that Axios creates a new error in such
9099
// condition and the original low-level error is lost
91100
validateStatus: () => true,
101+
// Configure SSL certificate validation based on options
102+
httpsAgent: new (require('node:https').Agent)({
103+
rejectUnauthorized: this._options.rejectUnauthorized,
104+
}),
92105
});
93106
}
94107

0 commit comments

Comments
 (0)