...
|
...
|
@@ -17,66 +17,66 @@ public class UserInfoTest { |
|
|
/**
|
|
|
* 用户注册:
|
|
|
* register(String adminUser,String adminPass,
|
|
|
String user,String pass,String name,String sex,String birthDate,String phone,String idcard)
|
|
|
* String user,String pass,String name,String sex,String birthDate,String phone,String idcard)
|
|
|
*/
|
|
|
@Test
|
|
|
public void testRegister(){
|
|
|
String adminUser = "user1";
|
|
|
String adminPass = "pass1";
|
|
|
public void testRegister() {
|
|
|
String adminUser = Constants.ADMIN_ACCOUNT;
|
|
|
String adminPass = Constants.ADMIN_PWD;
|
|
|
String user = "15211112222";
|
|
|
String pass = "pass152";
|
|
|
String name = "usernameTest";
|
|
|
String sex = Constants.MALE;
|
|
|
String birthDate= "1966-06-12";
|
|
|
String birthDate = "1966-06-12";
|
|
|
String phone = "13011112222";
|
|
|
String idcard = "130105196606125555";
|
|
|
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
|
|
|
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testRegisterWithDiffId(){
|
|
|
String adminUser = "user1";
|
|
|
String adminPass = "pass1";
|
|
|
public void testRegisterWithDiffId() {
|
|
|
String adminUser = Constants.ADMIN_ACCOUNT;
|
|
|
String adminPass = Constants.ADMIN_PWD;
|
|
|
String user = "15233334444";
|
|
|
String pass = "pass152";
|
|
|
String name = "usernameTest1";
|
|
|
String sex = Constants.MALE;
|
|
|
String birthDate= "1966-06-12";
|
|
|
String birthDate = "1966-06-12";
|
|
|
String phone = "13011112222";
|
|
|
String idcard = "110000196606125555";
|
|
|
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
|
|
|
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testRegisterWithOutIdCard(){
|
|
|
String adminUser = "user1";
|
|
|
String adminPass = "pass1";
|
|
|
public void testRegisterWithOutIdCard() {
|
|
|
String adminUser = Constants.ADMIN_ACCOUNT;
|
|
|
String adminPass = Constants.ADMIN_PWD;
|
|
|
String user = "15222223333";
|
|
|
String pass = "pass152";
|
|
|
String name = "usernameTest2";
|
|
|
String sex = Constants.FEMALE;
|
|
|
String birthDate= "1999-12-22";
|
|
|
String birthDate = "1999-12-22";
|
|
|
String phone = "13011112222";
|
|
|
String idcard = null;
|
|
|
register(adminUser,adminPass,user,pass,name,sex,birthDate,phone,idcard);
|
|
|
register(adminUser, adminPass, user, pass, name, sex, birthDate, phone, idcard);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户修改密码
|
|
|
*/
|
|
|
@Test
|
|
|
public void testModPass(){
|
|
|
register("user1","pass1","15211112222","pass152","usernameTest","1","1966-06-12","13011112222","130105196606125555");
|
|
|
public void testModPass() {
|
|
|
register(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD, "15211112222", "pass152", "usernameTest", "1", "1966-06-12", "13011112222", "130105196606125555");
|
|
|
|
|
|
Map<String,String> params = new HashMap<String, String>();
|
|
|
params.put("password",EncodeTools.encode("MD5","pass152_new"));
|
|
|
params.put("t",HttpTools.getNow());
|
|
|
params.put("type",Constants.KEY_ID);
|
|
|
params.put("sign",HttpTools.getSign(params));
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("password", EncodeTools.encode("MD5", "pass152_new"));
|
|
|
params.put("t", HttpTools.getNow());
|
|
|
params.put("type", Constants.KEY_ID);
|
|
|
params.put("sign", HttpTools.getSign(params));
|
|
|
//获取token
|
|
|
String token = loginAndGetToken("15211112222","pass152");
|
|
|
String token = loginAndGetToken("15211112222", "pass152");
|
|
|
System.out.println(token);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER,"PUT",params,token);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER, "PUT", params, token);
|
|
|
System.out.println(response);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -84,34 +84,34 @@ public class UserInfoTest { |
|
|
* 个人信息查询接口
|
|
|
*/
|
|
|
@Test
|
|
|
public void testGetUserInfo(){
|
|
|
Map<String,String> params = new HashMap<String, String>();
|
|
|
params.put("t",HttpTools.getNow());
|
|
|
params.put("type",Constants.KEY_ID);
|
|
|
params.put("sign",HttpTools.getSign(params));
|
|
|
public void testGetUserInfo() {
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("t", HttpTools.getNow());
|
|
|
params.put("type", Constants.KEY_ID);
|
|
|
params.put("sign", HttpTools.getSign(params));
|
|
|
//获取token
|
|
|
String token = loginAndGetToken("user1","pass1");
|
|
|
String token = loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);
|
|
|
System.out.println(token);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER,"GET",params,token);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token);
|
|
|
System.out.println(response);
|
|
|
}
|
|
|
|
|
|
public void register(String adminUser,String adminPass,
|
|
|
String user,String pass,String name,String sex,String birthDate,String phone,String idcard){
|
|
|
Map<String,String> params = new HashMap<String, String>();
|
|
|
params.put("username",user);
|
|
|
params.put("password",EncodeTools.encode("MD5",pass));
|
|
|
params.put("name",name);
|
|
|
params.put("sex",sex);
|
|
|
params.put("birthDate",birthDate);
|
|
|
params.put("phone",phone);
|
|
|
if(idcard!=null&&idcard!="")
|
|
|
params.put("idcard",idcard);
|
|
|
params.put("t",HttpTools.getNow());
|
|
|
params.put("type",Constants.KEY_ID);
|
|
|
params.put("sign",HttpTools.getSign(params));
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
|
|
|
public void register(String adminUser, String adminPass,
|
|
|
String user, String pass, String name, String sex, String birthDate, String phone, String idcard) {
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("username", user);
|
|
|
params.put("password", EncodeTools.encode("MD5", pass));
|
|
|
params.put("name", name);
|
|
|
params.put("sex", sex);
|
|
|
params.put("birthDate", birthDate);
|
|
|
params.put("phone", phone);
|
|
|
if (idcard != null && idcard != "")
|
|
|
params.put("idcard", idcard);
|
|
|
params.put("t", HttpTools.getNow());
|
|
|
params.put("type", Constants.KEY_ID);
|
|
|
params.put("sign", HttpTools.getSign(params));
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
|
|
|
System.out.println(response);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -119,30 +119,30 @@ public class UserInfoTest { |
|
|
* 错误的注册:不带sign
|
|
|
*/
|
|
|
@Test
|
|
|
public void testRegisterNoSign(){
|
|
|
String adminUser = "user1";
|
|
|
String adminPass = "pass1";
|
|
|
public void testRegisterNoSign() {
|
|
|
String adminUser = Constants.ADMIN_ACCOUNT;
|
|
|
String adminPass = Constants.ADMIN_PWD;
|
|
|
String user = "15211112222";
|
|
|
String pass = "pass152";
|
|
|
String name = "usernameTest";
|
|
|
String sex = Constants.MALE;
|
|
|
String birthDate= "1966-06-12";
|
|
|
String birthDate = "1966-06-12";
|
|
|
String phone = "13011112222";
|
|
|
String idcard = "130105196606125555";
|
|
|
Map<String,String> params = new HashMap<String, String>();
|
|
|
params.put("username",user);
|
|
|
params.put("password",EncodeTools.encode("MD5",pass));
|
|
|
params.put("name",name);
|
|
|
params.put("sex",sex);
|
|
|
params.put("birthDate",birthDate);
|
|
|
params.put("phone",phone);
|
|
|
if(idcard!=null&&idcard!="")
|
|
|
params.put("idcard",idcard);
|
|
|
params.put("t",HttpTools.getNow());
|
|
|
params.put("type",Constants.KEY_ID);
|
|
|
params.put("sign","nosign");
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("username", user);
|
|
|
params.put("password", EncodeTools.encode("MD5", pass));
|
|
|
params.put("name", name);
|
|
|
params.put("sex", sex);
|
|
|
params.put("birthDate", birthDate);
|
|
|
params.put("phone", phone);
|
|
|
if (idcard != null && idcard != "")
|
|
|
params.put("idcard", idcard);
|
|
|
params.put("t", HttpTools.getNow());
|
|
|
params.put("type", Constants.KEY_ID);
|
|
|
params.put("sign", "nosign");
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
|
|
|
System.out.println(response);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -150,30 +150,30 @@ public class UserInfoTest { |
|
|
* 错误注册:客户端与服务端时间差距过大
|
|
|
*/
|
|
|
@Test
|
|
|
public void testRegisterWrongTime(){
|
|
|
String adminUser = "user1";
|
|
|
String adminPass = "pass1";
|
|
|
public void testRegisterWrongTime() {
|
|
|
String adminUser = Constants.ADMIN_ACCOUNT;
|
|
|
String adminPass = Constants.ADMIN_PWD;
|
|
|
String user = "15211112222";
|
|
|
String pass = "pass152";
|
|
|
String name = "usernameTest";
|
|
|
String sex = Constants.MALE;
|
|
|
String birthDate= "1966-06-12";
|
|
|
String birthDate = "1966-06-12";
|
|
|
String phone = "13011112222";
|
|
|
String idcard = "130105196606125555";
|
|
|
Map<String,String> params = new HashMap<String, String>();
|
|
|
params.put("username",user);
|
|
|
params.put("password",EncodeTools.encode("MD5",pass));
|
|
|
params.put("name",name);
|
|
|
params.put("sex",sex);
|
|
|
params.put("birthDate",birthDate);
|
|
|
params.put("phone",phone);
|
|
|
if(idcard!=null&&idcard!="")
|
|
|
params.put("idcard",idcard);
|
|
|
params.put("t",HttpTools.getNow()+60*60*26);
|
|
|
params.put("type",Constants.KEY_ID);
|
|
|
params.put("sign","nosign");
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser,adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER,"POST",params,token);
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("username", user);
|
|
|
params.put("password", EncodeTools.encode("MD5", pass));
|
|
|
params.put("name", name);
|
|
|
params.put("sex", sex);
|
|
|
params.put("birthDate", birthDate);
|
|
|
params.put("phone", phone);
|
|
|
if (idcard != null && idcard != "")
|
|
|
params.put("idcard", idcard);
|
|
|
params.put("t", HttpTools.getNow() + 60 * 60 * 26);
|
|
|
params.put("type", Constants.KEY_ID);
|
|
|
params.put("sign", "nosign");
|
|
|
String token = TokenTest.adminLoginAndGetToken(adminUser, adminPass);
|
|
|
String response = HttpTools.requestByMapWithToken(URL_USER, "POST", params, token);
|
|
|
|
|
|
System.out.println(response);
|
|
|
}
|
...
|
...
|
|