Support passing auth hash to API server

This commit is contained in:
Andrew Stewart 2014-04-03 15:49:13 -07:00
parent 0b3b298596
commit 89a5bbae2f
2 changed files with 17 additions and 3 deletions

View File

@ -47,7 +47,8 @@ var Cylon = (function() {
host: '127.0.0.1', host: '127.0.0.1',
port: '3000', port: '3000',
cert: null, cert: null,
key: null key: null,
auth: {}
}; };
this.robot = bind(this.robot, this); this.robot = bind(this.robot, this);
@ -101,6 +102,7 @@ var Cylon = (function() {
var host = opts.host || this.api_config.host, var host = opts.host || this.api_config.host,
port = opts.port || this.api_config.port, port = opts.port || this.api_config.port,
auth = opts.auth || this.api_config.auth,
cert = opts.cert || this.api_config.cert, cert = opts.cert || this.api_config.cert,
key = opts.key || this.api_config.key; key = opts.key || this.api_config.key;
@ -108,7 +110,8 @@ var Cylon = (function() {
host: host, host: host,
port: port, port: port,
cert: cert, cert: cert,
key: key key: key,
auth: auth
}; };
return this.api_config; return this.api_config;

View File

@ -47,7 +47,8 @@ describe("Cylon", function() {
host: '127.0.0.1', host: '127.0.0.1',
port: '3000', port: '3000',
cert: null, cert: null,
key: null key: null,
auth: {}
}; };
// this is the shortest, cheapest way to dup an object in JS. // this is the shortest, cheapest way to dup an object in JS.
@ -102,6 +103,16 @@ describe("Cylon", function() {
expect(cylon.api_config).to.be.eql(expectedConfig); expect(cylon.api_config).to.be.eql(expectedConfig);
}) })
}); });
context("specifying an auth strategy", function() {
it("changes the auth strategy", function() {
var auth = { type: 'basic', user: 'user', pass: 'pass'}
expectedConfig.auth = auth;
cylon.api({ auth: auth })
expect(cylon.api_config).to.be.eql(expectedConfig);
});
});
}); });
describe("#findRobot", function() { describe("#findRobot", function() {