Windshaft-cartodb/test/unit/lzma-middleware-test.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
var assert = require('assert');
2019-10-07 17:29:07 +08:00
var testHelper = require('../support/test-helper');
2019-10-07 17:29:07 +08:00
var lzmaMiddleware = require('../../lib/api/middlewares/lzma');
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();
var req = {
headers: {
host:'localhost'
},
query: {
api_key: 'test',
lzma: data
2018-03-02 18:16:46 +08:00
},
profiler: {
done: function () {}
}
};
2018-03-02 01:45:04 +08:00
lzma(req, {}, function(err) {
if ( err ) {
return done(err);
}
var query = req.query;
assert.deepEqual(qo.config, query.config);
assert.equal('test', query.api_key);
done();
});
});
});
});