Comparing version 0.3.3 to 0.3.4
exports.ServiceSync = require('./service.gen.sync'); | ||
exports.ServiceAsync = require('./service.gen.async'); | ||
exports.Api = require('./service.api'); | ||
exports.version = '0.3.3'; | ||
exports.version = '0.3.4'; |
{ | ||
"name": "bluecat", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Generic REST API Test Framework", | ||
@@ -20,6 +20,6 @@ "repository": { | ||
"dependencies": { | ||
"fibers": ">=1.0.5", | ||
"hoek": "^2.13.0", | ||
"promise": ">=7.0.1", | ||
"request": "2.55.0" | ||
"fibers": ">=1.0.7", | ||
"hoek": "^2.16.3", | ||
"promise": ">=7.0.4", | ||
"request": "2.67.0" | ||
}, | ||
@@ -31,8 +31,8 @@ "scripts": { | ||
"chai": "^2.3.0", | ||
"mocha": "^2.2.5", | ||
"mocha": "^2.3.4", | ||
"grunt-cli": "^0.1.13", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-jshint": "^0.11.2", | ||
"grunt-jscs": "^1.8.0" | ||
"grunt-contrib-jshint": "^0.11.3", | ||
"grunt-jscs": "^2.4.0" | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
## Bluecat | ||
## Bluecat <img src="https://raw.github.com/chenchaoyi/bluecat/master/images/bluecat.png" align="middle" /> | ||
[![NPM version][npm-image]][npm-url] | ||
[![Build Status](https://travis-ci.org/chenchaoyi/bluecat.svg?branch=master)](https://travis-ci.org/chenchaoyi/bluecat) | ||
[![Dependency Status][david-image]][david-url] | ||
@@ -35,2 +37,8 @@ [![Downloads][downloads-image]][downloads-url] | ||
## Example ## | ||
#### Regular RESTful API | ||
``` | ||
POST /checkout/contract | ||
GET /checkout/contract | ||
``` | ||
* First define your API in config/api.json: | ||
@@ -40,6 +48,6 @@ | ||
{ | ||
"mobileapi": { | ||
"typeahead": { | ||
"api": { | ||
"checkout": { | ||
"schema": "http", | ||
"method": ["GET"] | ||
"method": ["GET", "POST"] | ||
} | ||
@@ -50,3 +58,3 @@ } | ||
* Then in your test suite (example, using Mocha): | ||
* Then create a Bluecat service object. You are all set to send request and validate response: | ||
@@ -56,29 +64,24 @@ ```javascript | ||
var Bluecat = require('bluecat'); | ||
var Api = Bluecat.Api('mobileapi'); | ||
var Service = new Bluecat.ServiceSync(Bluecat.Api('api'), 'sample-host.com'); | ||
describe('typeahead service test suite', function() { | ||
// All requests need to be put into Api.run(), so they will run synchronously | ||
Service.run(function() { | ||
// send POST http://sample-host.com/checkout/contract | ||
var r = Service.checkout.contract.POST({ | ||
body: { | ||
cartid: 'test-cart-id' | ||
} | ||
}); | ||
// verify response | ||
expect(r.data.statusCode).to.equal(200); | ||
expect(r.data.body).to.have.ownProperty('id'); | ||
before(function() { | ||
t = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
}) | ||
// send GET http://sample-host.com/checkout/contract | ||
// cookies are automatically maintained | ||
r = Service.checkout.contract.GET(); | ||
// verify response | ||
expect(r.data.statusCode).to.equal(200); | ||
expect(r.data.body.cartId).to.eql('test-cart-id'); | ||
}) | ||
it('GET typeahead?term=toy&cat=0&num=2', function(done) { | ||
t.run(function() { | ||
// send GET to http://api.mobile.walmart.com/typeahead?term=toy&cat=0&num=2 | ||
var r = t.typeahead.GET({ | ||
query: { | ||
term: 'toy', | ||
cat: 0, | ||
num: 2 | ||
} | ||
}); | ||
// verify response | ||
expect(r.err).to.equal(null); | ||
expect(r.data.statusCode).to.equal(200); | ||
expect(r.data.body).to.have.ownProperty('specific'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
``` | ||
@@ -96,3 +99,3 @@ | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com', { | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com', { | ||
gzip: true | ||
@@ -108,5 +111,5 @@ }); | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var r = lapetus.rawRequest({ | ||
var r = Service.rawRequest({ | ||
method: 'GET', | ||
@@ -126,5 +129,5 @@ json: true, | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
service.setProxy('http://127.0.0.1:8888') | ||
Service.setProxy('http://127.0.0.1:8888') | ||
``` | ||
@@ -138,7 +141,7 @@ | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
service.v1.products.search.GET(); | ||
service.resetCookie(); | ||
service.v1.cart.POST({ | ||
Service.v1.products.search.GET(); | ||
Service.resetCookie(); | ||
Service.v1.cart.POST({ | ||
body: { | ||
@@ -156,5 +159,5 @@ location: '94066' | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
service.setHeaders({'User-Agent': 'Automation'}); | ||
Service.setHeaders({'User-Agent': 'Automation'}); | ||
``` | ||
@@ -168,3 +171,3 @@ | ||
var Api = Bluecat.Api('mobileapi'); | ||
var service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
var Service = new Bluecat.ServiceSync(Api, 'api.mobile.walmart.com'); | ||
@@ -174,3 +177,3 @@ // The following sessions rules start with 'start-auth-token-value' in the request header AUTH_TOKEN, | ||
// and put it in the next request header AUTH_TOKEN | ||
service.setSessionRules({ | ||
Service.setSessionRules({ | ||
requestHeader: 'AUTH_TOKEN', | ||
@@ -177,0 +180,0 @@ responseHeader: 'REFRESH_AUTH_TOKEN', |
Sorry, the diff of this file is not supported yet
25504
13
199
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@0.2.01.0.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbl@1.0.3(transitive)
+ Addedcaseless@0.11.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedform-data@1.0.1(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-validator@2.0.6(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprocess-nextick-args@1.0.7(transitive)
+ Addedqs@5.2.1(transitive)
+ Addedreadable-stream@2.0.6(transitive)
+ Addedrequest@2.67.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.2.2(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedcaseless@0.9.0(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedform-data@0.2.0(transitive)
- Removedhar-validator@1.8.0(transitive)
- Removedhawk@2.3.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmime-db@1.12.0(transitive)
- Removedmime-types@2.0.14(transitive)
- Removedoauth-sign@0.6.0(transitive)
- Removedqs@2.4.2(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedrequest@2.55.0(transitive)
- Removedtldts@6.1.74(transitive)
- Removedtldts-core@6.1.74(transitive)
- Removedtough-cookie@5.1.0(transitive)
Updatedfibers@>=1.0.7
Updatedhoek@^2.16.3
Updatedpromise@>=7.0.4
Updatedrequest@2.67.0