From ff562094fb0f19ba7de47a13827415c944542a3a Mon Sep 17 00:00:00 2001 From: Artur Mackowiak Date: Mon, 24 Jul 2017 15:46:04 +0200 Subject: [PATCH] IP2017-75 a few elements from DefaultPasswordsTest refactored --- .../secureaem/tests/DefaultPasswordsTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cognifide/secureaem/tests/DefaultPasswordsTest.java b/src/main/java/com/cognifide/secureaem/tests/DefaultPasswordsTest.java index 7e7f203..f86b0e5 100644 --- a/src/main/java/com/cognifide/secureaem/tests/DefaultPasswordsTest.java +++ b/src/main/java/com/cognifide/secureaem/tests/DefaultPasswordsTest.java @@ -28,8 +28,8 @@ */ public class DefaultPasswordsTest extends AbstractTest implements AuthorTest, PublishTest { + private static final String LOGIN_PATH = "/libs/granite/core/content/login.html/j_security_check"; private static final String USERNAME_FORM_PARAM_NAME = "j_username"; - private static final String ALTERNATIVE_LOGIN_PATH = "/libs/granite/core/content/login.html/j_security_check"; private static final String PASSWORD_FORM_PARAM_NAME = "j_password"; private static final String IS_VALIDATE_FORM_PARAM_NAME = "j_validate"; @@ -39,12 +39,12 @@ public DefaultPasswordsTest(Configuration config) { @Override public boolean doTest(String url, String instanceName) throws Exception { - String alternativeUrl = url + ALTERNATIVE_LOGIN_PATH; + String loginUrl = url + LOGIN_PATH; boolean ok = true; String[] users = config.getStringList("users"); for (String user : users) { String[] split = UserHelper.splitUser(user); - if (split[1] != null && remoteUserExists(split, alternativeUrl)) { + if (split[1] != null && remoteUserExists(split, loginUrl)) { addErrorMessage("User %s exists on %s", user, instanceName); ok = false; } else { @@ -59,7 +59,7 @@ private boolean remoteUserExists(String[] user, String url) throws URISyntaxExce DefaultHttpClient authorizedClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); - List params = getRequestParamsList(user); + List params = getPostParamsList(user); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = authorizedClient.execute(httpPost); @@ -68,7 +68,7 @@ private boolean remoteUserExists(String[] user, String url) throws URISyntaxExce return code != HttpURLConnection.HTTP_FORBIDDEN; } - private List getRequestParamsList(String[] user) { + private List getPostParamsList(String[] user) { List params = new ArrayList<>(); params.add(new BasicNameValuePair(USERNAME_FORM_PARAM_NAME, user[0]));