All Projects → shutterstock → Ntf

shutterstock / Ntf

Licence: mit
Network Testing Framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ntf

Ten34
A globally-distributed, eventually-consistent, 100% available key-value store ;)
Stars: ✭ 87 (-9.37%)
Mutual labels:  dns
Tyu
Unit test with no initial configuration.
Stars: ✭ 89 (-7.29%)
Mutual labels:  test
Devel Cover
Code coverage metrics for Perl
Stars: ✭ 91 (-5.21%)
Mutual labels:  test
Elixir Dns
DNS library for Elixir
Stars: ✭ 86 (-10.42%)
Mutual labels:  dns
Scalatestplus Play
ScalaTest + Play
Stars: ✭ 88 (-8.33%)
Mutual labels:  test
Rebar3
Erlang build tool that makes it easy to compile and test Erlang applications and releases.
Stars: ✭ 1,295 (+1248.96%)
Mutual labels:  test
Snapper
Bringing Jest-esque Snapshot testing to C#
Stars: ✭ 85 (-11.46%)
Mutual labels:  test
Kotlinfixture
Fixtures for Kotlin providing generated values for unit testing
Stars: ✭ 94 (-2.08%)
Mutual labels:  test
Test Each
🤖 Repeat tests. Repeat tests. Repeat tests.
Stars: ✭ 89 (-7.29%)
Mutual labels:  test
Bind Restapi
A RESTful json api to BIND DNS
Stars: ✭ 91 (-5.21%)
Mutual labels:  dns
Dnss
DNS over HTTPS [mirror]
Stars: ✭ 87 (-9.37%)
Mutual labels:  dns
.o
The domain records for the ".o" TLD on @OpenNIC. Claim your domain today!
Stars: ✭ 87 (-9.37%)
Mutual labels:  dns
Dnscrypt Protocol
DNSCrypt protocol specification
Stars: ✭ 91 (-5.21%)
Mutual labels:  dns
A11y.css
This CSS file intends to warn developers about possible risks and mistakes that exist in HTML code. It can also be used to roughly evaluate a site's quality by simply including it as an external stylesheet.
Stars: ✭ 1,277 (+1230.21%)
Mutual labels:  test
React Pinpoint
An open source utility library for measuring React component render times.
Stars: ✭ 93 (-3.12%)
Mutual labels:  test
Junitperf
⛵️Junit performance rely on junit5 and jdk8+.(java 性能测试框架)
Stars: ✭ 86 (-10.42%)
Mutual labels:  test
App Test Arch
Android 单元测试、Monkey、LeakCanary测试demo项目【粗略示例】
Stars: ✭ 90 (-6.25%)
Mutual labels:  test
Cazador unr
Hacking tools
Stars: ✭ 95 (-1.04%)
Mutual labels:  dns
Faux Jax
NO MORE MAINTAINED: Intercept and respond to requests in the browser (AJAX) and Node.js (http(s) module)
Stars: ✭ 93 (-3.12%)
Mutual labels:  test
Packcheck
Universal build and CI testing for Haskell packages
Stars: ✭ 91 (-5.21%)
Mutual labels:  test

ntf Build Status

ntf is a network testing framework written in Node.js.

See the ntf homepage for more details about the ntf framework.

Getting Started

Install ntf

npm install ntf
npm install ntf -g

Create a file named ntfjs.org.js

var ntf = require('ntf')
  , test = ntf.http('http://ntfjs.org')

exports.homepage = test.get('/', function(test) {
  test.statusCode(200)
  test.body('ntf')
  test.done()
})

Run the tests

ntf ntfjs.org.js
## Documentation

DNS

HTTP

Socket

## DNS

Test DNS records.

var ntf = require('ntf')
  , dns = ntf.dns()
### dns.a(name, callback)

Resolve an IPv4 address record.

Arguments

  • name {String} - name to resolve
  • callback(test) {Function} - test callback

Example

exports.a = dns.a('a.dns.ntfjs.org', function(test) {
  test.address('127.0.0.1')
  test.done()
})
### dns.aaaa(name, callback)

Resolve an IPv6 address record.

