New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bluecat

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluecat - npm Package Compare versions

Comparing version 0.3.9 to 1.0.0

2

lib/index.js
exports.ServiceSync = require('./service.gen.sync');
exports.ServiceAsync = require('./service.gen.async');
exports.Api = require('./service.api');
exports.version = '0.3.9';
exports.version = '1.0.0';
'use strict';
var ServiceSync = require('./service.gen.sync');
var request = require('request');
var fs = require('fs');
var hoek = require('hoek');
var Request = require('request');
var Fs = require('fs');
var Hoek = require('hoek');

@@ -20,3 +20,3 @@ var internals = {};

if (process.env.BLUECAT_DEBUG_FILE) {
this.writeStream = fs.createWriteStream(process.env.BLUECAT_DEBUG_FILE, {
this.writeStream = Fs.createWriteStream(process.env.BLUECAT_DEBUG_FILE, {
flags: 'a'

@@ -31,3 +31,3 @@ });

internals.Service.prototype = hoek.clone(ServiceSync.prototype);
internals.Service.prototype = Hoek.clone(ServiceSync.prototype);

@@ -121,3 +121,3 @@ internals.Service.prototype.recursiveBuildServices = function(path, services) {

if (callback) {
request(opts, function(err, response, body) {
Request(opts, function(err, response, body) {
if (self.writeStream) {

@@ -145,3 +145,3 @@ var res = {};

for (var i = 0; i < cs.length; i++) {
self.cookieJar.add(request.cookie(cs[i]));
self.cookieJar.add(Request.cookie(cs[i]));
}

@@ -156,3 +156,3 @@ }

return new Promise(function(resolve, reject) {
request(opts, function(err, response, body) {
Request(opts, function(err, response, body) {
if (self.writeStream) {

@@ -181,3 +181,3 @@ var res = {};

for (var i = 0; i < cs.length; i++) {
self.cookieJar.add(request.cookie(cs[i]));
self.cookieJar.add(Request.cookie(cs[i]));
}

@@ -184,0 +184,0 @@ }

{
"name": "bluecat",
"version": "0.3.9",
"version": "1.0.0",
"author": "ccy <ccy.chenchaoyi@gmail.com>",
"description": "Generic REST API Test Framework",
"description": "Library for building HTTP requests, good for generic REST API Test Framework",
"repository": {

@@ -25,7 +25,7 @@ "type": "git",

"dependencies": {
"fibers": ">=1.0.7",
"fibers": "^1.0.8",
"hoek": "^2.16.3",
"inquirer": "^0.11.0",
"path": "^0.12.7",
"promise": "^7.0.4",
"promise": "^7.1.1",
"request": "2.67.0",

@@ -38,3 +38,3 @@ "yargs": "^3.31.0"

"devDependencies": {
"chai": "^2.3.0",
"chai": "^3.4.1",
"mocha": "^2.3.4",

@@ -41,0 +41,0 @@ "grunt-cli": "^0.1.13",

@@ -8,2 +8,3 @@ ## Bluecat <img src="https://raw.github.com/chenchaoyi/bluecat/master/images/bluecat.png" align="middle" />

[![Downloads][downloads-image]][downloads-url]
[![Gitter](https://badges.gitter.im/chenchaoyi/bluecat.svg)](https://gitter.im/chenchaoyi/bluecat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
<!-- [![Gittip][gittip-image]][gittip-url] -->

@@ -15,6 +16,6 @@

* Define your APIs in a json file, `Bluecat` will create all the methods for you
* Callbacks are removed so tests that have a complex API call flow will be more clear
* Callbacks are removed so complex requests flow is more clear
* Full control over the request URL query, headers and body in test case
* Automatically maintains session cookies for you for HTTP API call flows
* [Convenience methods](#usage) that helps to handle complex scenario
* [Convenience methods](#usage) that help to handle complex scenario

@@ -51,5 +52,7 @@ ## Table of contents

"checkout": {
"schema": "http",
"method": ["GET", "POST"]
"contract": {
"schema": "http",
"method": ["GET", "POST"]
}
}
}

@@ -69,2 +72,3 @@ }

// send POST http://sample-host.com/checkout/contract
// with body: {"cartid": "test-cart-id"}
var r = Service.checkout.contract.POST({

@@ -80,3 +84,3 @@ body: {

// send GET http://sample-host.com/checkout/contract
// cookies are automatically maintained
// cookies are automatically maintained if there is any
r = Service.checkout.contract.GET();

@@ -90,2 +94,44 @@ // verify response

#### RESTful API with parameters in the URL
```
GET /checkout/${uuid}/contract
```
* First define your API in config/api.json:
```
{
"api": {
"checkout": {
"${uuid}": {
"contract": {
"schema": "http",
"method": ["GET"]
}
}
}
}
}
```
* Then create a Bluecat service object. You are all set to send request and validate response:
```javascript
var expect = require('chai').expect;
var Bluecat = require('bluecat');
var Service = new Bluecat.ServiceSync(Bluecat.Api('api'), 'sample-host.com');
// All requests need to be put into Api.run(), so they will run synchronously
Service.run(function() {
// send GET http://sample-host.com/checkout/5e586387-6d5a-4874-8a98-5836bdc45c7b/contract
var r = Service.checkout['${uuid}'].contract.GET({
params: {
uuid: '5e586387-6d5a-4874-8a98-5836bdc45c7b'
}
});
// verify response
expect(r.data.statusCode).to.equal(200);
})
```
---

@@ -152,3 +198,3 @@

#### `setHeaders(headers)`
Set headers that will be set in all the requests.
Set headers that will be sent in all the requests.

@@ -155,0 +201,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc