| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a41a3e3 commit aa5309c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ require('../common'); | |||
| 4 | 4 | ||
| 5 | 5 | const { BlockList } = require('net'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | + const util = require('util'); | ||
| 7 | 8 | ||
| 8 | 9 | { | |
| 9 | 10 | const blockList = new BlockList(); | |
@@ -135,3 +136,45 @@ const assert = require('assert'); | |||
| 135 | 136 | assert(blockList.check('8592:757c:efaf:1fff:ffff:ffff:ffff:ffff', 'ipv6')); | |
| 136 | 137 | assert(!blockList.check('8592:757c:efaf:2fff:ffff:ffff:ffff:ffff', 'ipv6')); | |
| 137 | 138 | } | |
| 139 | + | ||
| 140 | + { | ||
| 141 | + assert.throws(() => new BlockList('NOT BLOCK LIST HANDLE'), /ERR_INVALID_ARG_TYPE/); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + { | ||
| 145 | + const blockList = new BlockList(); | ||
| 146 | + assert.throws(() => blockList.addRange('1.1.1.2', '1.1.1.1'), /ERR_INVALID_ARG_VALUE/); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + { | ||
| 150 | + const blockList = new BlockList(); | ||
| 151 | + assert.throws(() => blockList.addSubnet(1), /ERR_INVALID_ARG_TYPE/); | ||
| 152 | + assert.throws(() => blockList.addSubnet('', ''), /ERR_INVALID_ARG_TYPE/); | ||
| 153 | + assert.throws(() => blockList.addSubnet('', 1, 1), /ERR_INVALID_ARG_TYPE/); | ||
| 154 | + assert.throws(() => blockList.addSubnet('', 1, ''), /ERR_INVALID_ARG_VALUE/); | ||
| 155 | + | ||
| 156 | + assert.throws(() => blockList.addSubnet('', -1, 'ipv4'), /ERR_OUT_OF_RANGE/); | ||
| 157 | + assert.throws(() => blockList.addSubnet('', 33, 'ipv4'), /ERR_OUT_OF_RANGE/); | ||
| 158 | + | ||
| 159 | + assert.throws(() => blockList.addSubnet('', -1, 'ipv6'), /ERR_OUT_OF_RANGE/); | ||
| 160 | + assert.throws(() => blockList.addSubnet('', 129, 'ipv6'), /ERR_OUT_OF_RANGE/); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + { | ||
| 164 | + const blockList = new BlockList(); | ||
| 165 | + assert.throws(() => blockList.check(1), /ERR_INVALID_ARG_TYPE/); | ||
| 166 | + assert.throws(() => blockList.check('', 1), /ERR_INVALID_ARG_TYPE/); | ||
| 167 | + assert.throws(() => blockList.check('', ''), /ERR_INVALID_ARG_VALUE/); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + { | ||
| 171 | + const blockList = new BlockList(); | ||
| 172 | + const ret = util.inspect(blockList, { depth: -1 }); | ||
| 173 | + assert.strictEqual(ret, '[BlockList]'); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + { | ||
| 177 | + const blockList = new BlockList(); | ||
| 178 | + const ret = util.inspect(blockList, { depth: null }); | ||
| 179 | + assert(ret.includes('rules: []')); | ||
| 180 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments