Advertisement
CSenshi

tmp_test_v6

Apr 28th, 2020
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   describe('IPv6 Validation rule', function () {
  2.     it('should pass normal ipv6 address ', function () {
  3.       var validator = new Validator({
  4.         ipAddr: '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
  5.       }, {
  6.         ipAddr: 'ipv6'
  7.       });
  8.       expect(validator.passes()).to.be.pass;
  9.     });
  10.  
  11.     it('should pass normal ipv6 address with ommited zeros', function () {
  12.       var validator = new Validator({
  13.         ipAddr: '2001:0db8:85a3:0:0:8a2e:0370:7334'
  14.       }, {
  15.         ipAddr: 'ipv6'
  16.       });
  17.       expect(validator.passes()).to.be.pass;
  18.     });
  19.  
  20.     it('should pass max ipv6 address', function () {
  21.       var validator = new Validator({
  22.         ipAddr: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
  23.       }, {
  24.         ipAddr: 'ipv6'
  25.       });
  26.       expect(validator.passes()).to.be.pass;
  27.     });
  28.  
  29.     it('should pass ipv6 address with ommiting section of zeros', function () {
  30.       var validator = new Validator({
  31.         ipAddr: '2001:db8::ff00:42:8329'
  32.       }, {
  33.         ipAddr: 'ipv6'
  34.       });
  35.       expect(validator.passes()).to.be.pass;
  36.     });
  37.  
  38.     it('should pass ipv6 address of localhost', function () {
  39.       var validator = new Validator({
  40.         ipAddr: '::1'
  41.       }, {
  42.         ipAddr: 'ipv6'
  43.       });
  44.       expect(validator.passes()).to.be.pass;
  45.     });
  46.  
  47.     it('should fail on ipv4 address', function () {
  48.       var validator = new Validator({
  49.         ipAddr: '192.168.33.10'
  50.       }, {
  51.         ipAddr: 'ipv6'
  52.       });
  53.       expect(validator.passes()).to.be.fail;
  54.     });
  55.  
  56.     it('should fail on ipv4 address', function () {
  57.       var validator = new Validator({
  58.         ipAddr: '192.168.33.10'
  59.       }, {
  60.         ipAddr: 'ipv6'
  61.       });
  62.       expect(validator.passes()).to.be.fail;
  63.     });
  64.  
  65.     it('should fail on ipv6 address with more than 8 sectors', function () {
  66.       var validator = new Validator({
  67.         ipAddr: '2001:0db8:85a3:1234:5349:8a2e:0370:7334:1234'
  68.       }, {
  69.         ipAddr: 'ipv6'
  70.       });
  71.       expect(validator.passes()).to.be.fail;
  72.     });
  73.  
  74.     it('should fail on ipv6 address with less than 2 sectors', function () {
  75.       var validator = new Validator({
  76.         ipAddr: ':2000'
  77.       }, {
  78.         ipAddr: 'ipv6'
  79.       });
  80.       expect(validator.passes()).to.be.fail;
  81.     });
  82.  
  83.     it('should fail on ipv6 address with bigger values in octet than ffff', function () {
  84.       var validator = new Validator({
  85.         ipAddr: '2001:0db8:85a3:1234:123456789:8a2e:0370:7334:'
  86.       }, {
  87.         ipAddr: 'ipv6'
  88.       });
  89.       expect(validator.passes()).to.be.fail;
  90.     });
  91.  
  92.     it('should fail on ipv6 address when consecutive ommiting sections occure', function () {
  93.       var validator = new Validator({
  94.         ipAddr: '234::123::23'
  95.       }, {
  96.         ipAddr: 'ipv6'
  97.       });
  98.       expect(validator.passes()).to.be.false;
  99.     });
  100.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement