@@ -3847,13 +3847,14 @@ describe('/account/destroy', () => {
38473847 const tokenVerified = true ;
38483848 const uid = uuid . v4 ( { } , Buffer . alloc ( 16 ) ) . toString ( 'hex' ) ;
38493849
3850- let mockDB , mockLog , mockRequest , mockPush , mockPushbox ;
3850+ let mockDB , mockLog , mockRequest , mockPush , mockPushbox , mockCustoms ;
38513851
38523852 beforeEach ( async ( ) => {
38533853 mockDB = {
38543854 ...mocks . mockDB ( { email : email , uid : uid } ) ,
38553855 } ;
38563856 mockLog = mocks . mockLog ( ) ;
3857+ mockCustoms = mocks . mockCustoms ( ) ;
38573858 mockRequest = mocks . mockRequest ( {
38583859 credentials : { uid, email, tokenVerified } ,
38593860 log : mockLog ,
@@ -3889,6 +3890,7 @@ describe('/account/destroy', () => {
38893890 log : mockLog ,
38903891 push : mockPush ,
38913892 pushbox : mockPushbox ,
3893+ customs : mockCustoms
38923894 } ) ;
38933895 return getRoute ( accountRoutes , '/account/destroy' ) ;
38943896 }
@@ -3969,6 +3971,26 @@ describe('/account/destroy', () => {
39693971 } ) ;
39703972 } ) ;
39713973 } ) ;
3974+
3975+ it ( 'should fail for mismatch session and account ui' , async ( ) => {
3976+ mockDB = { ...mocks . mockDB ( { email, uid } ) } ;
3977+ mockRequest = mocks . mockRequest ( {
3978+ credentials :
{ uid :
'anotherone' , email :
`[email protected] ` , tokenVerified
} , 3979+ log : mockLog ,
3980+ payload : {
3981+ email,
3982+ } ,
3983+ } ) ;
3984+ const route = buildRoute ( ) ;
3985+
3986+ try {
3987+ await runTest ( route , mockRequest ) ;
3988+ sinon . assert . fail ( 'should have errored' ) ;
3989+ } catch ( error ) {
3990+ sinon . assert . calledOnceWithExactly ( mockCustoms . flag , "63.245.221.32" , { email, errno : 102 } ) ;
3991+ assert . equal ( error . errno , 102 , 'unknown account' ) ;
3992+ }
3993+ } ) ;
39723994} ) ;
39733995
39743996describe ( '/account' , ( ) => {
0 commit comments