mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
fix unit tests for HttpRequestService.ts
This commit is contained in:
parent
e914be3694
commit
b888ff931d
1 changed files with 12 additions and 2 deletions
|
@ -16,8 +16,8 @@ describe(HttpRequestService, () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
allowedPrivateNetworks = parsePrivateNetworks([
|
allowedPrivateNetworks = parsePrivateNetworks([
|
||||||
'10.0.0.1/32',
|
'10.0.0.1/32',
|
||||||
'127.0.0.1/32#1',
|
{ network: '127.0.0.1/32', ports: [1] },
|
||||||
'127.0.0.1/32#3,4,5',
|
{ network: '127.0.0.1/32', ports: [3, 4, 5] },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,11 @@ describe(HttpRequestService, () => {
|
||||||
expect(result).toBeFalsy();
|
expect(result).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return false when ip private and all ports undefined', () => {
|
||||||
|
const result = isPrivateIp(allowedPrivateNetworks, '10.0.0.1', undefined);
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should return true when ip private and no ports specified', () => {
|
it('should return true when ip private and no ports specified', () => {
|
||||||
const result = isPrivateIp(allowedPrivateNetworks, '10.0.0.2', 80);
|
const result = isPrivateIp(allowedPrivateNetworks, '10.0.0.2', 80);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
|
@ -41,6 +46,11 @@ describe(HttpRequestService, () => {
|
||||||
const result = isPrivateIp(allowedPrivateNetworks, '127.0.0.1', 80);
|
const result = isPrivateIp(allowedPrivateNetworks, '127.0.0.1', 80);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true when ip private and port is null but ports are specified', () => {
|
||||||
|
const result = isPrivateIp(allowedPrivateNetworks, '127.0.0.1', undefined);
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validateSocketConnect', () => {
|
describe('validateSocketConnect', () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue