在每个功能之前,BDD带有重新介绍的传递OAuth2代码
我目前使用BDD设置了我的框架,并放心。对于每个功能文件,我都有一个方案。最近,我们添加了OAuth2支持,我想知道实现该Auth2代码支持的最佳方法。 oauth2代币持续半小时,所以我希望getauthtoken部分首先运行,并使用该令牌来验证所有功能。
从本质上讲,我会减少检索载体令牌,并重复使用所有API测试的
任何提示。
I have my framework currently setup with BDD and rest assured. For each feature files, I have one Scenario . recently we added oauth2 support and im wondering on best approach to take on implementing that Auth2 code support. Oauth2 token last for half an hour so I would want the getAuthToken part to run first and use that token to authenticate for all the features.
Essentially I wane retrieve the bearer token and reuse that for all the api tests
Any tips appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会使用vcr( https://relishapp://relishapp.com/vcr/vcr/vcr/vcr/docs ) 为了这。基本上,您一次获得有效的令牌,并记录使用令牌从Oauth获得的积极响应。然后,您将这些录音在所有SUSB后续步骤和功能中使用。
这避免了每次运行功能时都必须去OAuth。并且应该允许您在本地运行您的功能,而根本没有网络连接,并让他们所有人工作。此功能是任何可用测试集的基本要求。
希望您可以找到相当于VCR的Java。
I would use something like VCR (https://relishapp.com/vcr/vcr/docs) for this. Basically you get a valid token once, and you record the positive response you get from Oauth using the token. Then you use that recording in all you susbsequent steps and features.
This avoids having to go to Oauth each time you run your features. And should allow you to run your features locally with no network connection at all, and for them all to work. This capability is a fundamental requirement of any usable set of tests.
Hopefully you can find a java equivalent of VCR for your project.