@@ -26,7 +26,7 @@ describe('Express Mongo Sanitize', function() {
26
26
describe ( 'Top-level object' , function ( ) {
27
27
it ( 'should sanitize the query string' , function ( done ) {
28
28
request ( app )
29
- . get ( '/query?q=search&$where=malicious' )
29
+ . get ( '/query?q=search&$where=malicious&dotted.data=some_data ' )
30
30
. set ( 'Accept' , 'application/json' )
31
31
. expect ( 200 , {
32
32
query : {
@@ -44,7 +44,8 @@ describe('Express Mongo Sanitize', function() {
44
44
and : 1 ,
45
45
even : null ,
46
46
stop : undefined ,
47
- $where : 'malicious'
47
+ $where : 'malicious' ,
48
+ 'dotted.data' : 'some_data'
48
49
} )
49
50
. set ( 'Content-Type' , 'application/json' )
50
51
. set ( 'Accept' , 'application/json' )
@@ -61,7 +62,7 @@ describe('Express Mongo Sanitize', function() {
61
62
it ( 'should sanitize a form url-encoded body' , function ( done ) {
62
63
request ( app )
63
64
. post ( '/body' )
64
- . send ( 'q=search&$where=malicious' )
65
+ . send ( 'q=search&$where=malicious&dotted.data=some_data ' )
65
66
. set ( 'Content-Type' , 'application/x-www-form-urlencoded' )
66
67
. set ( 'Accept' , 'application/json' )
67
68
. expect ( 200 , {
@@ -75,7 +76,7 @@ describe('Express Mongo Sanitize', function() {
75
76
describe ( 'Nested Object' , function ( ) {
76
77
it ( 'should sanitize a nested object in the query string' , function ( done ) {
77
78
request ( app )
78
- . get ( '/query?username[$gt]=' )
79
+ . get ( '/query?username[$gt]=foo&username[dotted.data]=some_data ' )
79
80
. set ( 'Accept' , 'application/json' )
80
81
. expect ( 200 , {
81
82
query : {
@@ -88,7 +89,10 @@ describe('Express Mongo Sanitize', function() {
88
89
request ( app )
89
90
. post ( '/body' )
90
91
. send ( {
91
- username : { $gt : '' }
92
+ username : {
93
+ $gt : 'foo' ,
94
+ 'dotted.data' : 'some_data'
95
+ }
92
96
} )
93
97
. set ( 'Content-Type' , 'application/json' )
94
98
. set ( 'Accept' , 'application/json' )
@@ -102,7 +106,7 @@ describe('Express Mongo Sanitize', function() {
102
106
it ( 'should sanitize a nested object in a form url-encoded body' , function ( done ) {
103
107
request ( app )
104
108
. post ( '/body' )
105
- . send ( 'username[$gt]=' )
109
+ . send ( 'username[$gt]=foo&username[dotted.data]=some_data ' )
106
110
. set ( 'Content-Type' , 'application/x-www-form-urlencoded' )
107
111
. set ( 'Accept' , 'application/json' )
108
112
. expect ( 200 , {
@@ -116,7 +120,7 @@ describe('Express Mongo Sanitize', function() {
116
120
describe ( 'Nested Object inside an Array' , function ( ) {
117
121
it ( 'should sanitize a nested object in the query string' , function ( done ) {
118
122
request ( app )
119
- . get ( '/query?username[0][$gt]=' )
123
+ . get ( '/query?username[0][$gt]=foo&username[0][dotted.data]=some_data ' )
120
124
. set ( 'Accept' , 'application/json' )
121
125
. expect ( 200 , {
122
126
query : {
@@ -129,7 +133,10 @@ describe('Express Mongo Sanitize', function() {
129
133
request ( app )
130
134
. post ( '/body' )
131
135
. send ( {
132
- username : [ { $gt : '' } ]
136
+ username : [ {
137
+ $gt : 'foo' ,
138
+ 'dotted.data' : 'some_data'
139
+ } ]
133
140
} )
134
141
. set ( 'Content-Type' , 'application/json' )
135
142
. set ( 'Accept' , 'application/json' )
@@ -143,7 +150,7 @@ describe('Express Mongo Sanitize', function() {
143
150
it ( 'should sanitize a nested object in a form url-encoded body' , function ( done ) {
144
151
request ( app )
145
152
. post ( '/body' )
146
- . send ( 'username[0][$gt]=' )
153
+ . send ( 'username[0][$gt]=foo&username[0][dotted.data]=some_data ' )
147
154
. set ( 'Content-Type' , 'application/x-www-form-urlencoded' )
148
155
. set ( 'Accept' , 'application/json' )
149
156
. expect ( 200 , {
0 commit comments