更新并测试了与MIS和VMS的通信接口

This commit is contained in:
free will committed 2021-11-04 17:21:05 +08:00
1 parent 7e8a3fe785
commit b14e137cba
1 file changed
+31 -5
+31 -5
View File
@@ -7,6 +7,7 @@ import VMSConnection.Utils.Base64Helper;
import org.bouncycastle.crypto.CryptoException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
/*
* @Author: Wang Feng
@@ -36,6 +37,8 @@ public class TestAPI {
String email="2hsagk3ss@163.com";
String phone="15239970973";
String passwd="password";
String machineInfo="Android-GuessMe";
String smscode = "";
int userID=1;
// 模拟客户端生成自己的公钥私钥
BC_KeyManager bc_keyManager=new BC_KeyManager();
@@ -59,9 +62,9 @@ public class TestAPI {
boolean _regis=false;
boolean _login=false;
boolean _getvpninfo=false;
boolean _getsmscode=true;
boolean _getsmscode=false;
boolean _deleteMachine=false;
boolean _changepw=false;
boolean _changepw=true;
// 测试验签结果
// boolean rr=new BC_KeyManager().Verify(username.getBytes(StandardCharsets.UTF_8),new String(sig),pubkey);
@@ -93,11 +96,14 @@ public class TestAPI {
System.out.println(networkResponse.Code);
}
// String fakeData="Host1,Host2,Host3";
// String[] recordedHosts=fakeData.split(",");
// System.out.println(Arrays.toString(recordedHosts));
// 构造登录请求包
if(_login){
LoginWithSignRequest loginWithSignRequest=new LoginWithSignRequest(username,
"password","cert",sig,"Android-GuessMe3");
"password","cert",sig,machineInfo);
try {
System.out.println("login request: "+loginWithSignRequest.toJson());
} catch (IllegalAccessException e) {
@@ -111,6 +117,12 @@ public class TestAPI {
e.printStackTrace();
}
System.out.println(networkResponse2.Code);
if(networkResponse2.Code==409){ // 409表示可用设备已满,服务器传回了可用设备信息
System.out.println("可用设备信息: "+new String(networkResponse2.Data));
// 由于服务器端需要在半个月后才能第一次删除设备,故这里用假数据做解析
String[] recordedHosts=new String(networkResponse2.Data).split(",");
// return recordedHosts; // 解析成功后,将主机数据渲染到界面,支持用户去选择和删除
}
}
// 构造vpnserver信息请求包
@@ -133,7 +145,7 @@ public class TestAPI {
// 获取验证码
if(_getsmscode){
GetVerificationCode getVerificationCode=new GetVerificationCode(username,phone);
GetVerificationCode getVerificationCode=new GetVerificationCode(username,"86"+phone);
try {
System.out.println("sms request: "+getVerificationCode.toJson());
} catch (IllegalAccessException e) {
@@ -150,7 +162,21 @@ public class TestAPI {
}
if(_deleteMachine){
DeleteMachineInfoFromUser deleteMachineInfoFromUser=new DeleteMachineInfoFromUser(
username,machineInfo,phone,smscode);
try {
System.out.println("delete request: "+deleteMachineInfoFromUser.toJson());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
// 删除用户设备
NetworkResponse networkResponse3=bc_api.deleteMachineInfoFromUser(deleteMachineInfoFromUser);
try {
System.out.println("删除用户设备的应答: "+networkResponse3.toJson());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
System.out.println(networkResponse3.Code);
}
// 修改密码