]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/account/TestChangePassword.java
Merge "Update notes about password security"
[gigi.git] / tests / org / cacert / gigi / pages / account / TestChangePassword.java
index 119df79f1e33df23723ef0596dd917b0195fc1c0..9601842631a1b639e730233458d43e6c87b7993a 100644 (file)
@@ -6,15 +6,10 @@ import java.io.IOException;
 import java.net.URLEncoder;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.User;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestChangePassword extends ManagedTest {
-
-    User u = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@example.org", TEST_PASSWORD));
-
-    String cookie;
+public class TestChangePassword extends ClientTest {
 
     String path = ChangePasswordPage.PATH;
 
@@ -39,9 +34,10 @@ public class TestChangePassword extends ManagedTest {
 
     @Test
     public void testChangePasswordWeb() throws IOException {
-        String error = executeBasicWebInteraction(cookie, path, "oldpassword=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
-                + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
-                + "&pword2=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
+        String error = executeBasicWebInteraction(cookie, path,
+                "oldpassword=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
+                        + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
+                        + "&pword2=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
         assertNull(error);
         assertTrue(isLoggedin(login(u.getEmail(), TEST_PASSWORD + "v2")));
         assertFalse(isLoggedin(login(u.getEmail(), TEST_PASSWORD)));
@@ -50,9 +46,10 @@ public class TestChangePassword extends ManagedTest {
 
     @Test
     public void testChangePasswordWebOldWrong() throws IOException {
-        String error = executeBasicWebInteraction(cookie, path, "oldpassword=a" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
-                + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
-                + "&pword2=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
+        String error = executeBasicWebInteraction(cookie, path,
+                "oldpassword=a" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
+                        + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
+                        + "&pword2=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
         assertNotNull(error);
         assertFalse(isLoggedin(login(u.getEmail(), TEST_PASSWORD + "v2")));
         assertTrue(isLoggedin(login(u.getEmail(), TEST_PASSWORD)));
@@ -61,9 +58,10 @@ public class TestChangePassword extends ManagedTest {
 
     @Test
     public void testChangePasswordWebNewWrong() throws IOException {
-        String error = executeBasicWebInteraction(cookie, path, "oldpassword=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
-                + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
-                + "&pword2=a" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
+        String error = executeBasicWebInteraction(cookie, path,
+                "oldpassword=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8") //
+                        + "&pword1=" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8")//
+                        + "&pword2=a" + URLEncoder.encode(TEST_PASSWORD + "v2", "UTF-8"));
         assertNotNull(error);
         assertFalse(isLoggedin(login(u.getEmail(), TEST_PASSWORD + "v2")));
         assertTrue(isLoggedin(login(u.getEmail(), TEST_PASSWORD)));