接口测试 Postman 使用小技巧

乖乖胡 · 2016年08月19日 · 最后由 丹丹 回复于 2016年12月08日 · 1763 次阅读

Postman 使用小技巧

参数值加密

使用 postman 进行接口测试时,会经常碰到参数值加密的情况,比如使用签名 sign MD5 加密,以下为 postman 进行加密的方法:

参照官方文档:

https://www.getpostman.com/docs/sandbox

我们可以通过 CryptoJS 进行加密,打开 postman 接口请求界面
postman

在 Pre-request Script 中输入以下脚本:

var str = environment.variable_1 + environment.variable_2;
var hash = CryptoJS.MD5(str).toString();
postman.setEnvironmentVariable('hash', hash);

然后在请求的 url Params 里 sign keyvalue 中输入{{hash}},就可以将加密值添加到 sign 里,其他加密方式可参考官方文档和模板来实现。

共收到 3 条回复 时间 点赞

非常好,不知道 postman 的这个脚本功能支持的怎么样,是否支持请求体中的数据加密?是否支持 google protocol buffer 协议数据?

#1 楼 @defias 这个是我在工作中碰到的一个问题的解决方案,至于是否支持其他,还得请用过的人来分享一下了。

问个问题:已经在浏览器开启了 interceptor,postman 中的卫星也打开了,但是在 postman 的 history 中没有自动捕获 chrome 的操作记录。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册