|
|
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 |