2017-08-04 23:30:46 +08:00
|
|
|
var assert = require('assert');
|
|
|
|
var testHelper = require('../../support/test_helper');
|
|
|
|
|
2018-04-09 22:18:30 +08:00
|
|
|
var lzmaMiddleware = require('../../../lib/cartodb/api/middlewares/lzma');
|
2017-08-04 23:30:46 +08:00
|
|
|
|
|
|
|
describe('lzma-middleware', function() {
|
|
|
|
|
|
|
|
it('it should extend params with decoded lzma', function(done) {
|
|
|
|
var qo = {
|
|
|
|
config: {
|
|
|
|
version: '1.3.0'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
testHelper.lzma_compress_to_base64(JSON.stringify(qo), 1, function(err, data) {
|
2018-03-02 01:45:04 +08:00
|
|
|
const lzma = lzmaMiddleware();
|
2017-08-04 23:30:46 +08:00
|
|
|
var req = {
|
|
|
|
headers: {
|
|
|
|
host:'localhost'
|
|
|
|
},
|
|
|
|
query: {
|
|
|
|
api_key: 'test',
|
|
|
|
lzma: data
|
2018-03-02 18:16:46 +08:00
|
|
|
},
|
|
|
|
profiler: {
|
|
|
|
done: function () {}
|
2017-08-04 23:30:46 +08:00
|
|
|
}
|
|
|
|
};
|
2018-03-02 01:45:04 +08:00
|
|
|
|
|
|
|
lzma(req, {}, function(err) {
|
2017-08-04 23:30:46 +08:00
|
|
|
if ( err ) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
var query = req.query;
|
|
|
|
assert.deepEqual(qo.config, query.config);
|
|
|
|
assert.equal('test', query.api_key);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|