Arguments

  • name {String} - name to resolve
  • callback(test) {Function} - test callback

Example

exports.aaaa = dns.aaaa('aaaa.dns.ntfjs.org', function(test) {
  test.address('::1')
  test.done()
})
### dns.cname(name, callback)

Resolve a canonical name record.

Arguments

  • name {String} - canonical name to resolve
  • callback(test) {Function} - test callback

Example

exports.cname = dns.cname('cname.dns.ntfjs.org', function(test) {
  test.name('a.dns.ntfjs.org')
  test.done()
})
### dns.mx(name, callback)

Resolve a mail exchange record.

Arguments

  • name {String} - mail exchange to resolve
  • callback(test) {Function} - test callback

Example

exports.mx = dns.mx('mx.dns.ntfjs.org', function(test) {
  test.name('mx1.dns.ntfjs.org')
  test.done()
})
### dns.ns(name, callback)

Resolve a name server record.

Arguments

  • name {String} - name server to resolve
  • callback(test) {Function} - test callback

Example

exports.ns = dns.ns('ns.dns.ntfjs.org', function(test) {
  test.name('ns1.dns.ntfjs.org')
  test.done()
})
### dns.ptr(ip, callback)

Resolve a pointer record.

Arguments

  • name {String} - IP address to resolve
  • callback(test) {Function} - test callback

Example

exports.ptr = dns.ptr('50.116.49.237', function(test) {
  test.name('hub.sewell.org')
  test.done()
})
### dns.srv(name, callback)

Resolve a service location record.

Arguments

  • name {String} - service to resolve
  • callback(test) {Function} - test callback

Example

exports.srv = dns.srv('_ntfjs', function(test) {
  test.name('srv1.dns.ntfjs.org')
  test.done()
})
### dns.txt(name, callback)

Resolve a text record.

Arguments

  • name {String} - text to resolve
  • callback(test) {Function} - test callback

Example

exports.txt = dns.txt('_ntfjs', function(test) {
  test.done()
})
### test.address(ip)

Assert answer contains IP address.

Arguments

  • ip {String} - IP address to check

Example

exports.a = dns.a('a.dns.ntfjs.org', function(test) {
  test.address('127.0.0.1')
  test.done()
})
### test.name(name)

Assert answer contains name.

Arguments

  • name {String} - name to check

Example

exports.cname = dns.cname('cname.dns.ntfjs.org', function(test) {
  test.name('a.dns.ntfjs.org')
  test.done()
})
## HTTP

Test HTTP requests.

var ntf = require('ntf')
  , http = ntf.http('http://http.ntfjs.org')
### http.request(options, callback)

Execute an HTTP request.

__Arguments__
  • options {Object,String} - options or path/URL
    • auth {String} - username and password (ex: "user:pass")
    • body {Object,String} - request body
    • cookie {Object} - cookie names and values (ex: { "sid": "2bf74f" })
    • header {Object} - header names and values (ex: { "content-type": "application/json" })
    • jar {Boolean} - persist cookies in sub-requests
    • method {String} - HTTP method (delete, get, post, put)
    • timeout {Integer} - maximum number of milliseconds request can take before its killed
    • type {String} - encodes body and sets content-type header (form, json)
    • url {String} - path or URL
  • callback(test) {Function} - test callback

Example

exports.request = http.request('/', function(test) {
  test.statusCode(200)
  test.done()
})
### http.del(options, callback)

Execute an HTTP delete request.

Arguments

  • options {Object,String} - see request arguments
    • method {String} - always set to delete
  • callback(test) {Function} - test callback

Example

exports.del = http.del('/delete', function(test) {
  test.statusCode(200)
  test.done()
})
### http.get(options, callback)

Execute an HTTP get request.

Arguments

  • options {Object,String} - see request arguments
    • method {String} - always set to get
  • callback(test) {Function} - test callback

Example

exports.get = http.get('/get', function(test) {
  test.statusCode(200)
  test.done()
})
### http.head(options, callback)

Execute an HTTP head request.

Arguments

  • options {Object,String} - see request arguments
    • method {String} - always set to head
  • callback(test) {Function} - test callback

Example

