Socket
Socket
Sign inDemoInstall

armrest

Package Overview
Dependencies
37
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.1.0

20

lib/index.js

@@ -66,3 +66,4 @@ var events = require('events');

}
this.auth = parseAuth(this.auth);
this.serializer = args.serializer || defaultSerializer;

@@ -127,3 +128,2 @@ this.timeout = args.timeout;

protocol: this.protocol,
auth: this.auth,
hostname: this.hostname,

@@ -137,2 +137,3 @@ port: this.port,

args.auth = parseAuth(args.auth) || this.auth;
args.method = method;

@@ -221,2 +222,17 @@ args.url = requestURL;

/*
* Parses authentication strings into objects or just passes back objects
*/
function parseAuth(auth) {
if (auth && typeof auth === 'string') {
var authObject = {
username: auth.split(':')[0],
password: auth.split(':')[1]
};
return authObject;
} else {
return auth;
}
}
/*
* Returns an HTTP status code error

@@ -223,0 +239,0 @@ */

2

package.json
{
"name": "armrest",
"description": "A high-level HTTP / REST client for Node",
"version": "4.0.0",
"version": "4.1.0",
"author": "David Chester <dchester@shutterstock.com>",

@@ -6,0 +6,0 @@ "main": "./lib/",

var server = require('./setup/server');
var armrest = require('../lib');
var client = armrest.client({ host: 'localhost:59903', auth: 'woo:hoo', logLevel: 'OFF' });
exports.auth = function(test) {
exports.authPropertyString = function(test) {
var client = armrest.client({
host: 'localhost:59903',
auth: 'woo:hoo',
logLevel: 'OFF'
});
client.get({
url: '/json',
url: '/auth',
success: function(data, response) {
test.equal(response.request.href, 'http://' + client.auth + '@' + client.hostname + ':' + client.port + '/json', 'authorized');
test.equal(data.username, 'woo', 'has username');
test.equal(data.password, 'hoo', 'has password');
test.ok(response.request.headers.authorization, 'has auth headers');
test.done();

@@ -15,2 +21,75 @@ }

exports.authPropertyObject = function(test) {
var client = armrest.client({
host: 'localhost:59903',
auth: {
username: 'woo',
password: 'hoo'
},
logLevel: 'OFF'
});
client.get({
url: '/auth',
success: function(data, response) {
test.equal(data.username, 'woo', 'has username');
test.equal(data.password, 'hoo', 'has password');
test.ok(response.request.headers.authorization, 'has auth headers');
test.done();
}
});
};
exports.authBase = function(test) {
var client = armrest.client({
base: 'woo:hoo@localhost:59903',
logLevel: 'OFF'
});
client.get({
url: '/auth',
success: function(data, response) {
test.equal(data.username, 'woo', 'has username');
test.equal(data.password, 'hoo', 'has password');
test.ok(response.request.headers.authorization, 'has auth headers');
test.done();
}
});
};
exports.authArgsString = function(test) {
var client = armrest.client({
base: 'localhost:59903',
logLevel: 'OFF'
});
client.get({
url: '/auth',
auth: 'woo:hoo',
success: function(data, response) {
test.equal(data.username, 'woo', 'has username');
test.equal(data.password, 'hoo', 'has password');
test.ok(response.request.headers.authorization, 'has auth headers');
test.done();
}
});
};
exports.authArgsObject = function(test) {
var client = armrest.client({
base: 'localhost:59903',
logLevel: 'OFF'
});
client.get({
url: '/auth',
auth: {
username: 'woo',
password: 'hoo'
},
success: function(data, response) {
test.equal(data.username, 'woo', 'has username');
test.equal(data.password, 'hoo', 'has password');
test.ok(response.request.headers.authorization, 'has auth headers');
test.done();
}
});
};
exports.setUp = function(callback) {

@@ -17,0 +96,0 @@ server.listen(59903, null, null, callback);

@@ -14,2 +14,15 @@ var fs = require('fs');

'/auth': function() {
var header = req.headers.authorization;
var token = header.split(/\s+/).pop();
var string = new Buffer(token, 'base64').toString();
var parts = string.split(/:/);
var info = {
username: parts[0],
password: parts[1]
};
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(info));
},
'/json': function() {

@@ -16,0 +29,0 @@ res.writeHead(200, { 'Content-Type': 'application/json' });

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc