如何在 SoapUI 中测试使用 JWT 的 REST 服务? [英] How to test a REST service that uses JWT in SoapUI?
问题描述
我正在实施一些 REST 服务.我所有的测试都是使用 SoapUI 进行的.最近我决定采用 JSON Web Token (JWT) 进行身份验证,但在 SoapUI 上找不到对此的任何支持(本机安装或插件,什么都没有).
我发现了一些在线生成器,例如 http://jwtbuilder.jamiekurtz.com/ 但填写所有字段,对每个测试用例一次又一次地在 SoapUI 上复制/粘贴根本没有效率.
我想知道是否有办法在 SoapUI 中测试 JWT 内容,或者我是否需要其他工具.有什么建议吗?
谢谢!
我找到了一种半自动的方法,可以使用包含令牌的外部文件在 TestCases 之间保留有效的 JWT 令牌,而不会浪费太多时间.
p>
- 使用外部工具将有效的 JWT 令牌生成到文件中.
在 SoapUI 中打开您的项目并添加一个
jwt
变量,其值为<代码>${=new File('/path/to/token_file.txt').text}代码>在您的请求中,将您的变量引用为具有值的 JWT 标头<代码>${#Project#jwt}代码>
当令牌过期时,只需重新启动生成器脚本,SoapUI 会自动加载新令牌.
I'm implementing some REST services. All my tests are made using SoapUI. Recently I decided to adopt JSON Web Token (JWT) for authentication but I could not find any support for this on SoapUI (native install or plugins, nothing).
I found some online generators like http://jwtbuilder.jamiekurtz.com/ but fill all fields, copy/paste on SoapUI again and again for every testcase is not productive at all.
I'm wondering if there is a way to test JWT stuff in SoapUI or if maybe I need another tool. Any advice?
Thanks!
I've found a semi-automatic way to keep a valid JWT token across TestCases without losing too much time, using an external file containing the token.
- Have an external tool generating a valid JWT token into a file.
Open your project in SoapUI and add a
jwt
variable with the value${=new File('/path/to/token_file.txt').text}
In your requests, reference your variable as a JWT header with the value
${#Project#jwt}
When the token expire, just relaunch the generator script, and SoapUI will automatically load the new token.
这篇关于如何在 SoapUI 中测试使用 JWT 的 REST 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!