@verdaccio/proxy 8.0.0-next-8.12 → 8.0.0-next-8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,126 +0,0 @@
1
- // import nock from 'nock';
2
- // import path from 'path';
3
-
4
- // import { Config, parseConfigFile } from '@verdaccio/config';
5
- // import { API_ERROR, HEADER_TYPE, HTTP_STATUS, VerdaccioError, errorUtils } from '@verdaccio/core';
6
-
7
- // import { ProxyStorage } from '../src';
8
-
9
- // const getConf = (name) => path.join(__dirname, '/conf', name);
10
-
11
- // const mockDebug = jest.fn();
12
- // const mockInfo = jest.fn();
13
- // const mockHttp = jest.fn();
14
- // const mockError = jest.fn();
15
- // const mockWarn = jest.fn();
16
- // jest.mock('@verdaccio/logger', () => {
17
- // const originalLogger = jest.requireActual('@verdaccio/logger');
18
- // return {
19
- // ...originalLogger,
20
- // logger: {
21
- // child: () => ({
22
- // debug: (arg) => mockDebug(arg),
23
- // info: (arg) => mockInfo(arg),
24
- // http: (arg) => mockHttp(arg),
25
- // error: (arg) => mockError(arg),
26
- // warn: (arg) => mockWarn(arg),
27
- // }),
28
- // },
29
- // };
30
- // });
31
-
32
- // const domain = 'https://registry.npmjs.org';
33
-
34
- // describe('proxy', () => {
35
- // beforeEach(() => {
36
- // nock.cleanAll();
37
- // });
38
- // const defaultRequestOptions = {
39
- // url: 'https://registry.npmjs.org',
40
- // };
41
- // const proxyPath = getConf('proxy1.yaml');
42
- // const conf = new Config(parseConfigFile(proxyPath));
43
-
44
- // describe('error handling', () => {
45
- // test('should be offline uplink', (done) => {
46
- // const tarball = 'https://registry.npmjs.org/jquery/-/jquery-0.0.1.tgz';
47
- // nock(domain).get('/jquery/-/jquery-0.0.1.tgz').times(100).replyWithError('some error');
48
- // const proxy = new ProxyStorage(defaultRequestOptions, conf);
49
- // const stream = proxy.fetchTarball(tarball);
50
- // // to test a uplink is offline we have to be try 3 times
51
- // // the default failed request are set to 2
52
- // process.nextTick(function () {
53
- // stream.on('error', function (err) {
54
- // expect(err).not.toBeNull();
55
- // // expect(err.statusCode).toBe(404);
56
- // expect(proxy.failed_requests).toBe(1);
57
-
58
- // const streamSecondTry = proxy.fetchTarball(tarball);
59
- // streamSecondTry.on('error', function (err) {
60
- // expect(err).not.toBeNull();
61
- // /*
62
- // code: 'ENOTFOUND',
63
- // errno: 'ENOTFOUND',
64
- // */
65
- // // expect(err.statusCode).toBe(404);
66
- // expect(proxy.failed_requests).toBe(2);
67
- // const streamThirdTry = proxy.fetchTarball(tarball);
68
- // streamThirdTry.on('error', function (err: VerdaccioError) {
69
- // expect(err).not.toBeNull();
70
- // expect(err.statusCode).toBe(HTTP_STATUS.INTERNAL_ERROR);
71
- // expect(proxy.failed_requests).toBe(2);
72
- // expect(err.message).toMatch(API_ERROR.UPLINK_OFFLINE);
73
- // done();
74
- // });
75
- // });
76
- // });
77
- // });
78
- // });
79
-
80
- // test('not found tarball', (done) => {
81
- // nock(domain).get('/jquery/-/jquery-0.0.1.tgz').reply(404);
82
- // const prox1 = new ProxyStorage(defaultRequestOptions, conf);
83
- // const stream = prox1.fetchTarball('https://registry.npmjs.org/jquery/-/jquery-0.0.1.tgz');
84
- // stream.on('error', (response) => {
85
- // expect(response).toEqual(errorUtils.getNotFound(API_ERROR.NOT_FILE_UPLINK));
86
- // done();
87
- // });
88
- // });
89
-
90
- // test('fail tarball request', (done) => {
91
- // nock(domain).get('/jquery/-/jquery-0.0.1.tgz').replyWithError('boom file');
92
- // const prox1 = new ProxyStorage(defaultRequestOptions, conf);
93
- // const stream = prox1.fetchTarball('https://registry.npmjs.org/jquery/-/jquery-0.0.1.tgz');
94
- // stream.on('error', (response) => {
95
- // expect(response).toEqual(Error('boom file'));
96
- // done();
97
- // });
98
- // });
99
-
100
- // test('bad uplink request', (done) => {
101
- // nock(domain).get('/jquery/-/jquery-0.0.1.tgz').reply(409);
102
- // const prox1 = new ProxyStorage(defaultRequestOptions, conf);
103
- // const stream = prox1.fetchTarball('https://registry.npmjs.org/jquery/-/jquery-0.0.1.tgz');
104
- // stream.on('error', (response) => {
105
- // expect(response).toEqual(errorUtils.getInternalError(`bad uplink status code: 409`));
106
- // done();
107
- // });
108
- // });
109
-
110
- // test('content length header mismatch', (done) => {
111
- // nock(domain)
112
- // .get('/jquery/-/jquery-0.0.1.tgz')
113
- // // types does not match here with documentation
114
- // // @ts-expect-error
115
- // .replyWithFile(201, path.join(__dirname, 'partials/jquery-0.0.1.tgz'), {
116
- // [HEADER_TYPE.CONTENT_LENGTH]: 0,
117
- // });
118
- // const prox1 = new ProxyStorage(defaultRequestOptions, conf);
119
- // const stream = prox1.fetchTarball('https://registry.npmjs.org/jquery/-/jquery-0.0.1.tgz');
120
- // stream.on('error', (response) => {
121
- // expect(response).toEqual(errorUtils.getInternalError(API_ERROR.CONTENT_MISMATCH));
122
- // done();
123
- // });
124
- // });
125
- // });
126
- // });
@@ -1,451 +0,0 @@
1
- import nock from 'nock';
2
- import path from 'path';
3
- import { setTimeout } from 'timers/promises';
4
- import { beforeEach, describe, expect, test, vi } from 'vitest';
5
-
6
- import { Config, parseConfigFile } from '@verdaccio/config';
7
- import { API_ERROR, errorUtils } from '@verdaccio/core';
8
- import { Logger } from '@verdaccio/types';
9
-
10
- import { ProxyStorage } from '../src';
11
-
12
- const getConf = (name) => path.join(__dirname, '/conf', name);
13
-
14
- const mockDebug = vi.fn();
15
- const mockInfo = vi.fn();
16
- const mockHttp = vi.fn();
17
- const mockError = vi.fn();
18
- const mockWarn = vi.fn();
19
-
20
- const logger = {
21
- debug: mockDebug,
22
- info: mockInfo,
23
- http: mockHttp,
24
- error: mockError,
25
- warn: mockWarn,
26
- } as unknown as Logger;
27
-
28
- const domain = 'https://registry.npmjs.org';
29
-
30
- describe('proxy', () => {
31
- beforeEach(() => {
32
- nock.cleanAll();
33
- });
34
-
35
- const defaultRequestOptions = {
36
- url: domain,
37
- };
38
- const proxyPath = getConf('proxy1.yaml');
39
- const conf = new Config(parseConfigFile(proxyPath));
40
- conf.server_id = 'foo-phseudo-bytes';
41
-
42
- describe('getRemoteMetadata', () => {
43
- beforeEach(() => {
44
- nock.cleanAll();
45
- nock.abortPendingRequests();
46
- vi.clearAllMocks();
47
- });
48
- describe('basic requests', () => {
49
- test('success call to remote', async () => {
50
- nock(domain, {
51
- reqheaders: {
52
- accept: 'application/json;',
53
- 'accept-encoding': 'gzip',
54
- 'x-forwarded-for': '127.0.0.1',
55
- via: '1.1 foo-phseudo-bytes (Verdaccio)',
56
- },
57
- })
58
- .get('/jquery')
59
- .reply(200, { body: 'test' });
60
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
61
- const [manifest] = await prox1.getRemoteMetadata('jquery', {
62
- remoteAddress: '127.0.0.1',
63
- });
64
- expect(manifest).toEqual({ body: 'test' });
65
- });
66
- });
67
-
68
- describe('etag header', () => {
69
- test('proxy call with etag', async () => {
70
- nock(domain, {
71
- reqheaders: {
72
- accept: 'application/json;',
73
- 'accept-encoding': 'gzip',
74
- 'x-forwarded-for': '127.0.0.1',
75
- via: '1.1 foo-phseudo-bytes (Verdaccio)',
76
- },
77
- })
78
- .get('/jquery')
79
- .reply(
80
- 200,
81
- { body: 'test' },
82
- {
83
- etag: () => `_ref_4444`,
84
- }
85
- );
86
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
87
- const [manifest, etag] = await prox1.getRemoteMetadata('jquery', {
88
- remoteAddress: '127.0.0.1',
89
- });
90
- expect(etag).toEqual('_ref_4444');
91
- expect(manifest).toEqual({ body: 'test' });
92
- });
93
-
94
- test('proxy call with etag as option', async () => {
95
- nock(domain, {
96
- reqheaders: {
97
- accept: 'application/json;',
98
- 'accept-encoding': 'gzip',
99
- 'x-forwarded-for': '127.0.0.1',
100
- via: '1.1 foo-phseudo-bytes (Verdaccio)',
101
- // match only if etag is set as option
102
- 'if-none-match': 'foo',
103
- },
104
- })
105
- .get('/jquery')
106
- .reply(
107
- 200,
108
- { body: 'test' },
109
- {
110
- etag: () => `_ref_4444`,
111
- }
112
- );
113
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
114
- const [manifest, etag] = await prox1.getRemoteMetadata('jquery', {
115
- etag: 'foo',
116
- remoteAddress: '127.0.0.1',
117
- });
118
- expect(etag).toEqual('_ref_4444');
119
- expect(manifest).toEqual({ body: 'test' });
120
- });
121
- });
122
-
123
- describe('log activity', () => {
124
- test('proxy call with etag', async () => {
125
- nock(domain)
126
- .get('/jquery')
127
- .reply(200, { body: { name: 'foo', version: '1.0.0' } }, {});
128
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
129
- await prox1.getRemoteMetadata('jquery', {
130
- remoteAddress: '127.0.0.1',
131
- });
132
- expect(mockHttp).toHaveBeenCalledTimes(2);
133
- expect(mockHttp).toHaveBeenCalledWith(
134
- {
135
- request: { method: 'GET', url: `${domain}/jquery` },
136
- status: 200,
137
- },
138
- "@{!status}, req: '@{request.method} @{request.url}' (streaming)"
139
- );
140
- expect(mockHttp).toHaveBeenLastCalledWith(
141
- {
142
- request: { method: 'GET', url: `${domain}/jquery` },
143
- status: 200,
144
- bytes: {
145
- in: 0,
146
- out: 41,
147
- },
148
- },
149
- "@{!status}, req: '@{request.method} @{request.url}'"
150
- );
151
- });
152
- });
153
-
154
- describe('error handling', () => {
155
- test('proxy call with 304', async () => {
156
- nock(domain).get('/jquery').reply(304);
157
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
158
- await expect(prox1.getRemoteMetadata('jquery', { etag: 'rev_3333' })).rejects.toThrow(
159
- 'no data'
160
- );
161
- });
162
-
163
- test('reply with error', async () => {
164
- nock(domain).get('/jquery').replyWithError('something awful happened');
165
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
166
- await expect(
167
- prox1.getRemoteMetadata('jquery', {
168
- remoteAddress: '127.0.0.1',
169
- })
170
- ).rejects.toThrow(/something awful happened/);
171
- });
172
-
173
- test('reply with 409 error', async () => {
174
- nock(domain).get('/jquery').reply(409);
175
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
176
- await expect(prox1.getRemoteMetadata('jquery', { retry: { limit: 0 } })).rejects.toThrow(
177
- /bad status code: 409/
178
- );
179
- });
180
-
181
- test('reply with bad body json format', async () => {
182
- nock(domain).get('/jquery').reply(200, 'some-text');
183
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
184
- await expect(
185
- prox1.getRemoteMetadata('jquery', {
186
- remoteAddress: '127.0.0.1',
187
- })
188
- ).rejects.toThrow();
189
- });
190
-
191
- test('400 error proxy call', async () => {
192
- nock(domain).get('/jquery').reply(409);
193
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
194
- await expect(
195
- prox1.getRemoteMetadata('jquery', {
196
- remoteAddress: '127.0.0.1',
197
- })
198
- ).rejects.toThrow(/bad status code: 409/);
199
- });
200
-
201
- test('proxy not found', async () => {
202
- nock(domain).get('/jquery').reply(404);
203
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
204
- await expect(
205
- prox1.getRemoteMetadata('jquery', {
206
- remoteAddress: '127.0.0.1',
207
- })
208
- ).rejects.toThrow(errorUtils.getNotFound(API_ERROR.NOT_PACKAGE_UPLINK));
209
- expect(mockHttp).toHaveBeenCalledTimes(1);
210
- expect(mockHttp).toHaveBeenLastCalledWith(
211
- {
212
- request: { method: 'GET', url: `${domain}/jquery` },
213
- status: 404,
214
- },
215
- "@{!status}, req: '@{request.method} @{request.url}' (streaming)"
216
- );
217
- });
218
- });
219
-
220
- describe('retry', () => {
221
- test('retry twice on 500 and return 200 logging offline activity', async () => {
222
- nock(domain)
223
- .get('/jquery')
224
- .twice()
225
- .reply(500, 'some-text')
226
- .get('/jquery')
227
- .once()
228
- .reply(200, { body: { name: 'foo', version: '1.0.0' } });
229
-
230
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
231
- const [manifest] = await prox1.getRemoteMetadata('jquery', {
232
- retry: { limit: 2 },
233
- });
234
- expect(manifest).toEqual({ body: { name: 'foo', version: '1.0.0' } });
235
- expect(mockInfo).toHaveBeenCalledTimes(2);
236
- expect(mockInfo).toHaveBeenLastCalledWith(
237
- {
238
- error: 'Response code 500 (Internal Server Error)',
239
- request: { method: 'GET', url: `${domain}/jquery` },
240
- retryCount: 2,
241
- },
242
- "retry @{retryCount} req: '@{request.method} @{request.url}'"
243
- );
244
- });
245
-
246
- test('retry count is exceded and uplink goes offline with logging activity', async () => {
247
- nock(domain).get('/jquery').times(10).reply(500);
248
-
249
- const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
250
- await expect(
251
- prox1.getRemoteMetadata('jquery', {
252
- remoteAddress: '127.0.0.1',
253
- retry: { limit: 2 },
254
- })
255
- ).rejects.toThrow();
256
- await expect(
257
- prox1.getRemoteMetadata('jquery', {
258
- remoteAddress: '127.0.0.1',
259
- retry: { limit: 2 },
260
- })
261
- ).rejects.toThrow(errorUtils.getInternalError(errorUtils.API_ERROR.UPLINK_OFFLINE));
262
- expect(mockWarn).toHaveBeenCalledTimes(1);
263
- expect(mockWarn).toHaveBeenLastCalledWith(
264
- {
265
- host: 'registry.npmjs.org',
266
- },
267
- 'host @{host} is now offline'
268
- );
269
- });
270
-
271
- test('fails calls and recover with 200 with log online activity', async () => {
272
- // This unit test is designed to verify if the uplink goes to offline
273
- // and recover after the fail_timeout has expired.
274
- nock(domain)
275
- .get('/jquery')
276
- .thrice()
277
- .reply(500, 'some-text')
278
- .get('/jquery')
279
- .once()
280
- .reply(200, { body: { name: 'foo', version: '1.0.0' } });
281
-
282
- const prox1 = new ProxyStorage(
283
- { ...defaultRequestOptions, fail_timeout: '1s', max_fails: 1 },
284
- conf,
285
- logger
286
- );
287
- // force retry
288
- await expect(
289
- prox1.getRemoteMetadata('jquery', {
290
- remoteAddress: '127.0.0.1',
291
- retry: { limit: 2 },
292
- })
293
- ).rejects.toThrow();
294
- // display offline error on exausted retry
295
- await expect(
296
- prox1.getRemoteMetadata('jquery', {
297
- remoteAddress: '127.0.0.1',
298
- retry: { limit: 2 },
299
- })
300
- ).rejects.toThrow(errorUtils.getInternalError(errorUtils.API_ERROR.UPLINK_OFFLINE));
301
- expect(mockWarn).toHaveBeenCalledTimes(2);
302
- expect(mockWarn).toHaveBeenLastCalledWith(
303
- {
304
- host: 'registry.npmjs.org',
305
- },
306
- 'host @{host} is now offline'
307
- );
308
- expect(mockWarn).toHaveBeenLastCalledWith(
309
- {
310
- host: 'registry.npmjs.org',
311
- },
312
- 'host @{host} is now offline'
313
- );
314
- // this is based on max_fails, if change that also change here acordingly
315
- await setTimeout(3000);
316
- const [manifest] = await prox1.getRemoteMetadata('jquery', {
317
- retry: { limit: 2 },
318
- });
319
- expect(manifest).toEqual({ body: { name: 'foo', version: '1.0.0' } });
320
- expect(mockWarn).toHaveBeenLastCalledWith(
321
- {
322
- host: 'registry.npmjs.org',
323
- },
324
- 'host @{host} is now online'
325
- );
326
- }, 10000);
327
- });
328
-
329
- describe('timeout', () => {
330
- test('fail for timeout (2 seconds)', async () => {
331
- nock(domain)
332
- .get('/jquery')
333
- .times(10)
334
- .delayConnection(6000)
335
- .reply(200, { body: { name: 'foo', version: '1.0.0' } });
336
-
337
- const confTimeout = { ...defaultRequestOptions };
338
- // @ts-expect-error
339
- confTimeout.timeout = '2s';
340
- const prox1 = new ProxyStorage(confTimeout, conf, logger);
341
- await expect(
342
- prox1.getRemoteMetadata('jquery', {
343
- retry: { limit: 0 },
344
- })
345
- ).rejects.toThrow('ETIMEDOUT');
346
- }, 10000);
347
-
348
- test('fail for one failure and timeout (2 seconds)', async () => {
349
- nock(domain)
350
- .get('/jquery')
351
- .times(1)
352
- .reply(500)
353
- .get('/jquery')
354
- .delayConnection(4000)
355
- .reply(200, { body: { name: 'foo', version: '1.0.0' } });
356
-
357
- const confTimeout = { ...defaultRequestOptions };
358
- // @ts-expect-error
359
- confTimeout.timeout = '2s';
360
- const prox1 = new ProxyStorage(confTimeout, conf, logger);
361
- await expect(
362
- prox1.getRemoteMetadata('jquery', {
363
- retry: { limit: 1 },
364
- })
365
- ).rejects.toThrow('ETIMEDOUT');
366
- }, 10000);
367
-
368
- // test('retry count is exceded and uplink goes offline with logging activity', async () => {
369
- // nock(domain).get('/jquery').times(10).reply(500);
370
-
371
- // const prox1 = new ProxyStorage(defaultRequestOptions, conf, logger);
372
- // await expect(
373
- // prox1.getRemoteMetadata('jquery', {
374
- // remoteAddress: '127.0.0.1',
375
- // retry: { limit: 2 },
376
- // })
377
- // ).rejects.toThrow();
378
- // await expect(
379
- // prox1.getRemoteMetadata('jquery', {
380
- // remoteAddress: '127.0.0.1',
381
- // retry: { limit: 2 },
382
- // })
383
- // ).rejects.toThrow(errorUtils.getInternalError(errorUtils.API_ERROR.UPLINK_OFFLINE));
384
- // expect(mockWarn).toHaveBeenCalledTimes(1);
385
- // expect(mockWarn).toHaveBeenLastCalledWith(
386
- // {
387
- // host: 'registry.npmjs.org',
388
- // },
389
- // 'host @{host} is now offline'
390
- // );
391
- // });
392
-
393
- // test('fails calls and recover with 200 with log online activity', async () => {
394
- // // This unit test is designed to verify if the uplink goes to offline
395
- // // and recover after the fail_timeout has expired.
396
- // nock(domain)
397
- // .get('/jquery')
398
- // .thrice()
399
- // .reply(500, 'some-text')
400
- // .get('/jquery')
401
- // .once()
402
- // .reply(200, { body: { name: 'foo', version: '1.0.0' } });
403
-
404
- // const prox1 = new ProxyStorage(
405
- // { ...defaultRequestOptions, fail_timeout: '1s', max_fails: 1 },
406
- // conf,
407
- // logger
408
- // );
409
- // // force retry
410
- // await expect(
411
- // prox1.getRemoteMetadata('jquery', {
412
- // remoteAddress: '127.0.0.1',
413
- // retry: { limit: 2 },
414
- // })
415
- // ).rejects.toThrow();
416
- // // display offline error on exausted retry
417
- // await expect(
418
- // prox1.getRemoteMetadata('jquery', {
419
- // remoteAddress: '127.0.0.1',
420
- // retry: { limit: 2 },
421
- // })
422
- // ).rejects.toThrow(errorUtils.getInternalError(errorUtils.API_ERROR.UPLINK_OFFLINE));
423
- // expect(mockWarn).toHaveBeenCalledTimes(2);
424
- // expect(mockWarn).toHaveBeenLastCalledWith(
425
- // {
426
- // host: 'registry.npmjs.org',
427
- // },
428
- // 'host @{host} is now offline'
429
- // );
430
- // expect(mockWarn).toHaveBeenLastCalledWith(
431
- // {
432
- // host: 'registry.npmjs.org',
433
- // },
434
- // 'host @{host} is now offline'
435
- // );
436
- // // this is based on max_fails, if change that also change here acordingly
437
- // await setTimeout(3000);
438
- // const [manifest] = await prox1.getRemoteMetadata('jquery', {
439
- // retry: { limit: 2 },
440
- // });
441
- // expect(manifest).toEqual({ body: { name: 'foo', version: '1.0.0' } });
442
- // expect(mockWarn).toHaveBeenLastCalledWith(
443
- // {
444
- // host: 'registry.npmjs.org',
445
- // },
446
- // 'host @{host} is now online'
447
- // );
448
- // }, 10000);
449
- });
450
- });
451
- });
@@ -1,87 +0,0 @@
1
- import { beforeEach, describe, expect, test, vi } from 'vitest';
2
-
3
- import { Logger } from '@verdaccio/types';
4
-
5
- import { ProxyStorage } from '../src';
6
-
7
- const mockDebug = vi.fn();
8
- const mockInfo = vi.fn();
9
- const mockHttp = vi.fn();
10
- const mockError = vi.fn();
11
- const mockWarn = vi.fn();
12
-
13
- const logger = {
14
- debug: mockDebug,
15
- info: mockInfo,
16
- http: mockHttp,
17
- error: mockError,
18
- warn: mockWarn,
19
- } as unknown as Logger;
20
-
21
- function getProxyInstance(host, uplinkConf, appConfig) {
22
- uplinkConf.url = host;
23
-
24
- return new ProxyStorage(uplinkConf, appConfig, logger);
25
- }
26
-
27
- describe('Check protocol of proxy', () => {
28
- beforeEach(() => {
29
- vi.clearAllMocks();
30
- });
31
- test('validate main config protocol - http', () => {
32
- expect(
33
- getProxyInstance(
34
- 'http://registry.domain.org',
35
- { http_proxy: 'http://registry.local.org' },
36
- {}
37
- ).proxy
38
- ).toEqual('http://registry.local.org');
39
- });
40
- test('main config invalid protocol - http', () => {
41
- expect(
42
- getProxyInstance(
43
- 'http://registry.domain.org',
44
- { http_proxy: 'https://registry.local.org' },
45
- {}
46
- ).proxy
47
- ).toEqual(undefined);
48
- expect(mockError).toHaveBeenCalledOnce();
49
- });
50
- test('main config invalid protocol - https', () => {
51
- expect(
52
- getProxyInstance(
53
- 'https://registry.domain.org',
54
- { https_proxy: 'http://registry.local.org' },
55
- {}
56
- ).proxy
57
- ).toEqual(undefined);
58
- expect(mockError).toHaveBeenCalledOnce();
59
- });
60
-
61
- test('validate uplink config protocol - http', () => {
62
- expect(
63
- getProxyInstance(
64
- 'https://registry.domain.org',
65
- {},
66
- { https_proxy: 'https://proxy.domain.org' }
67
- ).proxy
68
- ).toEqual('https://proxy.domain.org');
69
- });
70
- test('uplink config invalid protocol - http', () => {
71
- expect(
72
- getProxyInstance('http://registry.domain.org', {}, { http_proxy: 'https://proxy.domain.org' })
73
- .proxy
74
- ).toEqual(undefined);
75
- expect(mockError).toHaveBeenCalledOnce();
76
- });
77
- test('uplink config invalid protocol - https', () => {
78
- expect(
79
- getProxyInstance(
80
- 'https://registry.domain.org',
81
- {},
82
- { https_proxy: 'http://proxy.domain.org' }
83
- ).proxy
84
- ).toEqual(undefined);
85
- expect(mockError).toHaveBeenCalledOnce();
86
- });
87
- });