Skip to content

Commit

Permalink
test/http/middleware: assert delete of query.st (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Nov 14, 2024
1 parent f24e7f9 commit 5873479
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/unit/http/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check failure on line 90 in test/unit/http/middleware.js

View workflow job for this annotation

GitHub Actions / standard-tests

'should' is not defined
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();

Check failure on line 102 in test/unit/http/middleware.js

View workflow job for this annotation

GitHub Actions / standard-tests

'should' is not defined
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();

Check failure on line 114 in test/unit/http/middleware.js

View workflow job for this annotation

GitHub Actions / standard-tests

'should' is not defined
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();

Check failure on line 125 in test/unit/http/middleware.js

View workflow job for this annotation

GitHub Actions / standard-tests

'should' is not defined
done();
});
});
Expand Down

0 comments on commit 5873479

Please sign in to comment.