NIFCLOUD-mbaas / ncmb_js

ニフクラ mobile backend JavaScript SDK
https://mbaas.nifcloud.com
Other
28 stars 27 forks source link

fix error logout when session token expired time #132 #174

Closed hocnguyen closed 7 years ago

hocnguyen commented 8 years ago

概要(Summary)

Run the unit test.

ykokw commented 7 years ago

@hocnguyen Thank you for creating p-r!

Could you separate p-r for issue #161 or add description in p-r summary ? And I can't find test code for this fixing.

hocnguyen commented 7 years ago

@ykokw Thanks for your review. I will separate to 2 p-r.

hocnguyen commented 7 years ago

@ykokw I remove the code of issue 161. This is only code fixing of issue 132. Please help me review again!

ykokw commented 7 years ago

@hocnguyen I've confirmed that your fixing is separated to 2 p-r. Thanks. Could you add test code or tell me procedure for confirmation?

hocnguyen commented 7 years ago

@ykokw About this issue, when we call logout function with a session token was expired or wrong. The error will appear. Base from description of issue. I reset session info to null value when error code response is 401. Because In mbaas.yml file, we had declare logout function with response 200. So I can`t create response 401 with logout function from test code.
That is reason i can`t add the test code. But Please see example code bellow. That is my code test on this issue :

var user = new ncmb.User({userName:"Yamada Tarou", password:"password"});
            ncmb.User.login(user)
                .then(function(data){
                                   // reset wrong token to error appear when logout 
                    user.sessionToken="wrong token"; 
                    user.logout(function(err, res){
                      if(err){
                        console.log(err);
                      }
                    });
                })
                .catch(function(err){
                  // エラー処理
                });
ykokw commented 7 years ago

Because In mbaas.yml file, we had declare logout function with response 200.

上記、mbaas.ymlに401エラーが返るスタブを用意することで

テストコードが実装可能になるかと思います。