2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2017-08-04 23:30:46 +08:00
|
|
|
var assert = require('assert');
|
2019-10-07 17:29:07 +08:00
|
|
|
var testHelper = require('../support/test-helper');
|
2017-08-04 23:30:46 +08:00
|
|
|
|
2019-10-07 17:29:07 +08:00
|
|
|
var lzmaMiddleware = require('../../lib/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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|