在pytest案例中使用的加密密码存储

pytest-securestore的Python项目详细描述


PyPI versionPython versionsSee Build Status on Travis CI

在pytest案例中使用的加密密码存储


这个pytest插件是用Cookiecutter@hackebrotcookiecutter-pytest-plugin模板生成的。

功能

提供一种在测试repo中包含加密数据的方法,以便项目团队成员可以共享测试帐户数据(登录名、密码、密钥),而只需共享解密密码并将文件名存储在存储库之外。

要求

SecureStore利用了Marco Bellacchini的Pyescarcrypt: “pyaescrypt是一个python 3文件加密模块和脚本,使用aes256-cbc对文件和二进制流进行加密/解密。”

文件必须格式化为yaml数据(YAML Reference),并将加载到python字典中。

安装

您可以通过pipPyPI

$ pip install pytest-securestore

用法

一般山药布局:

---# a commenta_general_user:username:the_usernamepassword:a_passwordusertype:some_defined_type...

加密yaml文件(file encryption):

import osimport pyAesCryptbuffer_size = 64 * 1024# 64Kfilename = os.getenv('SECURE_STORE_FILE')password = os.getenv('SECURE_STORE_PASSWORD')pyAesCrypt.encryptFile("/path/to/yaml/file", filename, password, buffer_size)

在存储库中包含加密文件。

在测试中:

def test_get_store_values(store):# one way to get the valueuser = store.get('a_general_user')username = user['username']# or anotherusername = store.get('a_general_user').get('username')# or even anotherpassword = store.get('a_general_user')['password']# oruser_type = store['a_general_user']['usertype']# ...some_site.log_in(username, password, user_type)

开始:

带有环境变量的cli:

$ pytest --secure-store-filename=$SECURE_STORE_FILE --secure-store-password=$SECURE_STORE_PASSWORD

贡献

我们非常欢迎您的贡献。测试可以用tox运行,请确保 在提交请求之前,覆盖范围至少保持不变。

许可证

“pytest securestore”是根据MIT许可证的条款发布的免费开源软件

问题

如果您遇到任何问题,请file an issue连同详细说明。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java GridBagLayout不填充区域   java Memozied Fibonacci未运行与常规Fibonacci解决方案   Java Web启动未启动问题   Java中异常和if-then的区别   java从命令提示符运行批处理文件获取错误   socket在Java中验证SSL证书的公共名称   如何在JAVA中检查字符串数组中的相等字   用java语言将音频文件转换成文本文件的语音识别   java为什么foo(1,2,3)没有传递给varargs方法foo(对象…)作为整数[]   java通过蓝牙将奇怪的数据从Arduino传输到Android   java ContainerRequestFilter获取空entitystream   java如何从安卓 studio中删除不兼容类型错误   基本Java错误   在Spring引导中使用REST API时发生java错误   javascript通过从SQL查询派生的URL打开页面