mock测试(挡板测试)

news2024/12/23 11:02:52

https://www.cnblogs.com/lc-blogs/p/17027617.html

mock测试(挡板测试)就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法。
比如:测试天气这个接口,最近上海都没有下雪,那么我怎么去模拟下雪这个场景?需要等到真正下雪的哪天才可以吗?这个时候就可以通过mock来帮助我们完成下雪的场景了

  1. 后端代码还未开发完,前端代码需要调用后端接口进行调试,怎么办?
  2. 无法控制第三方系统某个接口的返回,返回的数据不满足要求?
  3. 需要跟第三方联调但对方还未开发完成,如何提早测试?
  4. 不用等开发人员开发完接口再进行自动化测试case的编写,在这个过程中可以修改、补case,在后端开发接口完成以后,只需要执行测试case,省去了很大的工作量,并且这些完善的用例脚本,用自动化去执行,效果更好。

fiddler之AutoResponder

AutoResponder参考:AutoResponder的使用

postman之Mock Server

Mock Server参考:Mock Server的使用

moco-runner

Moco是一个简单搭建模拟服务器的框架(工具),可以模拟http、https、socket等协议。基于Java开源(必须java环境)。
准备工具:jdk环境:jdk的安装与配置

http协议

1、下载

下载地址:Central Repository: com/github/dreamhead/moco-runner
GitHub:GitHub - dreamhead/moco: Easy Setup Stub Server

启动命令:
java -jar moco的jar文件  协议类型  -p 端口号 -c json配置文件

<span style="background-color:#282c34"><span style="color:#abb2bf">java -jar moco-runner-<span style="color:#d19a66">1.3</span>.<span style="color:#d19a66">0</span>-standalone.jar http -p <span style="color:#d19a66">9090</span> -c result.json

<span style="color:#98c379">//</span>jar包的名称根据自己下载的jar包版本来写;
<span style="color:#98c379">//</span>http 代表这个模拟的是http请求;
<span style="color:#98c379">//</span>-p <span style="color:#d19a66">9090</span> 是定义端口号;
<span style="color:#98c379">//</span>-c result.json 是编辑请求与响应的json文件名;</span></span>

2、使用

  • 新建文件夹,例如:mock
  • 将下载的moco-runner-1.3.0-standalone.jar放到mock文件夹中

3、模拟get接口响应(不带参数)

1)新建json文件(例如:result.json)放到mock文件夹中,json文件用来存放接口mock响应数据

2)打开result.json文件,模拟get请求不带参数,编辑如下:

<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"首页(不带参数)"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/index"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"get"</span>
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"text"</span>: <span style="color:#98c379">"进入首页成功!"</span>
		}
	}
]

<span style="color:#b18eb1"><em>//description:接口描述信息</em></span>
<span style="color:#b18eb1"><em>//request:所有请求的数据</em></span>
<span style="color:#b18eb1"><em>//uri:请求路径</em></span>
<span style="color:#b18eb1"><em>//method:HTTP请求类型GET|POST|PUT|DELETE</em></span>
<span style="color:#b18eb1"><em>//response:所有的响应数据</em></span>
<span style="color:#b18eb1"><em>//text:响应的文本</em></span></span></span>

3)启动

  • 在创建的mockrunner文件夹中启动cmd窗口

  • 在cmd窗口输入命令:java -jar moco-runner-1.3.0-standalone.jar http -p 9090 -c result.json
<span style="background-color:#282c34"><span style="color:#abb2bf">java -jar moco-runner-<span style="color:#d19a66">1.3</span>.<span style="color:#d19a66">0</span>-standalone.jar http -p <span style="color:#d19a66">9090</span> -c result.json

<span style="color:#98c379">//</span>jar包的名称根据自己下载的jar包版本来写;
<span style="color:#98c379">//</span>http 代表这个模拟的是http请求;
<span style="color:#98c379">//</span>-p <span style="color:#d19a66">9090</span> 是定义端口号;
<span style="color:#98c379">//</span>-c result.json 是编辑请求与响应的json文件名;</span></span>

下图表示启动成功:

  • 停止mock服务,使用Ctrl+c,或者关闭cmd窗口

  • 启动服务后,在浏览器中访问:127.0.0.1:9090/index

postmanq发送请求示例

4、模拟get接口响应(带参数)

  • 编辑mock.json文件,模拟get请求带参数,编辑如下:
