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

42 lines
1.2 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');
2019-10-22 01:07:24 +08:00
describe('lzma-middleware', function () {
it('it should extend params with decoded lzma', function (done) {
var qo = {
config: {
version: '1.3.0'
}
};
2019-10-22 01:07:24 +08:00
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: {
2019-10-22 01:07:24 +08:00
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
2019-10-22 01:07:24 +08:00
lzma(req, {}, function (err) {
if (err) {
return done(err);
}
var query = req.query;
assert.deepStrictEqual(qo.config, query.config);
assert.strictEqual('test', query.api_key);
done();
});
});
});
});