Authored by zhaoyue

Mod file location

@@ -7,9 +7,9 @@ public interface Constants { @@ -7,9 +7,9 @@ public interface Constants {
7 /** 7 /**
8 * 服务地址 8 * 服务地址
9 */ 9 */
10 - //String URL_PREFIX = "http://127.0.0.1:8090"; 10 +// String URL_PREFIX = "http://127.0.0.1:8090";
11 String URL_PREFIX = "https://www.hanhezy.com:8090/"; 11 String URL_PREFIX = "https://www.hanhezy.com:8090/";
12 - // String URL_PREFIX = "http://139.129.166.85:8090"; 12 +
13 /** 13 /**
14 * 测试用 用户名、密码、openid、openidtype 14 * 测试用 用户名、密码、openid、openidtype
15 */ 15 */
@@ -20,12 +20,14 @@ public interface Constants { @@ -20,12 +20,14 @@ public interface Constants {
20 20
21 21
22 /** 22 /**
23 - * 23 + * 只有区域管理员、区域操作员才能使用接口访问。
24 */ 24 */
25 // admin account 25 // admin account
26 public static final String ADMIN_ACCOUNT = "user1"; 26 public static final String ADMIN_ACCOUNT = "user1";
27 // admin password 27 // admin password
28 public static final String ADMIN_PWD = "pass1"; 28 public static final String ADMIN_PWD = "pass1";
  29 +
  30 +
29 /** 31 /**
30 * 密钥 32 * 密钥
31 */ 33 */
@@ -33,6 +35,8 @@ public interface Constants { @@ -33,6 +35,8 @@ public interface Constants {
33 String KEY = "weixin"; 35 String KEY = "weixin";
34 // 密钥ID 36 // 密钥ID
35 String KEY_ID = "1"; 37 String KEY_ID = "1";
  38 +
  39 +
36 /** 40 /**
37 * 性别 41 * 性别
38 */ 42 */
@@ -53,7 +57,13 @@ public interface Constants { @@ -53,7 +57,13 @@ public interface Constants {
53 int USER_MODPASS_LOGOUT = 1002;//修改密码成功,请重新登录 57 int USER_MODPASS_LOGOUT = 1002;//修改密码成功,请重新登录
54 int REPORT_INVALID_ERROR = -11142;//报告在数据库中不存在/Report is not exist in the DB 58 int REPORT_INVALID_ERROR = -11142;//报告在数据库中不存在/Report is not exist in the DB
55 int USER_NOT_FOUND = -1002;//用户不存在/User is not exist 59 int USER_NOT_FOUND = -1002;//用户不存在/User is not exist
56 - int COMPANY_ERROR =-11170;//"用户所属公司信息有误/Company infomation error";  
57 - 60 + int COMPANY_ERROR = -11170;//"用户所属公司信息有误/Company infomation error";
58 61
  62 + /**
  63 + * Operation
  64 + */
  65 + public static final int OP_NEWUSER_REGISTER = 0;
  66 + public static final int OP_HELTH_EXAM = 1;
  67 + public static final int OP_OLDUSER_GUIDE = 2;
  68 + public static final int OP_NEWUSER_DIAGNOSE = 3;
59 } 69 }
  1 +package com.xkl.internal;
  2 +
  3 +import com.utils.DESTools;
  4 +import com.xkl.Constants;
  5 +import com.xkl.EncodeTools;
  6 +import com.xkl.HttpTools;
  7 +import com.xkl.RtnCodeTools;
  8 +import com.xkl.partner.TokenTest;
  9 +import org.json.JSONObject;
  10 +import org.junit.Assert;
  11 +import org.junit.Test;
  12 +
  13 +import java.util.HashMap;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by zhaoyue on 2017/3/11.
  18 + */
  19 +public class AdminOpLogTest {
  20 + private static final String URL_ADMIN_OP_LOG = Constants.URL_PREFIX + "/adminOpLog";
  21 +
  22 + @Test
  23 + public void testAdminOpLog() {
  24 + String token = TokenTest.adminLoginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
  25 +
  26 + Map<String, String> params = new HashMap<String, String>();
  27 + params.put("username", Constants.USR_ACC);
  28 + params.put("operation", Integer.toString(Constants.OP_NEWUSER_REGISTER));
  29 + params.put("t", HttpTools.getNow());
  30 + params.put("type", Constants.KEY_ID);
  31 + params.put("sign", HttpTools.getSign(params));
  32 + String response = HttpTools.requestByMapWithToken(URL_ADMIN_OP_LOG, "POST", params, token);
  33 + System.out.println(response);
  34 + Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC));
  35 + }
  36 +}
1 -package com.xkl.inneruse; 1 +package com.xkl.internal;
2 2
3 import com.xkl.Constants; 3 import com.xkl.Constants;
4 import com.xkl.HttpTools; 4 import com.xkl.HttpTools;
5 import com.xkl.RtnCodeTools; 5 import com.xkl.RtnCodeTools;
6 import org.junit.Assert; 6 import org.junit.Assert;
7 -import org.junit.BeforeClass;  
8 import org.junit.Test; 7 import org.junit.Test;
9 8
10 import java.util.HashMap; 9 import java.util.HashMap;
11 import java.util.Map; 10 import java.util.Map;
12 11
13 -import static com.xkl.TokenTest.loginAndGetToken;  
14 -  
15 /** 12 /**
16 * Created by win7 on 2016/12/26. 13 * Created by win7 on 2016/12/26.
17 * 报告相关 14 * 报告相关
1 -package com.xkl.inneruse.qrcode; 1 +package com.xkl.internal.qrcode;
2 2
3 import com.utils.DESTools; 3 import com.utils.DESTools;
4 import com.xkl.*; 4 import com.xkl.*;
  5 +import com.xkl.partner.TokenTest;
5 import org.json.JSONObject; 6 import org.json.JSONObject;
6 import org.junit.Assert; 7 import org.junit.Assert;
7 import org.junit.Test; 8 import org.junit.Test;
1 -package com.xkl; 1 +package com.xkl.partner;
2 2
  3 +import com.xkl.Constants;
  4 +import com.xkl.EncodeTools;
  5 +import com.xkl.HttpTools;
  6 +import com.xkl.RtnCodeTools;
3 import org.json.JSONObject; 7 import org.json.JSONObject;
4 import org.junit.Assert; 8 import org.junit.Assert;
5 import org.junit.Test; 9 import org.junit.Test;
1 -package com.xkl; 1 +package com.xkl.partner;
2 2
  3 +import com.xkl.Constants;
  4 +import com.xkl.HttpTools;
  5 +import com.xkl.RtnCodeTools;
3 import org.junit.Assert; 6 import org.junit.Assert;
4 import org.junit.BeforeClass; 7 import org.junit.BeforeClass;
5 import org.junit.Test; 8 import org.junit.Test;
@@ -7,8 +10,6 @@ import org.junit.Test; @@ -7,8 +10,6 @@ import org.junit.Test;
7 import java.util.HashMap; 10 import java.util.HashMap;
8 import java.util.Map; 11 import java.util.Map;
9 12
10 -import static com.xkl.TokenTest.loginAndGetToken;  
11 -  
12 /** 13 /**
13 * Created by win7 on 2016/12/26. 14 * Created by win7 on 2016/12/26.
14 * 报告相关 15 * 报告相关
@@ -26,7 +27,7 @@ public class ReportTest { @@ -26,7 +27,7 @@ public class ReportTest {
26 public static void init() { 27 public static void init() {
27 28
28 // String token = OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID, Constants.USR_OPENID_TYPE); 29 // String token = OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID, Constants.USR_OPENID_TYPE);
29 - token = loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD); 30 + token = TokenTest.loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);
30 // String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE); 31 // String token =OpenIdTest.bindWithOpenIdAndLoginAndGetToken(Constants.USR_OPENID,Constants.USR_OPENID_TYPE);
31 } 32 }
32 33
1 -package com.xkl; 1 +package com.xkl.partner;
2 2
  3 +import com.xkl.Constants;
  4 +import com.xkl.EncodeTools;
  5 +import com.xkl.HttpTools;
  6 +import com.xkl.RtnCodeTools;
3 import org.json.JSONObject; 7 import org.json.JSONObject;
4 import org.junit.Assert; 8 import org.junit.Assert;
5 import org.junit.Test; 9 import org.junit.Test;
1 -package com.xkl; 1 +package com.xkl.partner;
2 2
  3 +import com.xkl.Constants;
  4 +import com.xkl.EncodeTools;
  5 +import com.xkl.HttpTools;
  6 +import com.xkl.RtnCodeTools;
3 import org.junit.Assert; 7 import org.junit.Assert;
4 import org.junit.Test; 8 import org.junit.Test;
5 9
6 import java.util.HashMap; 10 import java.util.HashMap;
7 import java.util.Map; 11 import java.util.Map;
8 12
9 -import static com.xkl.TokenTest.loginAndGetToken;  
10 -  
11 /** 13 /**
12 * Created by win7 on 2016/12/25. 14 * Created by win7 on 2016/12/25.
13 * 用户注册、修改密码、获取个人信息 15 * 用户注册、修改密码、获取个人信息
@@ -79,7 +81,7 @@ public class UserInfoTest { @@ -79,7 +81,7 @@ public class UserInfoTest {
79 params.put("type", Constants.KEY_ID); 81 params.put("type", Constants.KEY_ID);
80 params.put("sign", HttpTools.getSign(params)); 82 params.put("sign", HttpTools.getSign(params));
81 //获取token 83 //获取token
82 - String token = loginAndGetToken("15211112222", "pass152_new"); 84 + String token = TokenTest.loginAndGetToken("15211112222", "pass152_new");
83 System.out.println(token); 85 System.out.println(token);
84 String response = HttpTools.requestByMapWithToken(URL_USER, "PUT", params, token); 86 String response = HttpTools.requestByMapWithToken(URL_USER, "PUT", params, token);
85 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.USER_MODPASS_LOGOUT)); 87 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.USER_MODPASS_LOGOUT));
@@ -96,7 +98,7 @@ public class UserInfoTest { @@ -96,7 +98,7 @@ public class UserInfoTest {
96 params.put("type", Constants.KEY_ID); 98 params.put("type", Constants.KEY_ID);
97 params.put("sign", HttpTools.getSign(params)); 99 params.put("sign", HttpTools.getSign(params));
98 //获取token 100 //获取token
99 - String token = loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD); 101 + String token = TokenTest.loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);
100 System.out.println(token); 102 System.out.println(token);
101 String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token); 103 String response = HttpTools.requestByMapWithToken(URL_USER, "GET", params, token);
102 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC)); 104 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC));
@@ -74,6 +74,7 @@ public class AccountTest { @@ -74,6 +74,7 @@ public class AccountTest {
74 @Test 74 @Test
75 public void testLoginSuccess() { 75 public void testLoginSuccess() {
76 String response = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD); 76 String response = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
  77 + Assert.assertTrue(response.contains("_"));
77 System.out.println(response); 78 System.out.println(response);
78 } 79 }
79 80