30
30
*
31
31
* @author <a href="http://88250.b3log.org">Liang Ding</a>
32
32
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
33
- * @version 1.0.0.3, May 25 , 2017
33
+ * @version 1.0.0.4, Aug 14 , 2017
34
34
*/
35
35
@ Test (suiteName = "service" )
36
36
public class UserMgmtServiceTestCase extends AbstractTestCase {
37
37
38
38
/**
39
39
* Add User.
40
- *
40
+ *
41
41
* @throws Exception exception
42
42
*/
43
43
@ Test
@@ -56,15 +56,14 @@ public void addUser() throws Exception {
56
56
57
57
/**
58
58
* Update User.
59
- *
59
+ *
60
60
* @throws Exception exception
61
61
*/
62
62
@ Test (dependsOnMethods = "addUser" )
63
63
public void updateUser () throws Exception {
64
64
final UserMgmtService userMgmtService = getUserMgmtService ();
65
65
66
66
JSONObject requestJSONObject = new JSONObject ();
67
-
68
67
requestJSONObject .put (User .USER_NAME , "user2name" );
69
68
requestJSONObject .put (User .USER_EMAIL , "test2@gmail.com" );
70
69
requestJSONObject .put (User .USER_PASSWORD , "pass2" );
@@ -92,42 +91,38 @@ public void updateUser() throws Exception {
92
91
Assert .assertEquals (getUserQueryService ().getUser (id ).getJSONObject (
93
92
User .USER ).getString (User .USER_PASSWORD ), MD5 .hash ("pass2" ));
94
93
}
95
-
94
+
96
95
/**
97
96
* Valid User.
98
97
*
99
- *@throws Exception exception
98
+ * @throws Exception exception
100
99
*/
101
100
@ Test
102
- public void ValidUser () throws Exception {
101
+ public void validUser () throws Exception {
103
102
final UserMgmtService userMgmtService = getUserMgmtService ();
104
103
105
104
final JSONObject requestJSONObject = new JSONObject ();
106
-
107
105
requestJSONObject .put (User .USER_NAME , "user1 name" );
108
106
requestJSONObject .put (User .USER_EMAIL , "test1@gmail.com" );
109
107
requestJSONObject .put (User .USER_PASSWORD , "pass1" );
110
-
108
+
111
109
try {
112
110
final String id = userMgmtService .addUser (requestJSONObject );
113
111
} catch (Exception e ) {
114
- // TODO Auto-generated catch block
115
112
Assert .assertTrue (e instanceof ServiceException );
116
113
}
117
-
118
114
}
119
-
115
+
120
116
/**
121
- * Vallid XSS username.
117
+ * Valid XSS username.
122
118
*
123
- *@throws Exception exception
119
+ * @throws Exception exception
124
120
*/
125
121
@ Test (expectedExceptions = ServiceException .class )
126
122
public void XSSUser () throws Exception {
127
123
final UserMgmtService userMgmtService = getUserMgmtService ();
128
124
129
125
final JSONObject requestJSONObject = new JSONObject ();
130
-
131
126
requestJSONObject .put (User .USER_NAME , "username" );
132
127
requestJSONObject .put (User .USER_EMAIL , "<script></script>" );
133
128
@@ -136,20 +131,18 @@ public void XSSUser() throws Exception {
136
131
137
132
/**
138
133
* Remove User.
139
- *
134
+ *
140
135
* @throws Exception exception
141
136
*/
142
137
@ Test (dependsOnMethods = "addUser" )
143
138
public void removeUser () throws Exception {
144
139
final UserMgmtService userMgmtService = getUserMgmtService ();
145
140
146
- final JSONObject user =
147
- getUserQueryService ().getUserByEmail ("test1@gmail.com" );
141
+ final JSONObject user = getUserQueryService ().getUserByEmail ("test1@gmail.com" );
148
142
Assert .assertNotNull (user );
149
143
150
144
userMgmtService .removeUser (user .getString (Keys .OBJECT_ID ));
151
145
152
- Assert .assertNull (
153
- getUserQueryService ().getUserByEmail ("test1@gmail.com" ));
146
+ Assert .assertNull (getUserQueryService ().getUserByEmail ("test1@gmail.com" ));
154
147
}
155
148
}
0 commit comments