@@ -1730,6 +1730,57 @@ describe('Parse.User testing', () => {
1730
1730
} ) ;
1731
1731
} ) ;
1732
1732
1733
+ it ( 'should allow PUT request with stale auth Data' , ( done ) => {
1734
+ const provider = {
1735
+ authData : {
1736
+ id : '12345' ,
1737
+ access_token : 'token'
1738
+ } ,
1739
+ restoreAuthentication : function ( ) {
1740
+ return true ;
1741
+ } ,
1742
+ deauthenticate : function ( ) {
1743
+ provider . authData = { } ;
1744
+ } ,
1745
+ authenticate : function ( options ) {
1746
+ options . success ( this , provider . authData ) ;
1747
+ } ,
1748
+ getAuthType : function ( ) {
1749
+ return "shortLivedAuth" ;
1750
+ }
1751
+ }
1752
+ defaultConfiguration . auth . shortLivedAuth . setValidAccessToken ( 'token' ) ;
1753
+ Parse . User . _registerAuthenticationProvider ( provider ) ;
1754
+ Parse . User . _logInWith ( "shortLivedAuth" , { } ) . then ( ( ) => {
1755
+ // Simulate a remotely expired token (like a short lived one)
1756
+ // In this case, we want success as it was valid once.
1757
+ // If the client needs an updated one, do lock the user out
1758
+ defaultConfiguration . auth . shortLivedAuth . setValidAccessToken ( 'otherToken' ) ;
1759
+ return rp . put ( {
1760
+ url : Parse . serverURL + '/users/' + Parse . User . current ( ) . id ,
1761
+ headers : {
1762
+ 'X-Parse-Application-Id' : Parse . applicationId ,
1763
+ 'X-Parse-Javascript-Key' : Parse . javaScriptKey ,
1764
+ 'X-Parse-Session-Token' : Parse . User . current ( ) . getSessionToken ( ) ,
1765
+ 'Content-Type' : 'application/json'
1766
+ } ,
1767
+ json : {
1768
+ key : 'value' , // update a key
1769
+ authData : { // pass the original auth data
1770
+ shortLivedAuth : {
1771
+ id : '12345' ,
1772
+ access_token : 'token'
1773
+ }
1774
+ }
1775
+ }
1776
+ } )
1777
+ } ) . then ( ( ) => {
1778
+ done ( ) ;
1779
+ } , ( err ) => {
1780
+ done . fail ( err ) ;
1781
+ } ) ;
1782
+ } ) ;
1783
+
1733
1784
it ( 'should properly error when password is missing' , ( done ) => {
1734
1785
var provider = getMockFacebookProvider ( ) ;
1735
1786
Parse . User . _registerAuthenticationProvider ( provider ) ;
0 commit comments