package test;
import idNoUtils.IdNo;
import java.io.IOException;
import java.util.HashMap;
import org.json.JSONObject;
import org.testng.annotations.Test;
import com.al.api.net.Http;
import com.al.api.test.base.APIBase;
import com.al.core.annotation.DataFactory;
import com.al.core.nassert.NAssert;
import com.al.core.report.NReporter;
import common.BankCard;
import test.HashMapObject;
@DataFactory(dataPathKey= "DataPath")
public class OpenData extends APIBase{
// 宁波银行 ("621279", "16") 7600 中国银行("623040", "16") 5300
String mobile = "13536703795";
String bankCode = "5300";
String cardbin = "623040";
String cardlength = "16";
String vcode = "123456";
String id = "";
String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEq8eU4xQtq7f9hyWulOtzKClrbiCQuTQ8cq+jlqV6UqLllxWUe7O2qFsxGznmOrW5tyIXUuLbNUj+Gcq0+jgSl7rOqw1sEXkjvq3oujr7c5RUvaLgsSUhqmTyQlqIudPL7tHKfGr6TIMdV9s7CZ+e1YF6XpPbv7MwmCoM4rkVSQIDAQAB";
//发�1�7�短信验证码
@Test
public void sendSms(){
Http hf = Http.newInstance("10.17.171.11",8080);
//请求入参赋�1�7�1�7
HashMap<String,String> input = new HashMap<String,String>();
input.put("serviceKey", "sendSms");
input.put("mobile", mobile);
input.put("imgCode", "");
input.put("codeType", "0");
//发起post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//验证短信验证码成劄1�7
@Test(dependsOnMethods="sendSms")
public void vSmsCode( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//发�1�7�短信验证码请求入参赋�1�7�1�7
HashMap<String, String> params = new HashMap<String, String>();
params.put("mobile", mobile);
//请求入参对象封装
HashMap<String, String> input = new HashMap<String, String>();
params = HashMapObject.parameter(params);
//验证短信验证码请求入参赋倄1�7
input.put("serviceKey","vSmsCode");
input.put("mobile",params.get("mobile"));
input.put("vcode",vcode);
input.put("codeType",params.get("codeType"));
input.put("sVersion",params.get("sVersion"));
input.put("loginFlag",params.get("loginFlag"));
input.put("h5RecommenderNoId",params.get("h5RecommenderNoId"));
input.put("pinion_recommender_code",params.get("pinion_recommender_code"));
input.put("pinion_recommender_name",params.get("pinion_recommender_name"));
input.put("version_recommender_name",params.get("version_recommender_name"));
input.put("appPlatform",params.get("appPlatform"));
//验证短信验证码的请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
NAssert.assertNotNull(jo.getJSONObject("data").get("user_id"));
id = (String) jo.getJSONObject("data").get("user_id");
}
//上传身份证正靄1�7
@Test(dependsOnMethods="vSmsCode")
public void uploadIdpicurl(){
Http hf = Http.newInstance("10.17.171.11",8080);
//入参赋�1�7�1�7 flist[0].base64Data
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey","saveUserMaterial");
input.put("userId",id);
input.put("channel","jykh");
input.put("flist[0].fileType","3");
//生成图片base64砄1�7
String imageName ="photo.jpg";
try {
String imgbese = ImageTranscoding.imageToBase64(imageName);
input.put("flist[0].base64Data",imgbese);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//发起post请求
hf.post(conf.get("oasDomain") + "oas/restapi/material",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
//----------------------------------------------
input.replace("flist[0].fileType", "4");
//生成图片base64砄1�7
imageName ="idpicurl.jpg";
try {
String imgbese = ImageTranscoding.imageToBase64(imageName);
input.replace("flist[0].base64Data",imgbese);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//发起post请求
hf.post(conf.get("oasDomain") + "oas/restapi/material",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject joa = new JSONObject(hf.getResponse());
NAssert.assertEquals(joa.getString("responseCode"),"0");
//----------------------------------------------
input.replace("flist[0].fileType", "5");
//生成图片base64砄1�7
imageName ="idpicurlBack.jpg";
try {
String imgbese = ImageTranscoding.imageToBase64(imageName);
input.replace("flist[0].base64Data",imgbese);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//发起post请求
hf.post(conf.get("oasDomain") + "oas/restapi/material",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject job = new JSONObject(hf.getResponse());
NAssert.assertEquals(job.getString("responseCode"),"0");
}
//提交并确认个人信恄1�7
@Test(dependsOnMethods="uploadIdpicurl")
public void submitUserInfo(){
Http hf = Http.newInstance("10.17.171.11",8080);
//
HashMap<String, String> input = new HashMap<String, String>();
input.put("id", id );
input.put("idno", IdNo.idNo() );
input.put("serviceKey" ,"saveUserInfo");
input.put("infocolect_channel" ,"3");
input.put("idtype" ,"00");
input.put("custname" ,"自动");
input.put("borthday" ,"1978-05-28");
input.put("idbegindate" ,"2006-07-28");
input.put("idenddate" ,"2025-07-28");
input.put("nativeAddr" ,"自动化测试卢湾区淡春树里顶顶替砖石");
input.put("policeorg" ,"上肃市公安局卢寿分局");
input.put("usersex" ,"1");
input.put("nationality" ,"156");
input.put("addr" ,"自动化测试卢湾区淡春树里顶顶替砖石");
input.put("postid" ,"520000");
input.put("edu" ,"博士");
input.put("branchno" ,"8888");
input.put("provinceno" ,"03");
input.put("cityno" ,"");
input.put("ipaddr" ,"");
input.put("macaddr" ,"");
input.put("recommender_name" ,"恭喜发财");
input.put("recommender_idno" ,"8888888");
input.put("profession" ,"99");
input.put("profession_code" ,"03");
input.put("accountBeneficiary" ,"1");
input.put("actualController" ,"1");
input.put("creditRecord" ,"00");
input.put("taxPayer" ,"1");
input.put("appropriate_flag" ,"1");
//发起post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//提交股东户开通申评1�7
@Test(dependsOnMethods="submitUserInfo")
public void saveStepStatus( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//手机短信验证请求入参赋�1�7�1�7
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey","saveStepStatus");
input.put("userId",id);
input.put("szaStr","1");
input.put("shaStr","1");
//提交股东户开通申请请汄1�7
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//设置密码
@Test(dependsOnMethods="saveStepStatus")
public void findLoadAccount( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//手机短信验证请求入参赋�1�7�1�7
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey", "setTCPassword");
input.put("userId", id);
input.put("fundPwd", rsaUtils.EncryptPwd.testEncryptPwd("123123", publicKey));
input.put("tradePwd", rsaUtils.EncryptPwd.testEncryptPwd("123123", publicKey) );
//post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//银行卡绑宄1�7
@Test(dependsOnMethods="findLoadAccount")
public void bindBank( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//生成民生银行卄1�7
String bankAcct = BankCard.generateBankCard(cardbin,cardlength);
NReporter.info("银行卡号$1�7 "+ bankAcct);
//请求入参封装
HashMap<String,String> input = new HashMap<String,String>();
input.put("serviceKey", "bindTpBank" );
input.put("userId", id );
input.put("bankAcct", bankAcct );
input.put("fndacct", "" );
input.put("bankCode", bankCode);
input.put("bankPwd", "123456");
input.put("opType", "0");
//post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//提交风险测评答案
@Test(dependsOnMethods="bindBank")
public void saveRiskResult( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//手机短信验证请求入参赋�1�7�1�7
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey", "saveRiskResult");
input.put("ratingValue", "3;3;3;3;3;3;3;3,;3;3;3;");
input.put("userId", id);
//post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//提交问卷回访答案
@Test(dependsOnMethods="saveRiskResult")
public void visitsurveyFlag( ){
Http hf = Http.newInstance("10.17.171.11",8080);
//手机短信验证请求入参赋�1�7�1�7
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey", "visitsurveyFlag");
input.put("userId", id);
//post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0");
}
//同步个人信息
@Test(dependsOnMethods="visitsurveyFlag")
public void endPageDo(){
Http hf = Http.newInstance("10.17.171.11",8080);
//请求入参封装
HashMap<String, String> input = new HashMap<String, String>();
input.put("serviceKey", "endPageDo" );
input.put("userId", id );
//post请求
hf.post(conf.get("oasDomain") + "oas/restapi/service",input);
//校验请求响应砄1�7
NReporter.saveJSON(hf.getRequest(), hf.getResponse());
NAssert.assertEquals(hf.getStatus(), 200);
//校验接口响应
JSONObject jo = new JSONObject(hf.getResponse());
NAssert.assertEquals(jo.getString("responseCode"),"0","同步信息成功");
}
}
testng的用法--未消化的,未研究明白
猜你喜欢
转载自my.oschina.net/u/3563297/blog/1607301
今日推荐
周排行