Authored by zhaoyue

Add admin info test

git add --all src/*
git add push.sh
git add pom.xml
git commit -m "Modify to make better"
git commit -m "Add admin info test"
git push origin master
git status
git pull
... ...
... ... @@ -5,7 +5,7 @@ package com.xkl;
*/
public interface Constants {
// String URL_PREFIX = "http://127.0.0.1:8090";
// String URL_PREFIX = "http://127.0.0.1:8090";
// String URL_PREFIX = "http://139.129.166.85:8090";
String URL_PREFIX = "https://www.hanhezy.com:8090/";
... ...
package com.xkl.upsoft;
import com.xkl.Constants;
import com.xkl.EncodeTools;
import com.xkl.HttpTools;
import org.json.JSONObject;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 获取admin个人信息
*/
public class AdminInfoTest {
private static final String URL_ADMININFO = Constants.URL_PREFIX + "/adminInfo";
private static final String URL_LOGIN = Constants.URL_PREFIX + "/upsoft/account";
public static String loginAndGetToken(String user, String pass) {
Map<String, String> params = new HashMap<String, String>();
params.put("account", user);
params.put("password", EncodeTools.encode("MD5", pass));
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMap(URL_LOGIN, "POST", params);
System.out.println("login success:" + response);
JSONObject jsonObject = new JSONObject(response);
JSONObject content = jsonObject.getJSONObject("content");
return content.getString("userId") + "_" + content.getString("token");
}
@Test
public void testGetAdminInfo() {
String token = loginAndGetToken(Data.ADMIN_ACCOUNT, Data.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
String response = HttpTools.requestByMapWithToken(URL_ADMININFO, "GET", params, token);
System.out.println("admin info get success:" + response);
}
}
\ No newline at end of file
... ...