<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"个人主页"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/userhomepage"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"get"</span>,
			<span style="color:#d19a66">"queries"</span>: {
				<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3882"</span>,
				<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"code"</span>: <span style="color:#98c379">"10000"</span>,
				<span style="color:#d19a66">"message"</span>: <span style="color:#98c379">"进入个人主页成功"</span>,
				<span style="color:#d19a66">"data"</span>: {
					<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>,
					<span style="color:#d19a66">"age"</span>: <span style="color:#98c379">"19"</span>,
					<span style="color:#d19a66">"addr"</span>: <span style="color:#98c379">"beijing"</span>,
					<span style="color:#d19a66">"tel"</span>: <span style="color:#98c379">"15512348888"</span>,
					<span style="color:#d19a66">"lastlogin"</span>: <span style="color:#98c379">"2020-10-01 10:55:23"</span>
				}
			}
		}
	}
 ]

<span style="color:#b18eb1"><em>//headers设置response的返回数据为application/json</em></span>
<span style="color:#b18eb1"><em>//request中的queries:定义get请求参</em></span></span></span>

postman发送请求示例

5、模拟post请求

  • 1)传递参数 Content-Type: application/json 为JSON格式,传递的参数是以JSON格式,参数包含在一对花括号中,以键值对的方式。
    编辑mock.json文件,模拟post请求,编辑如下:
<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"登录,请求Content-Type:application/json"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/login"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"username"</span>: <span style="color:#98c379">"admin"</span>,
				<span style="color:#d19a66">"password"</span>: <span style="color:#98c379">"123456"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"code"</span>: <span style="color:#98c379">"10000"</span>,
				<span style="color:#d19a66">"message"</span>: <span style="color:#98c379">"登录成功"</span>,
				<span style="color:#d19a66">"data"</span>: {
					<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3882"</span>,
					<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>,
					<span style="color:#d19a66">"addr"</span>: <span style="color:#98c379">"chengdu"</span>,
					<span style="color:#d19a66">"tel"</span>: <span style="color:#98c379">"13355556666"</span>,
					<span style="color:#d19a66">"token"</span>: <span style="color:#98c379">"mocktoken9gd878ad"</span>
				}
			}
		}
	}
]

<span style="color:#b18eb1"><em>//headers中的"Content-Type": "application/json"指传递参数以json方式</em></span>
<span style="color:#b18eb1"><em>//headers中的"token": "mocktoken"指请求头中必须加上token才能访问</em></span>
<span style="color:#b18eb1"><em>//status:定义http响应状态码</em></span></span></span>

postman发送请求示例

  • 2)传递参数 Content-Type: multipart/form-data 为form-data格式,参数写在body中以参数名称和值对应关系,常用于传递参数和文件,请求的Content-Type字段中有一个boundary字段,传参时每个参数都是由一对boundary包含。
    编辑mock.json文件,模拟post请求,编辑如下:
<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"商品详情页,请求Content-Type:multipart/form-data"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/details"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"forms"</span>: {
				<span style="color:#d19a66">"goodid"</span>: <span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"20220101"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"goodid"</span>: <span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"name"</span>:<span style="color:#98c379">"pears"</span>,
				<span style="color:#d19a66">"status"</span>:<span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"stock"</span>:<span style="color:#98c379">"25"</span>,
				<span style="color:#d19a66">"vip_amount "</span>:<span style="color:#98c379">"24"</span>,
				<span style="color:#d19a66">"sale_amount"</span>:<span style="color:#98c379">"18"</span>,
				<span style="color:#d19a66">"market_amount"</span>:<span style="color:#98c379">"23.6"</span>,
				<span style="color:#d19a66">"attribute_value"</span>:<span style="color:#98c379">"丰富营养"</span>,
				<span style="color:#d19a66">"product_attr_vals"</span>:<span style="color:#98c379">"单果300g"</span>,
				<span style="color:#d19a66">"share_title"</span>:<span style="color:#98c379">"分享标题"</span>,
				<span style="color:#d19a66">"share_descrip"</span>:<span style="color:#98c379">"分享描述"</span>,
				<span style="color:#d19a66">"license"</span>:<span style="color:#98c379">"营业执照"</span>,
				<span style="color:#d19a66">"employType"</span>:<span style="color:#d19a66">0</span>
			}
		}
	}
]</span></span>

postman发送请求示例

  • 3)传递参数 Content-Type: application/x-www-form-urlencoded 格式,和get请求传递参数一样的方式,区别get请求参数拼接在url中,post请求参数在body中。
    编辑mock.json文件,模拟post请求,编辑如下:
