forked from leancloud/cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVUserTest.cpp
More file actions
88 lines (63 loc) · 2.26 KB
/
AVUserTest.cpp
File metadata and controls
88 lines (63 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#define BOOST_TEST_MODULE AVUser 1.0 Test
#include <cstdio>
#include <fstream>
#include <string>
#include <vector>
#include <boost/test/unit_test.hpp>
#include "AVOSCloud.h"
#include "User/AVUser.h"
using namespace std;
using namespace avoscloud;
#error replace ${appId} and ${appKey} with real appId and appKey
BOOST_AUTO_TEST_CASE(AVUser_SignUp_Test) {
AVOSCloud::setApplicationId("${appId}", "${appKey}");
AVUser* user = AVUser::user();
user->username = "cyang123321";
user->password = "123456";
user->email = "cyang123321@avoscloud.com";
user->signUp();
BOOST_CHECK(user->isAuthenticated());
user->deleteInBackground();
user->release();
}
BOOST_AUTO_TEST_CASE(AVUser_Login_Test) {
AVOSCloud::setApplicationId("${appId}", "${appKey}");
AVUser* user = AVUser::user();
user->username = "cyang123321";
user->password = "123456";
user->email = "cyang123321@avoscloud.com";
user->signUp();
AVUser::logOut();
AVUser::loginWithUsernameAndPassword("cyang123321", "123456");
BOOST_CHECK(AVUser::currentUser() != nullptr && AVUser::currentUser()->isAuthenticated());
AVUser::currentUser()->deleteInBackground();
user->release();
}
BOOST_AUTO_TEST_CASE(AVUser_UpdatePassword_Test) {
AVOSCloud::setApplicationId("${appId}", "${appKey}");
AVUser* user = AVUser::user();
user->username = "cyang123321";
user->password = "123456";
user->email = "cyang123321@avoscloud.com";
user->signUp();
user->updatePasswordWithCallback("123456", "654321", [&](Json::Value const & root, AVError const & error){
//do nothing
});
AVUser::logOut();
AVUser::loginWithUsernameAndPassword("cyang123321", "654321");
BOOST_CHECK(AVUser::currentUser() != nullptr && AVUser::currentUser()->isAuthenticated());
AVUser::currentUser()->deleteInBackground();
user->release();
}
BOOST_AUTO_TEST_CASE(AVUser_RequestPasswordResetForEmail_Test) {
AVOSCloud::setApplicationId("${appId}", "${appKey}");
AVUser* user = AVUser::user();
user->username = "cyang123321";
user->password = "123456";
user->email = "cyang@avoscloud.com";
user->signUp();
BOOST_CHECK(AVUser::currentUser() != nullptr && AVUser::currentUser()->isAuthenticated());
AVUser::requestPasswordResetForEmail("cyang@avoscloud.com");
user->deleteInBackground();
user->release();
}