Commit cadd900e by giaogiao

login单元测试

parent a974a9de
......@@ -59,45 +59,48 @@ public class LoginTest {
if (mySign.equals(sign)) {
System.out.println("一致" + mySign);
// return null;
//
// }
//
// // 判断client是否存在
// ImClient client = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
// .eq(ImClient::getFkAppid, imApplication.getId())
// .eq(ImClient::getClientId, clientId));
//
// if (client == null) {
// System.out.println("不存在");
//
// ImClient imClient = new ImClient();
// imClient.setId(new Snowflake(1L, 1L).nextId());
// imClient.setFkAppid(imApplication.getId());
// imClient.setClientId(clientId);
// imClientService.save(imClient);
//
// } else {
// System.out.println("存在");
// }
//
// // 生成token
// String generateToken = JwtUtil.generateToken(clientId, appKey, imApplication.getAppSecret(), Duration.ofDays(99999));
//
// // 保存redis
// redisTemplate.opsForValue().set("client:" + imApplication.getAppKey() + ":" + clientId, generateToken);
// return generateToken;
// }
//
// @Test
// public void test() throws Exception {
// // 时间戳
// String timestamp = "1629274899016";
// String clientId = "aaaaa2";
// String sign = "a404fe25d383eb154b3b527f7213b35a";
//
//
// String appKey = "QNtP3EjtLw26ekt0";
// String token = getToken(timestamp, clientId, appKey, sign);
// System.out.println("token:\n" + token);
// }
//}
} else {
System.out.println("不一致" + mySign);
return null;
}
// 判断client是否存在
ImClient client = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, imApplication.getId())
.eq(ImClient::getClientId, clientId));
if (client == null) {
System.out.println("不存在");
ImClient imClient = new ImClient();
imClient.setId(new Snowflake(1L, 1L).nextId());
imClient.setFkAppid(imApplication.getId());
imClient.setClientId(clientId);
imClientService.save(imClient);
} else {
System.out.println("存在");
}
// 生成token
String generateToken = JwtUtil.generateToken(clientId, appKey, imApplication.getAppSecret(), Duration.ofDays(99999));
// 保存redis
redisTemplate.opsForValue().set("client:" + imApplication.getAppKey() + ":" + clientId, generateToken);
return generateToken;
}
@Test
public void test() throws Exception {
// 时间戳
String timestamp = "1629274899016";
String clientId = "aaaaa2";
String sign = "a404fe25d383eb154b3b527f7213b35a";
String appKey = "QNtP3EjtLw26ekt0";
String token = getToken(timestamp, clientId, appKey, sign);
System.out.println("token:\n" + token);
}
}
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