diff --git a/test/unit/http/middleware.js b/test/unit/http/middleware.js index cf020f55a..43f01b2fb 100644 --- a/test/unit/http/middleware.js +++ b/test/unit/http/middleware.js @@ -82,35 +82,47 @@ describe('middleware', () => { it('should pass through any query key content', (done) => { const request = createRequest({ url: '/v1/users/23?st=inva|id' }); + request.query.st.should.equal('inva|id'); + fieldKeyParser(request, null, () => { request.fieldKey.should.eql(Option.of('inva|id')); request.originalUrl.should.equal('/v1/key/inva|id/users/23?st=inva|id'); + should(request.query.st).be.undefined(); done(); }); }); it('should escape slashes in the rewritten path prefix', (done) => { const request = createRequest({ url: '/v1/users/23?st=in$va/i/d' }); + request.query.st.should.equal('in$va/i/d'); + fieldKeyParser(request, null, () => { request.fieldKey.should.eql(Option.of('in$va/i/d')); request.originalUrl.should.equal('/v1/key/in$va%2Fi%2Fd/users/23?st=in$va/i/d'); + should(request.query.st).be.undefined(); done(); }); }); it('should set Some(fk) and rewrite URL if a query key is found', (done) => { const request = createRequest({ url: '/v1/users/23?st=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }); + request.query.st.should.equal('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); + fieldKeyParser(request, null, () => { request.fieldKey.should.eql(Option.of('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); request.originalUrl.should.equal('/v1/key/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/users/23?st=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); + should(request.query.st).be.undefined(); done(); }); }); it('should decode percent-encoded query keys', (done) => { const request = createRequest({ url: '/v1/users/23?st=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%24aa!aaaaaaaaaaaaaaaaaa' }); + request.query.st.should.equal('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aa!aaaaaaaaaaaaaaaaaa'); + fieldKeyParser(request, null, () => { request.fieldKey.should.eql(Option.of('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aa!aaaaaaaaaaaaaaaaaa')); + should(request.query.st).be.undefined(); done(); }); });