fix compatibility issues
This commit is contained in:
parent
7207f03bd1
commit
7942048dd1
7 changed files with 115 additions and 43 deletions
|
|
@ -5,16 +5,17 @@ var querystring = require('querystring');
|
|||
describe('insight storage plugin', function() {
|
||||
|
||||
var requestMock = sinon.stub();
|
||||
var storage = new InsightStorage({request: requestMock});
|
||||
var storage = new InsightStorage({
|
||||
request: requestMock
|
||||
});
|
||||
var email = 'john@doe.com';
|
||||
var password = '1234';
|
||||
|
||||
var data = '{"random": true}';
|
||||
var namespace = 'profile::0000000000000000000000000000000000000000';
|
||||
|
||||
var oldSecret = 'rFA+F/N+ZvKXp717zBdfCKYQ5v9Fjry0W6tautj5etIH'
|
||||
+ 'KLQliZBEYXA7AXjTJ9K3DglzGWJKost3QJUCMbhM/A=='
|
||||
var newSecret = '+72pwnQ/ukrXVXZ/L4vFeiykwn522uVz0J6p81TGXvI=';
|
||||
var oldSecret = 'rFA+F/N+ZvKXp717zBdfCKYQ5v9Fjry0W6tautj5etIH' + 'KLQliZBEYXA7AXjTJ9K3DglzGWJKost3QJUCMbhM/A=='
|
||||
var newSecret = 'rcNEqxJZV1fsrZgpwpET8D9aCsCIYXS7XOGlsONgEiA=';
|
||||
|
||||
var setupStorageCredentials = function() {
|
||||
storage.setCredentials(email, password);
|
||||
|
|
@ -29,7 +30,9 @@ describe('insight storage plugin', function() {
|
|||
|
||||
var setupForCreation = function() {
|
||||
requestMock.get.onFirstCall().callsArgWith(1, 'Not found');
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {statusCode: 200});
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
||||
statusCode: 200
|
||||
});
|
||||
};
|
||||
|
||||
it('should be able to create a namespace for storage', function(done) {
|
||||
|
|
@ -43,7 +46,9 @@ describe('insight storage plugin', function() {
|
|||
});
|
||||
|
||||
var setupForRetrieval = function() {
|
||||
requestMock.get.onFirstCall().callsArgWith(1, null, {statusCode: 200}, data);
|
||||
requestMock.get.onFirstCall().callsArgWith(1, null, {
|
||||
statusCode: 200
|
||||
}, data);
|
||||
};
|
||||
|
||||
it('should be able to retrieve data in a namespace', function(done) {
|
||||
|
|
@ -57,8 +62,10 @@ describe('insight storage plugin', function() {
|
|||
});
|
||||
});
|
||||
|
||||
var setupForSave = function () {
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {statusCode: 200});
|
||||
var setupForSave = function() {
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
||||
statusCode: 200
|
||||
});
|
||||
};
|
||||
|
||||
it('should be able to overwrite data when using same password', function(done) {
|
||||
|
|
@ -95,10 +102,16 @@ describe('insight storage plugin', function() {
|
|||
|
||||
var setupForOldData = function() {
|
||||
requestMock.get = sinon.stub();
|
||||
requestMock.get.onFirstCall().callsArgWith(1, null, {statusCode: 403});
|
||||
requestMock.get.onSecondCall().callsArgWith(1, null, {statusCode: 200}, data);
|
||||
requestMock.get.onFirstCall().callsArgWith(1, null, {
|
||||
statusCode: 403
|
||||
});
|
||||
requestMock.get.onSecondCall().callsArgWith(1, null, {
|
||||
statusCode: 200
|
||||
}, data);
|
||||
requestMock.post = sinon.stub();
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {statusCode: 200});
|
||||
requestMock.post.onFirstCall().callsArgWith(1, null, {
|
||||
statusCode: 200
|
||||
});
|
||||
}
|
||||
|
||||
it('should be able to restore 0.7.2 data', function(done) {
|
||||
|
|
@ -120,11 +133,9 @@ describe('insight storage plugin', function() {
|
|||
var receivedArgs = requestMock.post.firstCall.args[0].body;
|
||||
var url = requestMock.post.firstCall.args[0].url;
|
||||
var args = querystring.decode(receivedArgs);
|
||||
assert(url.indexOf('change_passphrase') !== -1);
|
||||
assert(requestMock.post.firstCall.args[0].headers.Authorization
|
||||
===
|
||||
new Buffer(email + ':' + oldSecret).toString('base64'));
|
||||
assert(args.newPassphrase === newSecret);
|
||||
url.indexOf('change_passphrase').should.not.be.equal(-1);
|
||||
requestMock.post.firstCall.args[0].headers.Authorization.should.be.equal( new Buffer(email + ':' + oldSecret).toString('base64'));
|
||||
args.newPassphrase.should.be.equal(newSecret);
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue