|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | | -import { getIPNetworkType, getNetworksCount, getSubnets, parseAsCIDR, to6to4Prefix, toARPA, toIPv4MappedAddress, toIPv4MappedAddressDecimal } from './ip'; |
| 2 | +import { fromARPA, getIPNetworkType, getNetworksCount, getSubnets, parseAsCIDR, to6to4Prefix, toARPA, toIPv4MappedAddress, toIPv4MappedAddressDecimal } from './ip'; |
3 | 3 |
|
4 | 4 | describe('ipv4/6 util', () => { |
5 | 5 | describe('parseAsCIDR', () => { |
@@ -195,10 +195,10 @@ describe('ipv4/6 util', () => { |
195 | 195 |
|
196 | 196 | describe('toARPA', () => { |
197 | 197 | it('returns ARPA address', () => { |
198 | | - expect(toARPA('1.1.1.1')).to.eql('1.1.1.1.in-addr.arpa'); // NOSONAR |
199 | | - expect(toARPA('10.10.1.1')).to.eql('1.1.10.10.in-addr.arpa'); // NOSONAR |
200 | | - expect(toARPA('192.168.1.1')).to.eql('1.1.168.192.in-addr.arpa'); // NOSONAR |
201 | | - expect(toARPA('255.255.255.0')).to.eql('0.255.255.255.in-addr.arpa'); // NOSONAR |
| 198 | + expect(toARPA('1.1.1.1')).to.eql('1.1.1.1.in-addr.arpa.'); // NOSONAR |
| 199 | + expect(toARPA('10.10.1.1')).to.eql('1.1.10.10.in-addr.arpa.'); // NOSONAR |
| 200 | + expect(toARPA('192.168.1.1')).to.eql('1.1.168.192.in-addr.arpa.'); // NOSONAR |
| 201 | + expect(toARPA('255.255.255.0')).to.eql('0.255.255.255.in-addr.arpa.'); // NOSONAR |
202 | 202 | expect(toARPA('FF02::2')).to.eql('2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.f.f.ip6.arpa.'); // NOSONAR |
203 | 203 | expect(toARPA('2345:0425:2CA1:0000:0000:0567:5673:23b5')).to.eql('5.b.3.2.3.7.6.5.7.6.5.0.0.0.0.0.0.0.0.0.1.a.c.2.5.2.4.0.5.4.3.2.ip6.arpa.'); // NOSONAR |
204 | 204 | expect(toARPA('fdf8:f53b:82e4::53')).to.eql('3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.e.2.8.b.3.5.f.8.f.d.f.ip6.arpa.'); // NOSONAR |
@@ -235,4 +235,12 @@ describe('ipv4/6 util', () => { |
235 | 235 | expect(to6to4Prefix('2001:db8:0:85a3::ac1f:8001')).to.eql(''); // NOSONAR |
236 | 236 | }); // NOSONAR |
237 | 237 | }); // NOSONAR |
| 238 | + describe('fromARPA', () => { |
| 239 | + it('returns IP', () => { |
| 240 | + expect(fromARPA('42.2.0.192.in-addr.arpa.')).to.eql('192.0.2.42'); // NOSONAR |
| 241 | + expect(fromARPA('42.2.0.192.in-addr.arpa')).to.eql('192.0.2.42'); // NOSONAR |
| 242 | + expect(fromARPA('e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.')).to.eql('2001:0:ce49:7601:e866:efff:62c3:fffe'); // NOSONAR |
| 243 | + expect(fromARPA('e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa')).to.eql('2001:0:ce49:7601:e866:efff:62c3:fffe'); // NOSONAR |
| 244 | + }); // NOSONAR |
| 245 | + }); // NOSONAR |
238 | 246 | }); // NOSONAR |
0 commit comments