Commit 024e5f1b authored by 龚小红's avatar 龚小红

增加Jmeter的authKey文件生成类

parent a65dbbf8
......@@ -1279,4 +1279,5 @@ public class BasicConfig {
//自动化用户
public static final String TEST_testerSave = MOBILE_HOST + "/test/user/test/save";
public static final String TEST_testerDelete = MOBILE_HOST + "/test/user/test/delete";
public static final String MANAGER_encryptAuthKey = MANAGER_HOST + "/kjy/manager/testUser/encryptAuthKey";
}
......@@ -6,4 +6,7 @@ public class UserSqlFactory {
public static final String selectUserIdByUnionId = "select id from tb_users where union_id=?";
public static final String selectUserIdByOpenId = "SELECT user_id FROM `tb_users_wx_ext` WHERE `open_id` = ?";
public static final String selectUserIdForJmeter = "SELECT a.`id` FROM `tb_live_user` a, `tb_users` b ,`tb_users_wx_ext` c WHERE a.`biz_user_id` = b.`id` and b.`id` = c.`user_id` and b.`union_id` NOT LIKE \"-d%\" AND c.`open_id` IS NOT NULL and c.`oa_id` = 14";
}
......@@ -59,7 +59,7 @@ public class BaseUtils {
}
/**
* 小葡萄关注客集集微信公众号
* 关注客集集微信公众号
*/
public static String subscribe(String openId) throws SQLException {
//关注公众号
......@@ -85,7 +85,7 @@ public class BaseUtils {
}
/**
* 小葡萄取关客集集微信公众号
* 取关客集集微信公众号
*/
public static Object unsubscribe(String openId) throws SQLException {
//取关公众号
......
package com.kjj.utils;
import com.kjj.config.BasicConfig;
import com.kjj.sql.KjyUserDB;
import com.kjj.sql.UserSqlFactory;
import io.restassured.response.Response;
import org.testng.Assert;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JmeterAccountFile {
private static final NetworkUtils network = NetworkUtils.getInstance();
public static void main(String[] args) {
String path = String.valueOf(JmeterAccountFile.class.getResource("/"));
accountFile(path);
}
public static void accountFile(String path) {
BaseUtils.ssoLogin();
// 保存路径
String file = path + "AccountFile.txt";
// 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw
try {
File accountFile = new File("AccountFile.txt");// 相对路径,如果没有则要建立一个新的output。txt文件
// 判断文件是否存在,不存在即新建
if(!accountFile.exists()) {
accountFile.createNewFile(); // 创建新文件
}
// 如果是在原有基础上写入则append属性为true,默认为false
BufferedWriter out = new BufferedWriter(new FileWriter(accountFile,true));
//获取直播用户id
List<Map<String, Object>> result = KjyUserDB.getInstance().findModeResult(UserSqlFactory.selectUserIdForJmeter);
for (Map<String, Object> item:result
) {
System.out.println(item.get("id"));
Map<String, Object> subscribeParam = new HashMap<>();
subscribeParam.put("liveUserId", item.get("id"));
subscribeParam.put("validDays", 365);
Response subscribeRes = network.getResponse(subscribeParam, BasicConfig.MANAGER_encryptAuthKey);
String data = subscribeRes.jsonPath().getString("data");
Assert.assertNotNull(data, network.message(subscribeParam, BasicConfig.MANAGER_encryptAuthKey, "增加测试用户失败", subscribeRes.body().asString()));
System.out.println(data);
out.write(data+"\t\n"); // 写入TXT
out.flush(); // 把缓存区内容压入文件
}
out.close(); // 最后记得关闭文件
} catch (SQLException throwables) {
throwables.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment