在空手道DSL测试中使用环境变量
我想将gitlab ci
纳入我的空手道
测试。我想通过不同的用户名和密码循环进行测试,以确保我们的API端点对不同的用户响应。
考虑到这一点,我希望能够将用户名和密码作为安全环境变量存储在gitlab
中(而不是在karate-config
作为纯文本中)并让空手道
根据空心config
或功能文件将其拉出。
浏览文档和Stackoverflow问题,我还没有看到一个示例。
在下面的彼得评论中使用新信息更新
,这就是我需要的内容,我尝试将其设置为以下内容:
在空手道config中设置客户端ID:var client_id = java.lang.system.getenv('client_id');
在实际配置对象:clientId:client_id
在我的功能文件中尝试访问它:* def client_id = clientid
它仍然以null为单位。
I'd like to incorporate GitLab CI
into my Karate
testing. I'd like to loop through my tests with different user names and passwords to ensure our API endpoints are responding correctly to different users.
With that in mind, I'd like to be able to store the usernames and passwords as secure environment variables in GitLab
(rather than in the karate-config
as plain text) and have Karate
pull them as needed from either the karate-config
or the feature files.
Looking through the docs and StackOverflow questions, I haven't seen an example where it's being done.
Updating with new information
In regards to Peter's comment below, which is what I need I am trying to set it up as follows:
set client id in karate-config:var client_id = java.lang.System.getenv('client_id');
in the actual config object:clientId: client_id
In my feature file tried to access it:* def client_id = clientId
It still comes through as null, unfortunately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用空手道读取空手道的环境
。
变量
但是,如果您的用户太多,您的配置和环境变量看起来会很麻烦。
如果您想与多个用户一起运行一些功能,建议您查看这篇文章,
”>我们可以循环功能文件,并使用空手道中的多个登录用户
编辑:
使用peter:to to to to to to to to
to to to to to to to to to to to to opop 查看哪些变量实际上是暴露的,
并查看所有环境变量的列表。
You can read environment variables in karate using karate.properties,
eg,
If this helps you to read the environment variables that you are keeping securely on your gitlab, then you can use it in your karate-config for authentication.
But your config and environment variable will look cumbersome if you are having too many users.
If you want to run a few features with multiple users, I would suggest you look into this post,
Can we loop feature files and execute using multiple login users in karate
EDIT:
Using java interop as suggested by peter:
to see which are all variables are actually exposed try,
and see the list of all environment variables.