1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.user.test.ui; |
21 |
|
|
22 |
|
import org.apache.commons.lang.RandomStringUtils; |
23 |
|
import org.junit.Assert; |
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.test.ui.AbstractTest; |
27 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
28 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
29 |
|
import org.xwiki.test.ui.po.ViewPage; |
30 |
|
import org.xwiki.user.test.po.ChangeAvatarPage; |
31 |
|
import org.xwiki.user.test.po.ChangePasswordPage; |
32 |
|
import org.xwiki.user.test.po.PreferencesEditPage; |
33 |
|
import org.xwiki.user.test.po.PreferencesUserProfilePage; |
34 |
|
import org.xwiki.user.test.po.ProfileEditPage; |
35 |
|
import org.xwiki.user.test.po.ProfileUserProfilePage; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 99.1% |
Uncovered Elements: 1 (117) |
Complexity: 12 |
Complexity Density: 0.12 |
|
43 |
|
public class UserProfileTest extends AbstractTest |
44 |
|
{ |
45 |
|
private static final String IMAGE_NAME = "avatar.png"; |
46 |
|
|
47 |
|
private static final String USER_FIRST_NAME = "User"; |
48 |
|
|
49 |
|
private static final String USER_LAST_NAME = "of this Wiki"; |
50 |
|
|
51 |
|
private static final String USER_COMPANY = "XWiki.org"; |
52 |
|
|
53 |
|
private static final String USER_ABOUT = "This is some example text to type into the text area"; |
54 |
|
|
55 |
|
private static final String USER_EMAIL = "webmaster@xwiki.org"; |
56 |
|
|
57 |
|
private static final String USER_PHONE = "0000-000-000"; |
58 |
|
|
59 |
|
private static final String USER_ADDRESS = "1600 No Street"; |
60 |
|
|
61 |
|
private static final String USER_BLOG = "http://xwiki.org/"; |
62 |
|
|
63 |
|
private static final String USER_BLOGFEED = "http://xwiki.org/feed"; |
64 |
|
|
65 |
|
private static final String WYSIWYG_EDITOR = "Wysiwyg"; |
66 |
|
|
67 |
|
private static final String TEXT_EDITOR = "Text"; |
68 |
|
|
69 |
|
private static final String DEFAULT_EDITOR = "Text (Default)"; |
70 |
|
|
71 |
|
private static final String SIMPLE_USER = "Simple"; |
72 |
|
|
73 |
|
private static final String ADVANCED_USER = "Advanced"; |
74 |
|
|
75 |
|
private static final String PASSWORD_1 = "password1"; |
76 |
|
|
77 |
|
private static final String PASSWORD_2 = "password2"; |
78 |
|
|
79 |
|
private static final String DEFAULT_PASSWORD = "testtest"; |
80 |
|
|
81 |
|
private ProfileUserProfilePage customProfilePage; |
82 |
|
|
83 |
|
private String userName; |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
85 |
10 |
@Before... |
86 |
|
public void setUp() |
87 |
|
{ |
88 |
10 |
getUtil().recacheSecretToken(); |
89 |
10 |
this.userName = getTestClassName() + getTestMethodName(); |
90 |
10 |
getUtil().createUserAndLogin(this.userName, DEFAULT_PASSWORD); |
91 |
|
|
92 |
10 |
this.customProfilePage = ProfileUserProfilePage.gotoPage(this.userName); |
93 |
|
} |
94 |
|
|
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
96 |
1 |
@Test... |
97 |
|
@IgnoreBrowsers({ |
98 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
99 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
100 |
|
}) |
101 |
|
public void testEditProfile() |
102 |
|
{ |
103 |
1 |
ProfileEditPage profileEditPage = this.customProfilePage.editProfile(); |
104 |
1 |
profileEditPage.setUserFirstName(USER_FIRST_NAME); |
105 |
1 |
profileEditPage.setUserLastName(USER_LAST_NAME); |
106 |
1 |
profileEditPage.setUserCompany(USER_COMPANY); |
107 |
1 |
profileEditPage.setUserAbout(USER_ABOUT); |
108 |
1 |
profileEditPage.setUserEmail(USER_EMAIL); |
109 |
1 |
profileEditPage.setUserPhone(USER_PHONE); |
110 |
1 |
profileEditPage.setUserAddress(USER_ADDRESS); |
111 |
1 |
profileEditPage.setUserBlog(USER_BLOG); |
112 |
1 |
profileEditPage.setUserBlogFeed(USER_BLOGFEED); |
113 |
1 |
profileEditPage.clickSaveAndView(); |
114 |
|
|
115 |
|
|
116 |
1 |
Assert.assertEquals(USER_FIRST_NAME, this.customProfilePage.getUserFirstName()); |
117 |
1 |
Assert.assertEquals(USER_LAST_NAME, this.customProfilePage.getUserLastName()); |
118 |
1 |
Assert.assertEquals(USER_COMPANY, this.customProfilePage.getUserCompany()); |
119 |
1 |
Assert.assertEquals(USER_ABOUT, this.customProfilePage.getUserAbout()); |
120 |
1 |
Assert.assertEquals(USER_EMAIL, this.customProfilePage.getUserEmail()); |
121 |
1 |
Assert.assertEquals(USER_PHONE, this.customProfilePage.getUserPhone()); |
122 |
1 |
Assert.assertEquals(USER_ADDRESS, this.customProfilePage.getUserAddress()); |
123 |
1 |
Assert.assertEquals(USER_BLOG, this.customProfilePage.getUserBlog()); |
124 |
1 |
Assert.assertEquals(USER_BLOGFEED, this.customProfilePage.getUserBlogFeed()); |
125 |
|
} |
126 |
|
|
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
128 |
1 |
@Test... |
129 |
|
@IgnoreBrowsers({ |
130 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
131 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
132 |
|
}) |
133 |
|
public void testChangeAvatarImage() |
134 |
|
{ |
135 |
1 |
ChangeAvatarPage changeAvatarImage = this.customProfilePage.changeAvatarImage(); |
136 |
1 |
changeAvatarImage.setAvatarImage(IMAGE_NAME); |
137 |
1 |
changeAvatarImage.submit(); |
138 |
1 |
Assert.assertEquals(IMAGE_NAME, this.customProfilePage.getAvatarImageName()); |
139 |
|
} |
140 |
|
|
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
142 |
1 |
@Test... |
143 |
|
@IgnoreBrowsers({ |
144 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
145 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
146 |
|
}) |
147 |
|
public void testChangePassword() |
148 |
|
{ |
149 |
|
|
150 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
151 |
1 |
ChangePasswordPage changePasswordPage = preferencesPage.changePassword(); |
152 |
1 |
String newPassword = RandomStringUtils.randomAlphanumeric(6); |
153 |
1 |
changePasswordPage.changePassword(DEFAULT_PASSWORD, newPassword, newPassword); |
154 |
1 |
changePasswordPage.submit(); |
155 |
|
|
156 |
|
|
157 |
1 |
getUtil().forceGuestUser(); |
158 |
|
|
159 |
|
|
160 |
1 |
getUtil().loginAndGotoPage(this.userName, newPassword, |
161 |
|
getUtil().getURL(getTestClassName(), getTestMethodName())); |
162 |
1 |
ViewPage vp = new ViewPage(); |
163 |
1 |
Assert.assertTrue(vp.isAuthenticated()); |
164 |
1 |
getUtil().recacheSecretToken(); |
165 |
|
|
166 |
|
|
167 |
1 |
getUtil().loginAsSuperAdminAndGotoPage(this.customProfilePage.getURL()); |
168 |
|
|
169 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
170 |
1 |
changePasswordPage = preferencesPage.changePassword(); |
171 |
1 |
changePasswordPage.changePasswordAsAdmin(DEFAULT_PASSWORD, DEFAULT_PASSWORD); |
172 |
1 |
changePasswordPage.submit(); |
173 |
1 |
Assert.assertEquals("Your password has been successfully changed.", changePasswordPage.getSuccessMessage()); |
174 |
|
} |
175 |
|
|
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
177 |
1 |
@Test... |
178 |
|
@IgnoreBrowsers({ |
179 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
180 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
181 |
|
}) |
182 |
|
public void testChangeUserProfile() |
183 |
|
{ |
184 |
1 |
String timezone = "Europe/Paris"; |
185 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
186 |
1 |
Assert.assertEquals("", preferencesPage.getTimezone()); |
187 |
|
|
188 |
|
|
189 |
1 |
PreferencesEditPage preferencesEditPage = preferencesPage.editPreferences(); |
190 |
1 |
preferencesEditPage.setSimpleUserType(); |
191 |
1 |
preferencesEditPage.setTimezone(timezone); |
192 |
1 |
preferencesEditPage.clickSaveAndView(); |
193 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
194 |
1 |
Assert.assertEquals(SIMPLE_USER, preferencesPage.getUserType()); |
195 |
1 |
Assert.assertEquals(timezone, preferencesPage.getTimezone()); |
196 |
|
|
197 |
|
|
198 |
1 |
preferencesEditPage = preferencesPage.editPreferences(); |
199 |
1 |
preferencesEditPage.setAdvancedUserType(); |
200 |
1 |
preferencesEditPage.clickSaveAndView(); |
201 |
1 |
this.customProfilePage.switchToPreferences(); |
202 |
1 |
Assert.assertEquals(ADVANCED_USER, preferencesPage.getUserType()); |
203 |
|
} |
204 |
|
|
205 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
206 |
1 |
@Test... |
207 |
|
@IgnoreBrowsers({ |
208 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
209 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
210 |
|
}) |
211 |
|
public void testChangeDefaultEditor() |
212 |
|
{ |
213 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
214 |
|
|
215 |
|
|
216 |
1 |
PreferencesEditPage preferencesEditPage = preferencesPage.editPreferences(); |
217 |
1 |
preferencesEditPage.setDefaultEditorText(); |
218 |
1 |
preferencesEditPage.clickSaveAndView(); |
219 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
220 |
1 |
Assert.assertEquals(TEXT_EDITOR, preferencesPage.getDefaultEditor()); |
221 |
|
|
222 |
|
|
223 |
1 |
this.customProfilePage = ProfileUserProfilePage.gotoPage(this.userName); |
224 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
225 |
1 |
preferencesEditPage = preferencesPage.editPreferences(); |
226 |
1 |
preferencesEditPage.setDefaultEditorWysiwyg(); |
227 |
1 |
preferencesEditPage.clickSaveAndView(); |
228 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
229 |
1 |
Assert.assertEquals(WYSIWYG_EDITOR, preferencesPage.getDefaultEditor()); |
230 |
|
|
231 |
|
|
232 |
1 |
this.customProfilePage = ProfileUserProfilePage.gotoPage(this.userName); |
233 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
234 |
1 |
preferencesEditPage = preferencesPage.editPreferences(); |
235 |
1 |
preferencesEditPage.setDefaultEditorDefault(); |
236 |
1 |
preferencesEditPage.clickSaveAndView(); |
237 |
1 |
preferencesPage = this.customProfilePage.switchToPreferences(); |
238 |
1 |
Assert.assertEquals(DEFAULT_EDITOR, preferencesPage.getDefaultEditor()); |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
1PASS
|
|
245 |
1 |
@Test... |
246 |
|
public void testCommentDoesntOverrideAboutInformation() |
247 |
|
{ |
248 |
1 |
String commentContent = "this is from a comment"; |
249 |
|
|
250 |
1 |
int commentId = this.customProfilePage.openCommentsDocExtraPane().postComment(commentContent, true); |
251 |
1 |
getDriver().navigate().refresh(); |
252 |
1 |
Assert.assertFalse("Comment content was used as profile information", this.customProfilePage.getContent() |
253 |
|
.contains(commentContent)); |
254 |
|
|
255 |
1 |
if (commentId != -1) { |
256 |
1 |
this.customProfilePage.openCommentsDocExtraPane().deleteCommentByID(commentId); |
257 |
|
} |
258 |
|
} |
259 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
260 |
1 |
@Test... |
261 |
|
@IgnoreBrowsers({ |
262 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
263 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
264 |
|
}) |
265 |
|
public void testChangePasswordWithTwoDifferentPasswords() |
266 |
|
{ |
267 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
268 |
1 |
ChangePasswordPage changePasswordPage = preferencesPage.changePassword(); |
269 |
1 |
changePasswordPage.changePassword(DEFAULT_PASSWORD, PASSWORD_1, PASSWORD_2); |
270 |
1 |
changePasswordPage.submit(); |
271 |
1 |
Assert.assertEquals("The two passwords do not match.", changePasswordPage.getValidationErrorMessage()); |
272 |
|
} |
273 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
274 |
1 |
@Test... |
275 |
|
@IgnoreBrowsers({ |
276 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
277 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
278 |
|
}) |
279 |
|
public void testChangePasswordWithoutEnteringPasswords() |
280 |
|
{ |
281 |
1 |
ChangePasswordPage changePasswordPage = this.customProfilePage.switchToPreferences().changePassword(); |
282 |
1 |
changePasswordPage.submit(); |
283 |
1 |
Assert.assertEquals("Your new password should be at least 6 characters long.", changePasswordPage.getValidationErrorMessage()); |
284 |
|
} |
285 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
286 |
1 |
@Test... |
287 |
|
@IgnoreBrowsers({ |
288 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
289 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
290 |
|
}) |
291 |
|
public void testChangePasswordOfAnotherUserWithTwoDifferentPasswords() |
292 |
|
{ |
293 |
|
|
294 |
1 |
getUtil().loginAsSuperAdminAndGotoPage(this.customProfilePage.getURL()); |
295 |
|
|
296 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
297 |
1 |
ChangePasswordPage changePasswordPage = preferencesPage.changePassword(); |
298 |
1 |
changePasswordPage.changePasswordAsAdmin(PASSWORD_1, PASSWORD_2); |
299 |
1 |
changePasswordPage.submit(); |
300 |
1 |
Assert.assertEquals("The two passwords do not match.", changePasswordPage.getValidationErrorMessage()); |
301 |
|
} |
302 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
303 |
1 |
@Test... |
304 |
|
@IgnoreBrowsers({ |
305 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
306 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
307 |
|
}) |
308 |
|
public void testChangePasswordWithWrongOriginalPassword() |
309 |
|
{ |
310 |
1 |
PreferencesUserProfilePage preferencesPage = this.customProfilePage.switchToPreferences(); |
311 |
1 |
ChangePasswordPage changePasswordPage = preferencesPage.changePassword(); |
312 |
1 |
changePasswordPage.changePassword("badPassword", PASSWORD_1, PASSWORD_1); |
313 |
1 |
changePasswordPage.submit(); |
314 |
1 |
Assert.assertEquals("Current password is invalid.", changePasswordPage.getErrorMessage()); |
315 |
|
} |
316 |
|
} |