Support passing auth hash to API server
This commit is contained in:
parent
0b3b298596
commit
89a5bbae2f
|
@ -47,7 +47,8 @@ var Cylon = (function() {
|
|||
host: '127.0.0.1',
|
||||
port: '3000',
|
||||
cert: null,
|
||||
key: null
|
||||
key: null,
|
||||
auth: {}
|
||||
};
|
||||
|
||||
this.robot = bind(this.robot, this);
|
||||
|
@ -101,6 +102,7 @@ var Cylon = (function() {
|
|||
|
||||
var host = opts.host || this.api_config.host,
|
||||
port = opts.port || this.api_config.port,
|
||||
auth = opts.auth || this.api_config.auth,
|
||||
cert = opts.cert || this.api_config.cert,
|
||||
key = opts.key || this.api_config.key;
|
||||
|
||||
|
@ -108,7 +110,8 @@ var Cylon = (function() {
|
|||
host: host,
|
||||
port: port,
|
||||
cert: cert,
|
||||
key: key
|
||||
key: key,
|
||||
auth: auth
|
||||
};
|
||||
|
||||
return this.api_config;
|
||||
|
|
|
@ -47,7 +47,8 @@ describe("Cylon", function() {
|
|||
host: '127.0.0.1',
|
||||
port: '3000',
|
||||
cert: null,
|
||||
key: null
|
||||
key: null,
|
||||
auth: {}
|
||||
};
|
||||
|
||||
// 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);
|
||||
})
|
||||
});
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue