我在Karate Demo中看到了有关Oauth 2的详细信息,您还能提供如何实现Basic Auth吗? https://i.stack.imgur.com/3DWyF.png
是的,这个 JS 函数就是你所需要的(basic-auth.js
):
function(creds) {
var temp = creds.username + ':' + creds.password;
var Base64 = Java.type('java.util.Base64');
var encoded = Base64.getEncoder().encodeToString(temp.getBytes());
return 'Basic ' + encoded;
}
然后使用这个函数来构建的值Authorization
header:
* header Authorization = call read('basic-auth.js') { username: 'john', password: 'secret' }
请参阅此处的文档:https://github.com/intuit/karate#http-basic-authentication-example https://github.com/intuit/karate#http-basic-authentication-example
对于 OAuth 或“登录表单”类型的流程,请参阅:https://stackoverflow.com/a/58643689/143475 https://stackoverflow.com/a/58643689/143475 and https://stackoverflow.com/a/46333729/143475 https://stackoverflow.com/a/46333729/143475
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)