@pact-foundation/pact-node
Advanced tools
Comparing version 4.8.3 to 4.9.0
{ | ||
"name": "@pact-foundation/pact-node", | ||
"version": "4.8.3", | ||
"version": "4.9.0", | ||
"description": "A wrapper for the Ruby version of Pact to work within Node", | ||
@@ -40,5 +40,5 @@ "main": "./src/pact.js", | ||
"dependencies": { | ||
"@pact-foundation/pact-mock-service": "1.x.x", | ||
"@pact-foundation/pact-provider-verifier": "1.x.x", | ||
"bunyan": "^1.8.5", | ||
"@pact-foundation/pact-mock-service": "~1.2.0", | ||
"@pact-foundation/pact-provider-verifier": "~1.1.1", | ||
"bunyan": "^1.8.10", | ||
"bunyan-prettystream": "^0.1.3", | ||
@@ -48,7 +48,7 @@ "check-types": "~7.1.5", | ||
"mkdirp": "^0.5.1", | ||
"q": "^1.4.1", | ||
"request": "^2.79.0", | ||
"q": "^1.5.0", | ||
"request": "^2.81.0", | ||
"underscore": "^1.8.3", | ||
"unixify": "^0.2.1", | ||
"url-join": "^1.1.0" | ||
"unixify": "^1.0.0", | ||
"url-join": "^2.0.1" | ||
}, | ||
@@ -60,14 +60,14 @@ "bin": { | ||
"basic-auth": "^1.1.0", | ||
"body-parser": "^1.16.0", | ||
"body-parser": "^1.17.1", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"cors": "^2.8.1", | ||
"cross-env": "^3.1.4", | ||
"express": "^4.14.1", | ||
"cors": "^2.8.3", | ||
"cross-env": "^4.0.0", | ||
"express": "^4.15.2", | ||
"jscs": "3.0.7", | ||
"mocha": "^3.2.0", | ||
"mocha": "^3.3.0", | ||
"nodemon": "^1.11.0", | ||
"rewire": "^2.5.2", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^1.17.7" | ||
"rimraf": "^2.6.1", | ||
"sinon": "~2.2.0" | ||
}, | ||
@@ -74,0 +74,0 @@ "scripts": { |
@@ -70,2 +70,4 @@ <img src="https://raw.githubusercontent.com/pact-foundation/pact-logo/master/media/logo-black.png" width="200"> | ||
pactBrokerPassword: <String>, // Password for Pact Broker basic authentication. Optional | ||
publishVerificationResult: <Boolean> // Publish verification result to Broker. Optional | ||
providerVersion: <Boolean> // Provider version, required to publish verification result to Broker. Optional otherwise. | ||
timeout: <Number> // The duration in ms we should wait to confirm verification process was successful. Defaults to 30000, Optional. | ||
@@ -72,0 +74,0 @@ }; |
@@ -15,3 +15,3 @@ var checkTypes = require('check-types'), | ||
// Constructor | ||
function Verifier(providerBaseUrl, pactUrls, providerStatesUrl, providerStatesSetupUrl, pactBrokerUsername, pactBrokerPassword, timeout) { | ||
function Verifier(providerBaseUrl, pactUrls, providerStatesUrl, providerStatesSetupUrl, pactBrokerUsername, pactBrokerPassword, publishVerificationResult, providerVersion, timeout) { | ||
this._options = {}; | ||
@@ -24,2 +24,4 @@ this._options.providerBaseUrl = providerBaseUrl; | ||
this._options.pactBrokerPassword = pactBrokerPassword; | ||
this._options.publishVerificationResult = publishVerificationResult; | ||
this._options.providerVersion = providerVersion; | ||
this._options.timeout = timeout; | ||
@@ -56,3 +58,5 @@ } | ||
'pactBrokerUsername': '--broker-username', | ||
'pactBrokerPassword': '--broker-password' | ||
'pactBrokerPassword': '--broker-password', | ||
'publishVerificationResult': '--publish-verification-results', | ||
'providerVersion': '--provider-app-version' | ||
}); | ||
@@ -153,5 +157,17 @@ | ||
if (options.publishVerificationResult) { | ||
checkTypes.assert.boolean(options.publishVerificationResult); | ||
} | ||
if (options.publishVerificationResult && !options.providerVersion) { | ||
throw new Error('Must provide both or none of --publish-verification-results and --provider-app-version.'); | ||
} | ||
if (options.providerVersion) { | ||
checkTypes.assert.string(options.providerVersion); | ||
} | ||
checkTypes.assert.positive(options.timeout); | ||
return new Verifier(options.providerBaseUrl, options.pactUrls, options.providerStatesUrl, options.providerStatesSetupUrl, options.pactBrokerUsername, options.pactBrokerPassword, options.timeout); | ||
return new Verifier(options.providerBaseUrl, options.pactUrls, options.providerStatesUrl, options.providerStatesSetupUrl, options.pactBrokerUsername, options.pactBrokerPassword, options.publishVerificationResult, options.providerVersion, options.timeout); | ||
}; |
@@ -25,3 +25,3 @@ var verifierFactory = require('./verifier'), | ||
expect(function () { | ||
verifierFactory({"providerStatesUrl": "http://foo/provider-states"}); | ||
verifierFactory({ "providerStatesUrl": "http://foo/provider-states" }); | ||
}).to.throw(Error); | ||
@@ -33,3 +33,3 @@ }); | ||
expect(function () { | ||
verifierFactory({"providerStatesSetupUrl": "http://foo/provider-states/setup"}); | ||
verifierFactory({ "providerStatesSetupUrl": "http://foo/provider-states/setup" }); | ||
}).to.throw(Error); | ||
@@ -58,3 +58,4 @@ }); | ||
}); | ||
}); | ||
}); | ||
context("when given remote Pact URLs that don't exist", function () { | ||
@@ -80,2 +81,34 @@ it("should pass through to the Pact Verifier regardless", function () { | ||
}); | ||
context("when requested to publish verification results to a Pact Broker", function () { | ||
context("and specifies a provider version", function () { | ||
it("should pass through to the Pact Verifier", function () { | ||
expect(function () { | ||
verifierFactory({ | ||
providerBaseUrl: "http://localhost", | ||
pactUrls: ["http://idontexist"], | ||
publishVerificationResult: true, | ||
providerVersion: "1.0.0" | ||
}); | ||
}).to.not.throw(Error); | ||
}); | ||
}); | ||
}); | ||
context("when requested to publish verification results to a Pact Broker", function () { | ||
context("and does not specify provider version", function () { | ||
it("should fail with an error", function () { | ||
expect(function () { | ||
verifierFactory({ | ||
providerBaseUrl: "http://localhost", | ||
pactUrls: ["http://idontexist"], | ||
publishVerificationResult: true | ||
}); | ||
}).to.throw(Error); | ||
}); | ||
}); | ||
}); | ||
context("when given the correct arguments", function () { | ||
@@ -82,0 +115,0 @@ it("should return a Verifier object", function () { |
@@ -9,3 +9,3 @@ var cors = require('cors'), | ||
server.use(bodyParser.json()); | ||
server.use(bodyParser.urlencoded({extended: true})); | ||
server.use(bodyParser.urlencoded({ extended: true })); | ||
@@ -15,11 +15,11 @@ var stateData = ""; | ||
server.get('/', function (req, res) { | ||
res.json({greeting: 'Hello'}); | ||
res.json({ greeting: 'Hello' }); | ||
}); | ||
server.get('/fail', function (req, res) { | ||
res.json({greeting: 'Oh noes!'}); | ||
res.json({ greeting: 'Oh noes!' }); | ||
}); | ||
server.get('/provider-states', function (req, res) { | ||
res.json({me: ["There is a greeting"], anotherclient: ["There is a greeting"]}); | ||
res.json({ me: ["There is a greeting"], anotherclient: ["There is a greeting"] }); | ||
}); | ||
@@ -29,11 +29,11 @@ | ||
stateData = "State data!"; | ||
res.json({greeting: stateData}); | ||
res.json({ greeting: stateData }); | ||
}); | ||
server.get('/somestate', function (req, res) { | ||
res.json({greeting: stateData}); | ||
res.json({ greeting: stateData }); | ||
}); | ||
server.post('/', function (req, res) { | ||
res.json({greeting: "Hello " + req.body.name}); | ||
res.json({ greeting: "Hello " + req.body.name }); | ||
}); | ||
@@ -74,2 +74,7 @@ | ||
// Verification result | ||
server.post('/pacts/provider/:provider/consumer/:consumer/pact-version/:version/verification-results', function (req, res) { | ||
res.json({}); | ||
}); | ||
server.get('/pacts/provider/they/consumer/me/latest', auth, function (req, res) { | ||
@@ -76,0 +81,0 @@ var obj = JSON.parse('{"consumer":{"name":"me"},"provider":{"name":"they"},"interactions":[{"description":"Provider state success","provider_state":"There is a greeting","request":{"method":"GET","path":"/somestate"},"response":{"status":200,"headers":{},"body":{"greeting":"State data!"}}}],"metadata":{"pactSpecificationVersion":"2.0.0"},"updatedAt":"2016-05-15T00:09:33+00:00","createdAt":"2016-05-15T00:09:06+00:00","_links":{"self":{"title":"Pact","name":"Pact between me (v1.0.0) and they","href":"http://pact.onegeek.com.au/pacts/provider/they/consumer/me/version/1.0.0"},"pb:consumer":{"title":"Consumer","name":"me","href":"http://pact.onegeek.com.au/pacticipants/me"},"pb:provider":{"title":"Provider","name":"they","href":"http://pact.onegeek.com.au/pacticipants/they"},"pb:latest-pact-version":{"title":"Pact","name":"Latest version of this pact","href":"http://pact.onegeek.com.au/pacts/provider/they/consumer/me/latest"},"pb:previous-distinct":{"title":"Pact","name":"Previous distinct version of this pact","href":"http://pact.onegeek.com.au/pacts/provider/they/consumer/me/version/1.0.0/previous-distinct"},"pb:diff-previous-distinct":{"title":"Diff","name":"Diff with previous distinct version of this pact","href":"http://pact.onegeek.com.au/pacts/provider/they/consumer/me/version/1.0.0/diff/previous-distinct"},"pb:pact-webhooks":{"title":"Webhooks for the pact between me and they","href":"http://pact.onegeek.com.au/webhooks/provider/they/consumer/me"},"pb:tag-prod-version":{"title":"Tag this version as \'production\'","href":"http://pact.onegeek.com.au/pacticipants/me/versions/1.0.0/tags/prod"},"pb:tag-version":{"title":"Tag version","href":"http://pact.onegeek.com.au/pacticipants/me/versions/1.0.0/tags/{tag}"},"curies":[{"name":"pb","href":"http://pact.onegeek.com.au/doc/{rel}","templated":true}]}}'); |
@@ -16,3 +16,3 @@ var verifierFactory = require('./../src/verifier.js'), | ||
var server, | ||
PORT = Math.floor(Math.random() * 999) + 9000, | ||
PORT = 9123, | ||
providerBaseUrl = 'http://localhost:' + PORT, | ||
@@ -57,3 +57,3 @@ providerStatesUrl = providerBaseUrl + '/provider-states', | ||
context("with POST data", function () { | ||
context("with POST data", function () { | ||
it("should return a successful promise", function () { | ||
@@ -68,3 +68,3 @@ var verifier = verifierFactory({ | ||
context("with POST data and regex validation", function () { | ||
context("with POST data and regex validation", function () { | ||
it("should return a successful promise", function () { | ||
@@ -174,2 +174,31 @@ var verifier = verifierFactory({ | ||
}); | ||
context("when publishing verification results to a Pact Broker", function () { | ||
context("and there is a valid verification HAL link in the Pact file", function () { | ||
it("should return a successful promise", function () { | ||
var verifier = verifierFactory({ | ||
providerBaseUrl: providerBaseUrl, | ||
pactUrls: [path.resolve(__dirname, "integration/publish-verification-example-success.json")], | ||
providerStatesUrl: providerStatesUrl, | ||
providerStatesSetupUrl: providerStatesSetupUrl, | ||
publishVerificationResult: true, | ||
providerVersion: "1.0.0" | ||
}); | ||
return expect(verifier.verify()).to.eventually.be.fulfilled; | ||
}); | ||
}) | ||
context("and there is an invalid verification HAL link in the Pact file", function () { | ||
it("should fail with an error", function () { | ||
var verifier = verifierFactory({ | ||
providerBaseUrl: providerBaseUrl, | ||
pactUrls: [path.resolve(__dirname, "integration/publish-verification-example-fail.json")], | ||
providerStatesUrl: providerStatesUrl, | ||
providerStatesSetupUrl: providerStatesSetupUrl, | ||
publishVerificationResult: true, | ||
providerVersion: "1.0.0" | ||
}); | ||
return expect(verifier.verify()).to.eventually.be.fulfilled; | ||
}); | ||
}) | ||
}); | ||
}); |
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
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
113008
44
2813
177
+ Added@pact-foundation/pact-provider-verifier@1.1.1(transitive)
+ Added@pact-foundation/pact-provider-verifier-darwin@1.1.1(transitive)
+ Added@pact-foundation/pact-provider-verifier-linux-ia32@1.1.1(transitive)
+ Added@pact-foundation/pact-provider-verifier-linux-x64@1.1.1(transitive)
+ Added@pact-foundation/pact-provider-verifier-win32@1.1.1(transitive)
+ Addedunixify@1.0.0(transitive)
+ Addedurl-join@2.0.5(transitive)
- Removed@pact-foundation/pact-provider-verifier@1.4.3(transitive)
- Removed@pact-foundation/pact-provider-verifier-darwin@1.4.3(transitive)
- Removed@pact-foundation/pact-provider-verifier-linux-ia32@1.4.3(transitive)
- Removed@pact-foundation/pact-provider-verifier-linux-x64@1.4.3(transitive)
- Removed@pact-foundation/pact-provider-verifier-win32@1.4.3(transitive)
- Removedunixify@0.2.1(transitive)
- Removedurl-join@1.1.0(transitive)
Updatedbunyan@^1.8.10
Updatedq@^1.5.0
Updatedrequest@^2.81.0
Updatedunixify@^1.0.0
Updatedurl-join@^2.0.1