Comparing version 1.1.3 to 1.1.4
@@ -7,3 +7,3 @@ /*jslint node: true */ | ||
var Joi = require('joi'), | ||
combinatorics = require('js-combinatorics').Combinatorics, | ||
combinatorics = require('js-combinatorics'), | ||
queryString = require('query-string'), | ||
@@ -27,3 +27,2 @@ _ = require('lodash'), | ||
userTests = settings.plugins.patronus.testValues; | ||
} | ||
@@ -57,4 +56,2 @@ | ||
// example combo: { payload: [ { name: 'username'...} ] } | ||
// reset the test | ||
var test = { | ||
@@ -76,3 +73,3 @@ description: settings.description, | ||
status: undefined, | ||
schema: settings.response && Joi.compile(settings.response.schema) | ||
schema: (settings.response && settings.response.schema) && Joi.compile(settings.response.schema) | ||
} | ||
@@ -79,0 +76,0 @@ }; |
@@ -97,3 +97,2 @@ /*jslint node: true */ | ||
exports.assert = function (raw, responseObj) { | ||
if (responseObj.status && responseObj.status[raw.statusCode]) { | ||
@@ -100,0 +99,0 @@ return joiAssert(raw.result, responseObj.status[raw.statusCode], 'Response check'); |
{ | ||
"name": "patronus", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Specification-driven REST API testing", | ||
@@ -28,15 +28,15 @@ "main": "lib/Patronus.js", | ||
"dependencies": { | ||
"joi": "^6.0.0", | ||
"joi": "^10.0.5", | ||
"joi-assert": "0.0.3", | ||
"js-combinatorics": "^0.4.0", | ||
"lodash": "^3.6.0", | ||
"query-string": "^1.0.0" | ||
"js-combinatorics": "^0.5.2", | ||
"lodash": "^4.17.2", | ||
"query-string": "^4.2.3" | ||
}, | ||
"devDependencies": { | ||
"hapi": "^8.4.0", | ||
"hapi-auth-bearer-token": "^3.1.1", | ||
"istanbul": "^0.3.8", | ||
"mocha": "^2.2.0", | ||
"mocha-lcov-reporter": "^0.0.2" | ||
"hapi": "^16.0.1", | ||
"hapi-auth-bearer-token": "^4.3.1", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.2.0", | ||
"mocha-lcov-reporter": "^1.2.0" | ||
} | ||
} |
@@ -14,9 +14,10 @@ (function() { | ||
var genaricTestRun = function(server, tests) { | ||
tests.user.forEach(function (test) { | ||
it(test.description, function(done) { | ||
server.inject(test.request, function(res) { | ||
Patronus.assert(res, test.response); | ||
done(); | ||
}); | ||
server.inject(test.request) | ||
.then(res => { | ||
Patronus.assert(res, test.response); | ||
}) | ||
.then(done) | ||
.catch(done); | ||
}); | ||
@@ -27,3 +28,2 @@ }); | ||
var testShouldFail = function(server, tests) { | ||
tests.user.forEach(function (test) { | ||
@@ -52,4 +52,7 @@ it(test.description, function(done) { | ||
server.connection({ port: 9999, labels: 'api' }); | ||
server.connection({ port: 9998, labels: 'web' }); | ||
var apiServer = server.select('api'); | ||
describe('test basic route gathering', function() { | ||
@@ -75,5 +78,3 @@ var route = '/basic'; | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, apiServer)); | ||
}); | ||
@@ -152,4 +153,2 @@ | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
@@ -191,4 +190,2 @@ | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
@@ -258,4 +255,2 @@ | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
@@ -378,18 +373,3 @@ | ||
var tests = Patronus.testsFromRoute(method, route, server); | ||
tests.user.forEach(function (test) { | ||
it(test.description, function(done) { | ||
apiServer.inject(test.request, function(res) { | ||
try { | ||
Patronus.assert(res, test.response); | ||
} catch(e) { | ||
assert.ifError(e); | ||
} finally { | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
}); | ||
@@ -446,3 +426,2 @@ | ||
describe('should run tests from just select routes', function() { | ||
server.connection({ port: 9998, labels: 'web' }); | ||
var webServer = server.select('web'); | ||
@@ -487,32 +466,65 @@ | ||
}); | ||
}); | ||
apiServer.route({ | ||
method: method, | ||
path: route, | ||
config: { | ||
description: 'Test for an auth token of 1234', | ||
auth: 'simple', | ||
response: { | ||
schema: Joi.object({ | ||
success: Joi.boolean() | ||
}) | ||
apiServer.route({ | ||
method: method, | ||
path: route, | ||
config: { | ||
description: 'Test for an auth token of 1234', | ||
auth: 'simple', | ||
response: { | ||
schema: Joi.object({ | ||
success: Joi.boolean() | ||
}) | ||
}, | ||
plugins:{ | ||
patronus: { | ||
testValues: [{ | ||
username: 'user-name', | ||
password: 'user-name', | ||
__auth: { | ||
headers: { | ||
authorization: 'Bearer 1234' | ||
} | ||
} | ||
}] | ||
} | ||
} | ||
}, | ||
plugins:{ | ||
patronus: { | ||
testValues: [{ | ||
username: 'user-name', | ||
password: 'user-name', | ||
__auth: { | ||
headers: { | ||
authorization: 'Bearer 1234' | ||
handler: function(request, reply) { | ||
reply({success: true}); | ||
} | ||
}); | ||
apiServer.route({ | ||
method: 'POST', | ||
path: '/auth/optional', | ||
config: { | ||
description: 'Test for an auth token of 1234', | ||
auth: { | ||
strategies: ['simple'], | ||
mode: 'optional' | ||
}, | ||
response: { | ||
schema: Joi.object({ | ||
success: Joi.boolean() | ||
}) | ||
}, | ||
plugins:{ | ||
patronus: { | ||
testValues: [{ | ||
username: 'user-name', | ||
password: 'user-name', | ||
__auth: { | ||
headers: { | ||
authorization: 'Bearer 1234' | ||
} | ||
} | ||
} | ||
}] | ||
}] | ||
} | ||
} | ||
}, | ||
handler: function(request, reply) { | ||
reply({success: true}); | ||
} | ||
}, | ||
handler: function(request, reply) { | ||
reply({success: true}); | ||
} | ||
}); | ||
}); | ||
@@ -528,37 +540,3 @@ | ||
apiServer.route({ | ||
method: method, | ||
path: route, | ||
config: { | ||
description: 'Test for an auth token of 1234', | ||
auth: { | ||
strategies: ['simple'], | ||
mode: 'optional' | ||
}, | ||
response: { | ||
schema: Joi.object({ | ||
success: Joi.boolean() | ||
}) | ||
}, | ||
plugins:{ | ||
patronus: { | ||
testValues: [{ | ||
username: 'user-name', | ||
password: 'user-name', | ||
__auth: { | ||
headers: { | ||
authorization: 'Bearer 1234' | ||
} | ||
} | ||
}] | ||
} | ||
} | ||
}, | ||
handler: function(request, reply) { | ||
reply({success: true}); | ||
} | ||
}); | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
}); | ||
@@ -603,6 +581,4 @@ | ||
genaricTestRun(apiServer, Patronus.testsFromRoute(method, route, server)); | ||
}); | ||
}); | ||
})(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76799
10
1088
1
+ Addedhoek@4.3.1(transitive)
+ Addedisemail@2.2.1(transitive)
+ Addeditems@2.2.1(transitive)
+ Addedjoi@10.6.0(transitive)
+ Addedjs-combinatorics@0.5.5(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedquery-string@4.3.4(transitive)
+ Addedstrict-uri-encode@1.1.0(transitive)
+ Addedtopo@2.1.1(transitive)
- Removedhoek@2.16.3(transitive)
- Removedisemail@1.2.0(transitive)
- Removedjoi@6.10.1(transitive)
- Removedjs-combinatorics@0.4.1(transitive)
- Removedlodash@3.10.1(transitive)
- Removedmoment@2.30.1(transitive)
- Removedquery-string@1.0.1(transitive)
- Removedtopo@1.1.0(transitive)
Updatedjoi@^10.0.5
Updatedjs-combinatorics@^0.5.2
Updatedlodash@^4.17.2
Updatedquery-string@^4.2.3