<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"订单详情页,请求Content-Type:application/x-www-form-urlencoded"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/order"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/x-www-form-urlencoded"</span>
			},
			<span style="color:#d19a66">"forms"</span>: {
				<span style="color:#d19a66">"ordernum"</span>: <span style="color:#98c379">"20201010"</span>,
				<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3218"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"orderNo"</span>: <span style="color:#98c379">"LO20111216292785711001"</span>,
				<span style="color:#d19a66">"productId"</span>:<span style="color:#d19a66">2</span>,
				<span style="color:#d19a66">"skuId"</span>:<span style="color:#d19a66">22</span>,
				<span style="color:#d19a66">"expert"</span>:<span style="color:#d19a66">0</span>,
				<span style="color:#d19a66">"count"</span>:<span style="color:#d19a66">1</span>,
				<span style="color:#d19a66">"payType"</span>:<span style="color:#98c379">"WECHAT_PAY"</span>,
				<span style="color:#d19a66">"payClient"</span>:<span style="color:#98c379">"MINI"</span>,
				<span style="color:#d19a66">"mobile"</span>:<span style="color:#98c379">"15812345678"</span>,
				<span style="color:#d19a66">"goodname"</span>:<span style="color:#98c379">"apple"</span>,
				<span style="color:#d19a66">"orderType"</span>:<span style="color:#98c379">"NORMAL"</span>,
				<span style="color:#d19a66">"logistics"</span>:<span style="color:#98c379">"NONE"</span>
			}
		}
	}
]</span></span>

postman发送请求示例

mock文件参数详解

description:请求描述(程序不会识别到)

request:请求内容

  • uri:请求的url资源路径
  • method:请求类型,支持HTTP协议相关的请求类型,如post/get/put/delete等
  • headers:request的请求头
  • token:接口请求必须在headers带的token
  • cookies:接口进行cookie信息的校验
  • queries:get请求的请求参数
  • forms:post的表单请求体
  • json:request的请求json数据,当然也可是本地的json文件(可实现数据分离)

response:响应内容

  • status:定义http响应状态码
  • headers:response的响应头
  • json:response的响应json数据,当然也可是本地的json文件(可实现数据分离)
  • text:text响应体
  • redirectTo:请求时重定向

注:多个请求的mock可以写到一个文件中,每个mock之间以英文的逗号间隔,以下为不同请求方式的接口

