-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test: | ||
NODE_ENV=test ./node_modules/mocha/bin/mocha --recursive --timeout 5000 --reporter spec | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"name" : "netfilter", | ||
"version" : "0.2.3", | ||
"description" : "Packet filtering framework. Wrapper to provide netfilter capabilities from Node.js", | ||
"main" : "index.js", | ||
"keywords" : [ | ||
"name" : "netfilter", | ||
"version" : "0.2.3", | ||
"description" : "Packet filtering framework. Wrapper to provide netfilter capabilities from Node.js", | ||
"main" : "index.js", | ||
"keywords" : [ | ||
"stateless", | ||
"stateful", | ||
"packet", | ||
|
@@ -27,28 +27,32 @@ | |
"alias", | ||
"set" | ||
], | ||
"dependencies": { | ||
"dependencies" : { | ||
"async" : "~0.9.0", | ||
"process-queue": "^1.0.1", | ||
"shell-quote" : "^1.4.2" | ||
}, | ||
"engines" : { | ||
"devDependencies": { | ||
"should" : "~4.0.4", | ||
"mocha" : "~1.20.1" | ||
}, | ||
"engines" : { | ||
"node": ">=0.8.0" | ||
}, | ||
"homepage" : "https://github.com/diosney/node-netfilter", | ||
"bugs" : { | ||
"homepage" : "https://github.com/diosney/node-netfilter", | ||
"bugs" : { | ||
"url": "https://github.com/diosney/node-netfilter/issues" | ||
}, | ||
"author" : { | ||
"author" : { | ||
"name" : "Diosney Sarmiento", | ||
"email": "[email protected]" | ||
}, | ||
"license" : "MIT", | ||
"repository" : { | ||
"license" : "MIT", | ||
"repository" : { | ||
"type": "git", | ||
"url" : "https://github.com/diosney/node-netfilter.git" | ||
}, | ||
"scripts" : { | ||
"scripts" : { | ||
"test": "node test/*.js" | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
test/unit/iptables/fixtures/utils.processCommonRuleSpecs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module.exports = [ | ||
{ | ||
options: { | ||
protocol : 'tcp', | ||
source : '!10.10.10.0/24', | ||
destination : '11.11.11.0/24', | ||
'in-interface' : 'eth0', | ||
'out-interface': 'eth1', | ||
|
||
matches: { | ||
cluster: { | ||
'cluster-total-nodes': 2, | ||
'cluster-local-node' : 1, | ||
'cluster-hash-seed' : '0xdeadbeef' | ||
}, | ||
comment: { | ||
comment: 'Some comment.' | ||
} | ||
}, | ||
|
||
jump : 'AUDIT', | ||
target_options: { | ||
type: 'drop' | ||
} | ||
}, | ||
|
||
args: [ | ||
'--protocol', | ||
'tcp', | ||
'!', | ||
'--source', | ||
'10.10.10.0/24', | ||
'--destination', | ||
'11.11.11.0/24', | ||
'--in-interface', | ||
'eth0', | ||
'--out-interface', | ||
'eth1', | ||
'--match', | ||
'cluster', | ||
'--cluster-total-nodes', | ||
'2', | ||
'--cluster-local-node', | ||
'1', | ||
'--cluster-hash-seed', | ||
'0xdeadbeef', | ||
'--match', | ||
'comment', | ||
'--comment', | ||
'Some comment.', | ||
'--jump', | ||
'AUDIT', | ||
'--type', | ||
'drop' | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var should = require('should'); | ||
|
||
var utils = require('../../../lib/iptables/utils'); | ||
var fixtures = require('./fixtures/utils.processCommonRuleSpecs'); | ||
|
||
describe('iptables', function () { | ||
describe('#utils', function () { | ||
it('should be defined', function () { | ||
should.exist(utils); | ||
}); | ||
|
||
describe('#tables{}', function () { | ||
it('should be defined', function () { | ||
should.exist(utils.tables); | ||
}); | ||
|
||
it('should have its already known properties', function () { | ||
utils.tables.should.have.properties( | ||
{ | ||
filter : 'filter', | ||
nat : 'nat', | ||
mangle : 'mangle', | ||
raw : 'raw', | ||
security: 'security' | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#processCommonRuleSpecs()', function () { | ||
it('should be defined', function () { | ||
should.exist(utils.processCommonRuleSpecs); | ||
}); | ||
|
||
describe('when seed with several options', function () { | ||
it('should return a correct array representation of those options', function () { | ||
for (var i = 0, j = fixtures.length; | ||
i < j; | ||
i++) { | ||
|
||
var common_rule_specs = utils.processCommonRuleSpecs(fixtures[i].options); | ||
common_rule_specs.should.be.eql(fixtures[i].args); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |