@@ -242,6 +242,57 @@ describe('database', () => {
242
242
} )
243
243
} )
244
244
245
+ describe ( 'Data strictness' , ( ) => {
246
+ it ( 'should not save and leak password, confirm-password from Local API' , async ( ) => {
247
+ const createdUser = await payload . create ( {
248
+ collection : 'users' ,
249
+ data : {
250
+ password : 'some-password' ,
251
+ // @ts -expect-error
252
+ 'confirm-password' : 'some-password' ,
253
+ email : 'user1@payloadcms.com' ,
254
+ } ,
255
+ } )
256
+
257
+ let keys = Object . keys ( createdUser )
258
+
259
+ expect ( keys ) . not . toContain ( 'password' )
260
+ expect ( keys ) . not . toContain ( 'confirm-password' )
261
+
262
+ const foundUser = await payload . findByID ( { id : createdUser . id , collection : 'users' } )
263
+
264
+ keys = Object . keys ( foundUser )
265
+
266
+ expect ( keys ) . not . toContain ( 'password' )
267
+ expect ( keys ) . not . toContain ( 'confirm-password' )
268
+ } )
269
+
270
+ it ( 'should not save and leak password, confirm-password from payload.db' , async ( ) => {
271
+ const createdUser = await payload . db . create ( {
272
+ collection : 'users' ,
273
+ data : {
274
+ password : 'some-password' ,
275
+ 'confirm-password' : 'some-password' ,
276
+ email : 'user2@payloadcms.com' ,
277
+ } ,
278
+ } )
279
+
280
+ let keys = Object . keys ( createdUser )
281
+
282
+ expect ( keys ) . not . toContain ( 'password' )
283
+ expect ( keys ) . not . toContain ( 'confirm-password' )
284
+
285
+ const foundUser = await payload . db . findOne ( {
286
+ collection : 'users' ,
287
+ where : { id : createdUser . id } ,
288
+ } )
289
+
290
+ keys = Object . keys ( foundUser )
291
+ expect ( keys ) . not . toContain ( 'password' )
292
+ expect ( keys ) . not . toContain ( 'confirm-password' )
293
+ } )
294
+ } )
295
+
245
296
describe ( 'migrations' , ( ) => {
246
297
let ranFreshTest = false
247
298
0 commit comments