<span style="background-color:#282c34"><span style="color:#abb2bf">[
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"首页"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/index"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"get"</span>
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"text"</span>: <span style="color:#98c379">"Welcome to the the home page..."</span>
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"个人主页"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/userhomepage"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"get"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"token"</span>: <span style="color:#98c379">"mocktoken9gd878ad"</span>
			},
			<span style="color:#d19a66">"queries"</span>: {
				<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3882"</span>,
				<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"code"</span>: <span style="color:#98c379">"10000"</span>,
				<span style="color:#d19a66">"message"</span>: <span style="color:#98c379">"进入个人主页成功"</span>,
				<span style="color:#d19a66">"data"</span>: {
					<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>,
					<span style="color:#d19a66">"age"</span>: <span style="color:#98c379">"19"</span>,
					<span style="color:#d19a66">"addr"</span>: [<span style="color:#98c379">"beijing"</span>,<span style="color:#98c379">"shanghai"</span>,<span style="color:#98c379">"chengdu"</span>],
					<span style="color:#d19a66">"tel"</span>: <span style="color:#98c379">"15512348888"</span>,
					<span style="color:#d19a66">"lastlogin"</span>: <span style="color:#98c379">"2020-10-01 10:55:23"</span>
				}
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"登录,请求Content-Type:application/json"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/login"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"username"</span>: <span style="color:#98c379">"admin"</span>,
				<span style="color:#d19a66">"password"</span>: <span style="color:#98c379">"123456"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"code"</span>: <span style="color:#98c379">"10000"</span>,
				<span style="color:#d19a66">"message"</span>: <span style="color:#98c379">"登录成功"</span>,
				<span style="color:#d19a66">"data"</span>: {
					<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3882"</span>,
					<span style="color:#d19a66">"name"</span>: <span style="color:#98c379">"lucy"</span>,
					<span style="color:#d19a66">"addr"</span>: <span style="color:#98c379">"chengdu"</span>,
					<span style="color:#d19a66">"tel"</span>: <span style="color:#98c379">"13355556666"</span>,
					<span style="color:#d19a66">"token"</span>: <span style="color:#98c379">"mocktoken9gd878ad"</span>
				}
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"商品详情页,请求Content-Type:multipart/form-data"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/details"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"forms"</span>: {
				<span style="color:#d19a66">"goodid"</span>: <span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"20220101"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"goodid"</span>: <span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"name"</span>:<span style="color:#98c379">"pears"</span>,
				<span style="color:#d19a66">"status"</span>:<span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"stock"</span>:<span style="color:#98c379">"25"</span>,
				<span style="color:#d19a66">"vip_amount "</span>:<span style="color:#98c379">"24"</span>,
				<span style="color:#d19a66">"sale_amount"</span>:<span style="color:#98c379">"18"</span>,
				<span style="color:#d19a66">"market_amount"</span>:<span style="color:#98c379">"23.6"</span>,
				<span style="color:#d19a66">"attribute_value"</span>:<span style="color:#98c379">"丰富营养"</span>,
				<span style="color:#d19a66">"product_attr_vals"</span>:<span style="color:#98c379">"单果300g"</span>,
				<span style="color:#d19a66">"share_title"</span>:<span style="color:#98c379">"分享标题"</span>,
				<span style="color:#d19a66">"share_descrip"</span>:<span style="color:#98c379">"分享描述"</span>,
				<span style="color:#d19a66">"license"</span>:<span style="color:#98c379">"营业执照"</span>,
				<span style="color:#d19a66">"employType"</span>:<span style="color:#d19a66">0</span>
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"订单详情页,请求Content-Type:application/x-www-form-urlencoded"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/order"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/x-www-form-urlencoded"</span>,
				<span style="color:#d19a66">"token"</span>: <span style="color:#98c379">"mocktoken9gd878ad"</span>
			},
			<span style="color:#d19a66">"forms"</span>: {
				<span style="color:#d19a66">"ordernum"</span>: <span style="color:#98c379">"20201010"</span>,
				<span style="color:#d19a66">"userid"</span>: <span style="color:#98c379">"3218"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"orderNo"</span>: <span style="color:#98c379">"LO20111216292785711001"</span>,
				<span style="color:#d19a66">"productId"</span>:<span style="color:#d19a66">2</span>,
				<span style="color:#d19a66">"skuId"</span>:<span style="color:#d19a66">22</span>,
				<span style="color:#d19a66">"expert"</span>:<span style="color:#d19a66">0</span>,
				<span style="color:#d19a66">"count"</span>:<span style="color:#d19a66">1</span>,
				<span style="color:#d19a66">"payType"</span>:<span style="color:#98c379">"WECHAT_PAY"</span>,
				<span style="color:#d19a66">"payClient"</span>:<span style="color:#98c379">"MINI"</span>,
				<span style="color:#d19a66">"mobile"</span>:<span style="color:#98c379">"15812345678"</span>,
				<span style="color:#d19a66">"goodname"</span>:<span style="color:#98c379">"apple"</span>,
				<span style="color:#d19a66">"orderType"</span>:<span style="color:#98c379">"NORMAL"</span>,
				<span style="color:#d19a66">"logistics"</span>:<span style="color:#98c379">"NONE"</span>
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"物流详情,请求Content-Type:application/json,必须加上token才能访问"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/logistics"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json"</span>,
				<span style="color:#d19a66">"token"</span>: <span style="color:#98c379">"mocktoken9gd878ad"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"LogisticCode"</span>: <span style="color:#98c379">"118461988807"</span>,
				<span style="color:#d19a66">"ShipperCode"</span>: <span style="color:#98c379">"SF"</span>
			}
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"EBusinessID"</span>: <span style="color:#98c379">"1109259"</span>,
				<span style="color:#d19a66">"OrderCode"</span>: <span style="color:#98c379">"1"</span>,
				<span style="color:#d19a66">"ShipperCode"</span>: <span style="color:#98c379">"SF"</span>,
				<span style="color:#d19a66">"LogisticCode"</span>: <span style="color:#98c379">"118461988807"</span>,
				<span style="color:#d19a66">"Success"</span>: <span style="color:#56b6c2">true</span>,
				<span style="color:#d19a66">"CallBack"</span>:<span style="color:#98c379">""</span>,
				<span style="color:#d19a66">"State"</span>: <span style="color:#d19a66">3</span>,
				<span style="color:#d19a66">"Reason"</span>: <span style="color:#56b6c2">null</span>,
				<span style="color:#d19a66">"Traces"</span>: [
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/25 08:05:37"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"正在派件..(派件人邓裕富,电话:18718866310)[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"超时1小时"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/25 04:01:28"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"快件在深圳集散中心,准备送往下一站深圳[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"准时到达"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/25 01:41:06"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"快件在深圳集散中心[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"提前10分钟"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/24 20:18:58"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"已收件[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"准时到达"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/24 20:55:28"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"快件在深圳,准备送往下一站深圳集散中心[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"超时30分钟"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/25 10:23:03"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"派件已签收[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"超时17分钟"</span>
					},
					{
					<span style="color:#d19a66">"AcceptTime"</span>: <span style="color:#98c379">"2014/06/25 10:23:03"</span>,
					<span style="color:#d19a66">"AcceptStation"</span>: <span style="color:#98c379">"签收人是:已签收[深圳市]"</span>,
					<span style="color:#d19a66">"Remark"</span>: <span style="color:#98c379">"送货上门签收"</span>
					}
				]
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"上传json文件,仅能postman使用binary访问"</span>,
        <span style="color:#d19a66">"request"</span>: {
            <span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/file"</span>,
            <span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"post"</span>,
            <span style="color:#d19a66">"file"</span>: {
                <span style="color:#d19a66">"json"</span>: <span style="color:#98c379">"C:\\data.json"</span>
            }
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>: {
				<span style="color:#d19a66">"code"</span>:<span style="color:#98c379">"10000"</span>,
				<span style="color:#d19a66">"message"</span>:<span style="color:#98c379">"文件上传成功"</span>,
				<span style="color:#d19a66">"data"</span>:{
				}
			}
		}
	},
	{
		<span style="color:#d19a66">"description"</span>:<span style="color:#98c379">"重定向到百度"</span>,
		<span style="color:#d19a66">"request"</span>:{
		  <span style="color:#d19a66">"uri"</span>:<span style="color:#98c379">"/redirect"</span>,
		  <span style="color:#d19a66">"method"</span>:<span style="color:#98c379">"get"</span>
		},
		<span style="color:#d19a66">"redirectTo"</span>:<span style="color:#98c379">"http://www.baidu.com"</span>,
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">301</span>
		}
	},
	{
		<span style="color:#d19a66">"description"</span>: <span style="color:#98c379">"查询天气"</span>,
		<span style="color:#d19a66">"request"</span>: {
			<span style="color:#d19a66">"uri"</span>: <span style="color:#98c379">"/weatherquery"</span>,
			<span style="color:#d19a66">"method"</span>: <span style="color:#98c379">"get"</span>
		},
		<span style="color:#d19a66">"response"</span>: {
			<span style="color:#d19a66">"status"</span>: <span style="color:#d19a66">200</span>,
			<span style="color:#d19a66">"headers"</span>: {
				<span style="color:#d19a66">"Content-Type"</span>: <span style="color:#98c379">"application/json;charset=UTF-8"</span>
			},
			<span style="color:#d19a66">"json"</span>:{
				<span style="color:#d19a66">"reason"</span>: <span style="color:#98c379">"查询成功"</span>,
				<span style="color:#d19a66">"result"</span>:{
					<span style="color:#d19a66">"city"</span>:<span style="color:#98c379">"苏州"</span>,
					<span style="color:#d19a66">"realtime"</span>:{
						<span style="color:#d19a66">"temperature"</span>:<span style="color:#98c379">"4"</span>,
						<span style="color:#d19a66">"humidity"</span>:<span style="color:#98c379">"82"</span>,
						<span style="color:#d19a66">"info"</span>:<span style="color:#98c379">"阴天"</span>,
						<span style="color:#d19a66">"wid"</span>:<span style="color:#98c379">"02"</span>,
						<span style="color:#d19a66">"direct"</span>:<span style="color:#98c379">"西北方向"</span>,
						<span style="color:#d19a66">"power"</span>:<span style="color:#98c379">"3"</span>,
						<span style="color:#d19a66">"aqi"</span>:<span style="color:#98c379">"80"</span>
					},
					<span style="color:#d19a66">"future"</span>:[{
							<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"2019-02-22"</span>,
							<span style="color:#d19a66">"temperature"</span>:<span style="color:#98c379">"1/7摄氏"</span>,
							<span style="color:#d19a66">"weather"</span>:<span style="color:#98c379">"小雨转多yun"</span>,
							<span style="color:#d19a66">"wid"</span>:{
								<span style="color:#d19a66">"day"</span>:<span style="color:#98c379">"07"</span>,
								<span style="color:#d19a66">"night"</span>:<span style="color:#98c379">"12"</span>
							},
							<span style="color:#d19a66">"direct"</span>:<span style="color:#98c379">"北风转西北风"</span>
						},
						{
							<span style="color:#d19a66">"date"</span>:<span style="color:#98c379">"2019-02-23"</span>,
							<span style="color:#d19a66">"temperature"</span>:<span style="color:#98c379">"2/11摄氏"</span>,
							<span style="color:#d19a66">"weather"</span>:<span style="color:#98c379">"多云转阴"</span>,
							<span style="color:#d19a66">"wid"</span>:{
								<span style="color:#d19a66">"day"</span>:<span style="color:#98c379">"01"</span>,
								<span style="color:#d19a66">"night"</span>:<span style="color:#98c379">"02"</span>
							},
							<span style="color:#d19a66">"direct"</span>: <span style="color:#98c379">"北风转东北风"</span>
						},
						{
							<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"2019-02-24"</span>,
							<span style="color:#d19a66">"temperature"</span>: <span style="color:#98c379">"6/12摄氏"</span>,
							<span style="color:#d19a66">"weather"</span>: <span style="color:#98c379">"多云"</span>,
							<span style="color:#d19a66">"wid"</span>: {
								<span style="color:#d19a66">"day"</span>: <span style="color:#98c379">"01"</span>,
								<span style="color:#d19a66">"night"</span>: <span style="color:#98c379">"05"</span>
							},
							<span style="color:#d19a66">"direct"</span>: <span style="color:#98c379">"东北风转北风"</span>
						},
						{
							<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"2019-02-25"</span>,
							<span style="color:#d19a66">"temperature"</span>: <span style="color:#98c379">"5/12摄氏"</span>,
							<span style="color:#d19a66">"weather"</span>: <span style="color:#98c379">"小雨转晴"</span>,
							<span style="color:#d19a66">"wid"</span>: {
								<span style="color:#d19a66">"day"</span>: <span style="color:#98c379">"07"</span>,
								<span style="color:#d19a66">"night"</span>: <span style="color:#98c379">"09"</span>
							},
							<span style="color:#d19a66">"direct"</span>: <span style="color:#98c379">"东风转北风向"</span>
						},
						{
							<span style="color:#d19a66">"date"</span>: <span style="color:#98c379">"2019-02-26"</span>,
							<span style="color:#d19a66">"temperature"</span>: <span style="color:#98c379">"5/11摄氏"</span>,
							<span style="color:#d19a66">"weather"</span>: <span style="color:#98c379">"多云转小yu"</span>,
							<span style="color:#d19a66">"wid"</span>: {
								<span style="color:#d19a66">"day"</span>: <span style="color:#98c379">"01"</span>,
								<span style="color:#d19a66">"night"</span>: <span style="color:#98c379">"07"</span>
							},
							<span style="color:#d19a66">"direct"</span>: <span style="color:#98c379">"东南风向"</span>
						}
					]
				},
			<span style="color:#d19a66">"error_code"</span>: <span style="color:#d19a66">0</span>
		}
	}
}
]
</span></span>

https协议

添加https证书

1、在C:\Users\Administrator路径下新建.keystore用来保存证书

(设置的电脑名称不一样对应路径有区别)

2、生成https证书文件(可以是cer或者jks格式)

使用win+r输入cmd,在cmd窗口输入如下命令

<span style="background-color:#282c34"><span style="color:#abb2bf">keytool -genkey -alias cps.cer -keyalg RSA -keystore C:<span style="color:#61aeee">\U</span>sers<span style="color:#61aeee">\A</span>dministrator<span style="color:#61aeee">\.</span>keystore<span style="color:#61aeee">\h</span>ttpsmoco.cer -keysize 1024 -validity 99999</span></span>

操作是在命令行里完成的,命令解释:
-alias 别名,每个证书都要起自己独有的名字
-keyalg 如果是RSA算法,那么就是RSA
-keystore 填写完整的keystore文件保存路径以及文件名
-keysize 秘钥长度,一般1024
-validity 有效天数

之后会让输入 秘钥库 的密码,连续输入两遍,这里自行设置即可,然后会要求填写一些项目,姓名,组织机构,城市等等,最后会要求输入 证书 的密码,也是连续输入两遍,与证书库密码一样的话可以直接回车确(秘钥库密码和证书密码启动moco要使用)

3、JKS秘钥库使用专用命令再次尝试:

<span style="background-color:#282c34"><span style="color:#abb2bf">keytool -importkeystore -srckeystore C:<span style="color:#61aeee">\U</span>sers<span style="color:#61aeee">\A</span>dministrator<span style="color:#61aeee">\.</span>keystore<span style="color:#61aeee">\h</span>ttpsmoco.cer -destkeystore C:<span style="color:#61aeee">\U</span>sers<span style="color:#61aeee">\A</span>dministrator<span style="color:#61aeee">\.</span>keystore<span style="color:#61aeee">\h</span>ttpsmoco.cer -deststoretype pkcs12</span></span>

操作如下:

这样证书就生成成功,可以去目录查看。操作如下:

4、启动https服务

进入moco-runner-1.3.0-standalone.jar所在目录,然后进入 cmd 界面,输入启动https服务的命令

<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#98c379">java</span> -jar moco-runner-<span style="color:#d19a66">1</span>.<span style="color:#d19a66">3</span>.<span style="color:#d19a66">0</span>-standalone.jar https -p <span style="color:#d19a66">443</span> -c result.json --https C:\Users\Administrator\.keystore\httpsmoco.cer --cert httpsmoco --keystore httpsmoco</span></span>

命令解释:
【443】https服务默认开启的是443端口
【C:\Users\Administrator.keystore\httpsmoco.cer】cer证书所在路径
【--cert httpsmoco】秘钥库的密码(在第2步设置的秘钥库口令)
【--keystore httpsmoco】证书/秘钥的密码(在第2步设置的秘钥口令)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/649461.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

RIP协议路由配置(Cisco Packet Tracer)

实验环境&#xff1a; windows10操作系统、思科模拟器、网络正常&#xff1b; 实验内容&#xff1a; 新建packettracer拓扑图&#xff1b;设置PC机的网络配置信息&#xff1b;配置路由器的接口IP&#xff1b;为路由器的RIP添加地址&#xff1b;为路由器添加静态路由。测试PC…

由于找不到wpcap.dll导致软件无法运行的解决办法,特此记录

由于找不到wpcap.dll导致软件无法运行的解决办法&#xff0c;特此记录提示 目录 前言 一、解决找不到wpcap.dll错误的办法 前言 今天在运行一个软件时弹出&#xff0c;找不到wpcap.dll&#xff0c;无法运行的弹出&#xff0c;目前已解决此问题&#xff0c;特此记录&#xff…

MQTT服务等级

1.QoS含义 Quality of Service,服务质量 很多时候&#xff0c;使用 MQTT 协议的设备都运行在网络受限的环境下&#xff0c;而只依靠底层的 TCP传输协议&#xff0c;并不能完全保证消息的可靠到达。因此&#xff0c;MQTT 提供了 QoS机制&#xff0c;其核心是设计了多种消息交互…

什么是electron?

Electron是一个使用 JavaScript、HTML 和 CSS 构建桌面应用程序的框架。 嵌入 Chromium 和 Node.js 到 二进制的 Electron 允许您保持一个 JavaScript 代码代码库并创建 在Windows上运行的跨平台应用 macOS和Linux——不需要本地开发 经验 election的主要组成部分&#xff1a;…

5、共享模型之内存

目录 5.1 Java的内存模型5.2 可见性1、退不出的循环2、解决办法&#xff1a;3、可见性 vs 原子性 5.3 有序性1、为什么会有指令重排2、如何禁止指令重排3、原理之volatile4、happens-before 5.1 Java的内存模型 JMM 即 Java Memory Model&#xff08;Java内存模型&#xff09;…

如何学习Java“高并发”,并在项目中实际应用?

前几天收到一位粉丝私信&#xff0c;说的是他才一年半经验&#xff0c;去面试却被各种问到分布式&#xff0c;高并发&#xff0c;多线程之间的问题。基础层面上的是可以答上来&#xff0c;但是面试官深问的话就不会了&#xff01;被问得都怀疑现在Java招聘初级岗位到底招的是初…

DMHS同步原理介绍以及DM8同步到DM8

一、DMHS原理介绍 1.DMHS介绍 达梦数据实时同步软件 DMHS 是达梦公司推出的新一代支持异构环境的高性能、高可靠和高可扩展的数据库实时同步系统。该产品基于成熟的关系数据模型和标准接口&#xff0c;跨越多种软硬件平台实现秒级数据实时同步。该产品可广泛应用于应急系统、…

什么是产品经理 | 文末赠书

目录 一. 产品经理是什么&#xff1f;二. 产品经理需要具备的技能三. 产品经理的职责四. 产品经理在软件开发过程中如何平衡不同利益方的需求&#xff1f;五. 入门建议六. 发展前景七. 总结&#x1f981;文末福利图书介绍作者简介 一. 产品经理是什么&#xff1f; 产品经理是指…

使用阿里巴巴开源神器Arthas进行性能分析

目录 前言&#xff1a; Arthas介绍 启动 分析命令 Profiler工具 前言&#xff1a; Arthas是一款由阿里巴巴开源的Java诊断工具&#xff0c;它可以在生产环境中帮助开发人员快速地定位问题&#xff0c;并进行高效的性能分析。通过在命令行中输入简单的命令&#xff0c;开发人员…

Win10开机后自动显示右键菜单怎么办?

Win10开机后自动显示右键菜单怎么办&#xff1f;用户打开Win10电脑后发现电脑自动显示右键菜单&#xff0c;如果是使用联想电脑的用户&#xff0c;需要打开联想管家&#xff0c;关掉联想锁屏即可&#xff0c;若是系统不兼容导致的&#xff0c;这时候用户就需要恢复Win10系统来解…

前端性能优化:高在性能,大在范围,必要前置知识一网打尽!(上)

前言 前端性能优化 又是个听起来很高大上的词&#xff0c;确实是的&#xff0c;因为它需要 高在性能&#xff0c;大在范围 &#xff0c;所幸很多大佬都已经输出了很多高质量的内容供大家参考&#xff0c;作者最近也在学习和了解这方面的内容&#xff0c;对如下文中的一些理解若…

死磕测试 10 余年,呕心整理出了核心知识点已经做成PDF,无私奉献

前言&#xff1a; 想在面试、工作中脱颖而出&#xff1f;想在最短的时间内快速掌握 软件测试 的核心基础知识点&#xff1f;想要成为一位优秀的测试工程师&#xff1f;本篇文章能助你一臂之力&#xff01; 目前正值招聘求职旺季&#xff0c;很多同学对一些新技术名词都能侃侃…

智能文本生成:进展与挑战

智能文本生成&#xff1a;进展与挑战 万小军 北京大学王选计算机研究所 摘要&#xff1a;智能文本生成是人工智能与自然语言处理领域的前沿研究方向&#xff0c;也是AI生成内容&#xff08;AIGC&#xff09;的关键技术支撑&#xff0c;近些年受到学术界和产业界的高度关注&…

[笔记]pg常用命令

数据库版本 &#xff1a;9.6.6 注意 &#xff1a;PostgreSQL中的不同类型的权限有SELECT,INSERT,UPDATE,DELETE,TRUNCATE,REFERENCES,TRIGGER,CREATE,CONNECT,TEMPORARY,EXECUTE 和 USAGE。 1. 登录PG数据库 以管理员身份 postgres 登陆&#xff0c;然后通过 #psql -U postg…

【TA100 】3.3 曲面细分与几何着色器---大规模草渲染

一、两者的应用列举 1-1.曲面细分着色器的应用 ①海浪、雪地等 2著名的应用&#xff1a;和置换贴图&#xff08;DIsplacement mapping&#xff0c;也叫位移贴图&#xff09;结合使用 ● 使用普通法线的模型&#xff0c;在边缘部分的凹凸感会不理想 ● 如果使用置换贴图&#…

HarmonyOS学习路之开发篇—Java UI框架(自定义组件与布局 二)

自定义布局 当Java UI框架提供的布局无法满足需求时&#xff0c;可以创建自定义布局&#xff0c;根据需求自定义布局规则 常用接口 Component类相关接口 接口名称 作用 setEstimateSizeListener 设置测量组件的侦听器 setEstimatedSize 设置测量的宽度和高度 onEstima…

极速了解GPT生态

第一部分&#xff1a; 1、chatGPT:一个大语言模型&#xff0c;可以通过API去访问&#xff0c;下面很多是根据API去访问&#xff0c;然后来进行集成。 2、Vector store&#xff0c;你也可以叫是Vector search&#xff0c;主要目就是存储各种向量&#xff0c;然后去计算向量的各…

【Linux】基础IO——文件描述符:缓冲区的理解

上个月学校考试&#xff0c;进行课程复习&#xff0c;一直没有更新博客&#xff0c;现考试结束&#xff0c;继续保持更新&#xff0c;欢迎大家关注&#xff01; 目录 1 模仿C库自主封装简单的文件接口2 对缓冲区的理解2.1 数据刷新到磁盘的过程分析2.2 如何强制刷新内核 1 模仿…

00后是真的卷不过,工作没两年,跳槽到我们公司起薪17K都快接近我了

在程序员职场上&#xff0c;什么样的人最让人反感呢? 是技术不好的人吗?并不是。技术不好的同事&#xff0c;我们可以帮他。 是技术太强的人吗?也不是。技术很强的同事&#xff0c;可遇不可求&#xff0c;向他学习还来不及呢。 真正让人反感的&#xff0c;是技术平平&…

go+vue自建运维管理平台

文章目录 鲁班运维平台容器管理集群管理namespace管理节点管理工作负载存储管理网络管理配置管理事件中心 kuboard 鲁班运维平台 这个平台和spug很像&#xff0c;感觉就像是spug运维平台的容器版本。 但是如果是容器平台则选择的余地很大&#xff0c;优秀的如kubersphere、kub…