3 changed files with 21 additions and 50 deletions
@ -0,0 +1,15 @@ |
|||||
|
import test from "ava"; |
||||
|
import * as ufw from "./src/Index"; |
||||
|
|
||||
|
test("allow port", async (t) => t.true(await ufw.allow.port(1337))); |
||||
|
test("allow ip address", async (t) => t.true(await ufw.allow.address("1.1.1.1"))); |
||||
|
|
||||
|
test("delete specific rule", async (t) => t.true(await ufw.delete(1))); |
||||
|
|
||||
|
test("deny port", async (t) => t.true(await ufw.deny.port(1337))); |
||||
|
test("deny ip address", async (t) => t.true(await ufw.deny.address("1.1.1.1"))); |
||||
|
|
||||
|
test("enable firewall", async (t) => t.true(await ufw.enable())); |
||||
|
test("disable firewall", async (t) => t.true(await ufw.disable())); |
||||
|
test("reload firewall", async (t) => t.true(await ufw.reload())); |
||||
|
test("reset firewall", async (t) => t.true(await ufw.reset())); |
@ -1,49 +0,0 @@ |
|||||
const test = require("ava"); |
|
||||
const nodeUfw = require("./src/Main"); |
|
||||
const nodeUfwUtil = require("./src/Util"); |
|
||||
|
|
||||
test("exceeded port", async (t) => { |
|
||||
await t.throwsAsync(async () => { |
|
||||
await nodeUfw.allow.port(12341242); |
|
||||
}, {instanceOf: Error, message: 'Error: Exceeded port limit.'}); |
|
||||
|
|
||||
await t.throwsAsync(async () => { |
|
||||
await nodeUfw.deny.port(12341242); |
|
||||
}, {instanceOf: Error, message: 'Error: Exceeded port limit.'}); |
|
||||
}); |
|
||||
|
|
||||
test("wrongish", async (t) => { |
|
||||
// port checking
|
|
||||
await t.throwsAsync(async () => {await nodeUfw.allow.port("SADOASD")}, {instanceOf: Error, message: "Error: The port must be type of number."}); |
|
||||
await t.throwsAsync(async () => {await nodeUfw.deny.port("ASMJDKNSC")}, {instanceOf: Error, message: "Error: The port must be type of number."}); |
|
||||
|
|
||||
// protocol checking
|
|
||||
await t.throwsAsync(async () => {await nodeUfw.allow.port(12, 123124)}, {instanceOf: Error, message: "Error: The protocol must be type of string."}); |
|
||||
await t.throwsAsync(async () => {await nodeUfw.deny.port(12, 123124)}, {instanceOf: Error, message: "Error: The protocol must be type of string."}); |
|
||||
|
|
||||
// wrong protocol
|
|
||||
await t.throwsAsync(async () => {await nodeUfw.allow.port(12, "SDSD")}, {instanceOf: Error, message: 'Error: The protocol must be either "tcp" or "udp"'}); |
|
||||
await t.throwsAsync(async () => {await nodeUfw.deny.port(12, "SDSD")}, {instanceOf: Error, message: 'Error: The protocol must be either "tcp" or "udp"'}); |
|
||||
}); |
|
||||
|
|
||||
test("status raw cond", async (t) => { |
|
||||
t.pass(await nodeUfw.status(true)); |
|
||||
}); |
|
||||
|
|
||||
test("parsed status", async (t) => { |
|
||||
t.pass(await nodeUfw.status()); |
|
||||
}); |
|
||||
|
|
||||
test("sfw disabled", async (t) => { |
|
||||
t.true(await nodeUfw.disable()); |
|
||||
}); |
|
||||
|
|
||||
test("sfw enabled", async (t) => { |
|
||||
t.true(await nodeUfw.enable()); |
|
||||
}); |
|
||||
|
|
||||
test("check version", async (t) => { |
|
||||
t.true(nodeUfwUtil.checkNodeVersion()); |
|
||||
t.true(nodeUfwUtil.checkPlatform()); |
|
||||
t.true(await nodeUfwUtil.checkPlatformExact()); |
|
||||
}); |
|
Loading…
Reference in new issue