@@ -2,6 +2,7 @@ import assert from 'assert';
22import { EventEmitter } from 'events' ;
33import { feathers , Application , Params } from '@feathersjs/feathers' ;
44import { NotAuthenticated } from '@feathersjs/errors' ;
5+ import { isPlainObject } from 'lodash' ;
56
67import { routing } from '../../src/routing' ;
78import {
@@ -189,11 +190,15 @@ describe('socket commons utils', () => {
189190 beforeEach ( ( ) => {
190191 app = feathers ( ) . configure ( routing ( ) ) ;
191192 app . use ( '/myservice' , {
192- get ( id : number | string , params : Params ) {
193+ async get ( id : number | string , params : Params ) {
193194 if ( params . query . error ) {
194- return Promise . reject ( new NotAuthenticated ( 'None shall pass' ) ) ;
195+ throw new NotAuthenticated ( 'None shall pass' ) ;
195196 }
196- return Promise . resolve ( { id } ) ;
197+ if ( ! isPlainObject ( params . query ) ) {
198+ throw new Error ( 'Query is not a plain object' ) ;
199+ }
200+
201+ return { id } ;
197202 }
198203 } ) ;
199204 } ) ;
@@ -212,6 +217,21 @@ describe('socket commons utils', () => {
212217 runMethod ( app , { } , 'myservice' , 'get' , [ 10 , { } , callback ] ) ;
213218 } ) ;
214219
220+ it ( 'queries are always plain objects' , done => {
221+ const callback = ( error : any , result : any ) => {
222+ if ( error ) {
223+ return done ( error ) ;
224+ }
225+
226+ assert . deepStrictEqual ( result , { id : 10 } ) ;
227+ done ( ) ;
228+ } ;
229+
230+ runMethod ( app , { } , 'myservice' , 'get' , [ 10 , {
231+ __proto__ : [ ]
232+ } , callback ] ) ;
233+ } ) ;
234+
215235 it ( 'merges params with connection and passes connection' , done => {
216236 const connection = {
217237 testing : true
0 commit comments