exports.head = http.head('/head', function(test) {
  test.statusCode(200)
  test.done()
})
### http.options(options, callback)

Execute an HTTP options request.

Arguments

  • options {Object,String} - see request arguments
    • method {String} - always set to options
  • callback(test) {Function} - test callback

Example

exports.options = http.options('/options', function(test) {
  test.statusCode(200)
  test.done()
})
### http.patch(options, callback)

Execute an HTTP patch request.

Arguments

  • options {Object,String} - see request arguments
    • method {String} - always set to patch
  • callback(test) {Function} - test callback

Example

exports.patch = http.patch('/patch', function(test) {
  test.statusCode(200)
  test.done()
})
### http.post(options, callback)

Execute an HTTP post request.

Arguments

  • options {Object} - see request arguments
    • body {Object,String} - should be object by default (see type below)
    • method {String} - always set to post
    • type {String} - defaults to form
  • callback(test) {Function} - test callback

Example

exports.post = http.post({ url: '/post', body: { 'q': 'test' } }), function(test) {
  test.statusCode(201)
  test.done()
})
### http.put(options, callback)

Execute an HTTP put request.

Arguments

  • options {Object} - see request arguments
    • method {String} - always set to put
  • callback(test) {Function} - test callback

Example

exports.put = http.put({ url: '/put', body: 'put' }), function(test) {
  test.statusCode(201)
  test.done()
})
### test.body([match[, compare...]])

Tests match against body and returns result.

Arguments

  • match
    • RegExp - asserts body matches RegExp
      • compare {String} - compare against match results
      • return {Array,null} - RegExp match result
    • String - asserts body contains match
      • return {Integer} - first position of matched result
    • undefined
      • return {String,undefined} - body String

Example

exports.get = http.get('/', function(test) {
  test.body(/<title>(.*)<\/title>/, 'ntf')
  test.done()
})
### test.cookie([name[, match]])

Tests cookie existence/value and returns match.

Arguments

  • name {String} - cookie name
  • match
    • RegExp - asserts value matches RegExp
      • return {Array,null} - RegExp match result
    • String - asserts value matches String
    • undefined
      • return {Object,undefined} - cookie object

Example

exports.get = http.get('/', function(test) {
  test.cookie('sid', /^[a-f0-9]+$/)
  test.done()
})
### test.header([name[, match]])

Tests header existence/value and returns match.

Arguments

  • name {String} - header name
  • match
    • RegExp - asserts value matches RegExp
      • return {Array,null} - RegExp match result
    • String - asserts value matches String
    • undefined
      • return {Object,undefined} - header object

Example

exports.get = http.get('/', function(test) {
  test.header('Content-Type', 'text/html')
  test.done()
})
### test.json([match])

Tests body against match and returns parsed JSON.

Arguments

  • match - deep equal assert against match
  • return - parsed JSON object

Example

exports.get = http.get('/', function(test) {
  test.json({ one: 'two' })
  test.done()
})
### test.jsonPath([path[, compare...]])

Tests json path against compares and returns result.

Arguments

  • path {String} - json path (examples)
  • compare - compare against json path results
  • return {Array} - parsed JSON object

Example

exports.get = http.get('/', function(test) {
  test.jsonPath('$.book.title', 'Second Foundation', "The Wise Man's Fear")
  test.done()
})
### test.statusCode(code)

Tests response status code.

Arguments

  • code {Integer} - status code

Example

exports.get = http.get('/', function(test) {
  test.statusCode(200)
  test.done()
})
## Socket

Test socket connections.

var ntf = require('ntf')
  , socket = ntf.socket('ntfjs.org')
### socket.tcp(port, callback)

Open TCP connection to host and port.

Arguments

  • options {Integer,Object} - port or options
    • port {Integer} - port
    • timeout {Integer} - maximum number of milliseconds before connection is killed
  • callback(test) {Function} - test callback

Example

exports.tcp = socket.tcp(25, function(test) {
  test.connect()
  test.done()
})
### test.connect(code)

Tests connection was opened.

Example

exports.tcp = socket.tcp(25, function(test) {
  test.connect()
  test.done()
})

License

MIT © 2011-2017 Shutterstock Images, LLC

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].