Skip to main content
PyPI version Python versions See Build Status on Travis CI

An encrypted password store for use within pytest cases


This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Features

Provide a way to include encrypted data in a test repo so project team members may share test account data (logins, password, keys) while only having to share the decryption password and store filename outside of the repository.

Requirements

SecureStore makes use of PyAesCrypt by Marco Bellaccini: “pyAesCrypt is a Python 3 file-encryption module and script that uses AES256-CBC to encrypt/decrypt files and binary streams.”

Files must be formatted as YAML data (YAML Reference) and will be loaded into a Python dictionary.

Installation

You can install “pytest-securestore” via pip from PyPI:

$ pip install pytest-securestore

Usage

Generic YAML layout:

---
# a comment
a_general_user:
    username: the_username
    password: a_password
    usertype: some_defined_type
...

Encrypt the YAML file (file encryption):

import os
import pyAesCrypt

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

Include the encrypted file in the repository.

Within a test: Note: A ``’password’`` key triggers an internal class ``Secret`` to obscure passwords stored in the yaml. Use ``.value`` to get the plain text back.

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

And to kick it off:

CLI with environment variables:

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

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-securestore” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Release files for pytest-securestore 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-securestore 0.2.0
File Size Uploaded
pytest-securestore-0.2.0.tar.gz 4.9 kB Details

Release files / pytest-securestore-0.2.0.tar.gz

Download URL pytest-securestore-0.2.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d9d6e8b2e275a0e61baa9b0a97af421ea5d6baffee88284a9877f88bda64011f
BLAKE2b-256 checksum
How to use checksums
389ef50fbd73fc48d4f852f75bbe0d7c2ac6dc93d1ca3c353a72df41b636c567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page