量角器需要密码才能登录=>不安全? [英] Protractor needs password for login => insecure?
问题描述
我开始使用Protractor进行e2e测试.
I'm starting out with e2e testing with Protractor.
要测试某些页面,我首先需要登录.现在,我有这部分用于输入密码:
To test some pages I first need to login. Now I have this part for entering the password:
var passInput = element(by.id('Passwd'));
passInput.sendKeys('test');
现在,当我用实际的密码替换测试"时,不小心将更改提交到git时,密码就暴露了.
Now when I replace the 'test' with my actual password, and I accidentally commit my changes to git, my password is exposed.
我无法使用虚拟帐户,因为我们使用的是Google Auth.它必须是实际帐户.
I can't work with a dummy account because we use Google Auth. It needs to be an actual account.
这是量角器的预定方式吗?有解决方法吗?
Is this the intended way to go in Protractor? Is there a work-around?
推荐答案
要在 @ Sudharsan-Selvarj 上继续回答. 您应该创建2个文件:
To continue on @Sudharsan-Selvarj's answer. You should create 2 files:
environment.json
和environment.dist.json
.现在,首先,将environment.json
添加到您的.gitignore
.
environment.json
and environment.dist.json
. Now first of all, add environment.json
to your .gitignore
.
environment.json
{
"password": "correcthorsebatterystaple",
"username": "stijnisdebeste",
"server": "https://stijn.development.server"
}
environment.dist.json
{
"password": "-- ADD PASSWORD HERE --",
"username": "-- ADD USERNAME HERE --",
"server": "-- ADD SERVER HERE --"
}
现在在量角器中,您可以使用永远不会被推送到GIT服务器的环境变量.现在,每个开发人员都必须使用自己的凭据等.
Now in your protractor you can use the environment-variables that will never be pushed to the GIT-server. Every developer now has to use his own credentials etc.
如果您找到更好的解决方案,请告诉我:)
If you find a better solution, please let me know :)
修改:
确定要进行e2e测试吗?还是可以简单地使用集成测试?因为我们放弃了e2e测试,转而使用集成测试;并作为此Google博客文章指出:
Are you certain that you need e2e-tests? Or could you simply use integration tests? Because we've abandoned e2e-tests in favour of integration-tests; And as this google blogpost states:
- 编写许多很多单元测试.这些可以模拟出对要测试的单元的所有依赖关系.
- 编写许多集成测试.集成测试实际上使用所有类,但模拟后端.由于DOM应该只使用控制器的getter/setter,因此它应该易于测试,甚至无需考虑在测试中读取DOM.
- 编写一些e2e测试. e2e是昂贵的测试,它们需要很长时间才能运行,而且更难控制.我看到的真正e2e的唯一原因是检查不同HTML-5实现的浏览器兼容性.
这篇关于量角器需要密码才能登录=>不安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!