mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-11-19 14:22:02 +00:00
Add test to ip_util
This commit is contained in:
parent
1345bde1c2
commit
d4922fc42d
1 changed files with 31 additions and 0 deletions
31
src/shadowbox/server/ip_utils.spec.ts
Normal file
31
src/shadowbox/server/ip_utils.spec.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2018 The Outline Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
import * as ip_util from './ip_util';
|
||||
|
||||
describe('anonymizeIp', () => {
|
||||
it('Removes last byte of IPv4', () => {
|
||||
expect(ip_util.anonymizeIp('128.128.128.128')).toEqual('128.128.128.0');
|
||||
});
|
||||
it('Removes last bytes of IPv6', () => {
|
||||
expect(ip_util.anonymizeIp('aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa'))
|
||||
.toEqual('aaaa:aaaa:aaaa:0:0:0:0:0');
|
||||
});
|
||||
it('Throws on bad input', () => {
|
||||
try {
|
||||
ip_util.anonymizeIp('BAD');
|
||||
return Error('Should throw on bad input');
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue