@@ -256,6 +256,49 @@ describe('AuthenticationProviders', function () {
256256      . catch ( done . fail ) ; 
257257  } ) ; 
258258
259+   it ( 'should support loginWith with session token and with/without mutated authData' ,  async  ( )  =>  { 
260+     const  fakeAuthProvider  =  { 
261+       validateAppId : ( )  =>  Promise . resolve ( ) , 
262+       validateAuthData : ( )  =>  Promise . resolve ( ) , 
263+     } ; 
264+     const  payload  =  {  authData : {  id : 'user1' ,  token : 'fakeToken'  }  } ; 
265+     const  payload2  =  {  authData : {  id : 'user1' ,  token : 'fakeToken2'  }  } ; 
266+     await  reconfigureServer ( {  auth : {  fakeAuthProvider }  } ) ; 
267+     const  user  =  await  Parse . User . logInWith ( 'fakeAuthProvider' ,  payload ) ; 
268+     const  user2  =  await  Parse . User . logInWith ( 'fakeAuthProvider' ,  payload ,  { 
269+       sessionToken : user . getSessionToken ( ) , 
270+     } ) ; 
271+     const  user3  =  await  Parse . User . logInWith ( 'fakeAuthProvider' ,  payload2 ,  { 
272+       sessionToken : user2 . getSessionToken ( ) , 
273+     } ) ; 
274+     expect ( user . id ) . toEqual ( user2 . id ) ; 
275+     expect ( user . id ) . toEqual ( user3 . id ) ; 
276+   } ) ; 
277+ 
278+   it ( 'should support sync/async validateAppId' ,  async  ( )  =>  { 
279+     const  syncProvider  =  { 
280+       validateAppId : ( )  =>  true , 
281+       appIds : 'test' , 
282+       validateAuthData : ( )  =>  Promise . resolve ( ) , 
283+     } ; 
284+     const  asyncProvider  =  { 
285+       appIds : 'test' , 
286+       validateAppId : ( )  =>  Promise . resolve ( true ) , 
287+       validateAuthData : ( )  =>  Promise . resolve ( ) , 
288+     } ; 
289+     const  payload  =  {  authData : {  id : 'user1' ,  token : 'fakeToken'  }  } ; 
290+     const  syncSpy  =  spyOn ( syncProvider ,  'validateAppId' ) ; 
291+     const  asyncSpy  =  spyOn ( asyncProvider ,  'validateAppId' ) ; 
292+ 
293+     await  reconfigureServer ( {  auth : {  asyncProvider,  syncProvider }  } ) ; 
294+     const  user  =  await  Parse . User . logInWith ( 'asyncProvider' ,  payload ) ; 
295+     const  user2  =  await  Parse . User . logInWith ( 'syncProvider' ,  payload ) ; 
296+     expect ( user . getSessionToken ( ) ) . toBeDefined ( ) ; 
297+     expect ( user2 . getSessionToken ( ) ) . toBeDefined ( ) ; 
298+     expect ( syncSpy ) . toHaveBeenCalledTimes ( 1 ) ; 
299+     expect ( asyncSpy ) . toHaveBeenCalledTimes ( 1 ) ; 
300+   } ) ; 
301+ 
259302  it ( 'unlink and link with custom provider' ,  async  ( )  =>  { 
260303    const  provider  =  getMockMyOauthProvider ( ) ; 
261304    Parse . User . _registerAuthenticationProvider ( provider ) ; 
@@ -339,10 +382,10 @@ describe('AuthenticationProviders', function () {
339382    } ) ; 
340383
341384    validateAuthenticationHandler ( authenticationHandler ) ; 
342-     const  validator  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
385+     const  {   validator  }  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
343386    validateValidator ( validator ) ; 
344387
345-     validator ( validAuthData ) . then ( 
388+     validator ( validAuthData ,   { } ,   { } ) . then ( 
346389      ( )  =>  { 
347390        expect ( authDataSpy ) . toHaveBeenCalled ( ) ; 
348391        // AppIds are not provided in the adapter, should not be called 
@@ -362,12 +405,15 @@ describe('AuthenticationProviders', function () {
362405    } ) ; 
363406
364407    validateAuthenticationHandler ( authenticationHandler ) ; 
365-     const  validator  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
408+     const  {   validator  }  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
366409    validateValidator ( validator ) ; 
367- 
368-     validator ( { 
369-       token : 'my-token' , 
370-     } ) . then ( 
410+     validator ( 
411+       { 
412+         token : 'my-token' , 
413+       } , 
414+       { } , 
415+       { } 
416+     ) . then ( 
371417      ( )  =>  { 
372418        done ( ) ; 
373419      } , 
@@ -387,12 +433,16 @@ describe('AuthenticationProviders', function () {
387433    } ) ; 
388434
389435    validateAuthenticationHandler ( authenticationHandler ) ; 
390-     const  validator  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
436+     const  {   validator  }  =  authenticationHandler . getValidatorForProvider ( 'customAuthentication' ) ; 
391437    validateValidator ( validator ) ; 
392438
393-     validator ( { 
394-       token : 'valid-token' , 
395-     } ) . then ( 
439+     validator ( 
440+       { 
441+         token : 'valid-token' , 
442+       } , 
443+       { } , 
444+       { } 
445+     ) . then ( 
396446      ( )  =>  { 
397447        done ( ) ; 
398448      } , 
@@ -541,6 +591,7 @@ describe('AuthenticationProviders', function () {
541591  } ) ; 
542592
543593  it ( 'can depreciate' ,  async  ( )  =>  { 
594+     await  reconfigureServer ( ) ; 
544595    const  Deprecator  =  require ( '../lib/Deprecator/Deprecator' ) ; 
545596    const  spy  =  spyOn ( Deprecator ,  'logRuntimeDeprecation' ) . and . callFake ( ( )  =>  { } ) ; 
546597    const  provider  =  getMockMyOauthProvider ( ) ; 
0 commit comments