/cli

A command line client for interacting a secure mailbox

Primary LanguagePythonApache License 2.0Apache-2.0

cli

A command line client for interacting a secure mailbox

Build Status

codecov

Requirements

Note: Additional required packages can be found in pyproject.toml.

Getting Started

Installation

Recommended installation of python and associated packages:

Installing python can be easily done with pyenv (unless you're on windows)

# To download and install
pyenv install 3.8.1

# To use
pyenv global 3.8.1

# To check
python --version # Python 3.8.1

Project dependencies can be installed with either poetry, pipenv or pip. We recommend using poetry.

# Upgrade pip and setuptools to ensure we can build libraries against 3.8
python -m pip install --upgrade pip setuptools

# Install poetry and project dependencies
python -m pip install poetry && poetry install

Full documentation for installing and running via other supported tools can be found in the wiki

Other tools used in development:

# Install the black formatting tool
# Note: Install to global package list
# Docs: https://black.readthedocs.io/en/stable/
python -m pip install --user black
API

This application is intended to interact with the secure mailboxes API. To install and run it, please see the API repositories README.

Features

Create key

poetry run python scmailclient create-key

options:

  • name
  • email
  • key_type
  • key_length
  • expire_date

Register

poetry run python scmailclient register

options:

  • fingerprint(-f): user's fingerprint

Retrieve

poetry run python scmailclient retrieve

options:

  • fingerprint(-f): user's fingerprint.
  • sender_fingerprint(-s): optional, sender's fingerprint.
  • password(-p): optional, the password of private key.

Send

poetry run python scmailclient send

options:

  • sender_fingerprint(-s): the fingerprint of sender.
  • recipient(-r): the fingerprint of recipient.
  • message(-m): the message should be sent.

List key

poetry run python scmailclient list-keys

options:

  • private(-p): whether the output are private keys.

Export key

poetry run python scmailclient export-key

options:

  • fingerprint(--fingerprint): the fingerprint of exported key.
  • is_file(--is-file): export key to a file.
  • is_pvt(--is-pvt): whether export private key.

Import key

poetry run python scmailclient import-key

options:

  • file_path(-p): the path of import key file.
  • fingerprint(-f): the fingerprint of import key.

Help

Help about all commands.

poetry run python scmailclient --help

# or all options about one command.
poetry run python scmailclient [command] --help

Testing

Install pytest for our premade tests. If you installed everything in the pipfile pytest should already be installed.

poetry add pytest --dev
Basic testing
poetry run pytest

This will run tests with filenames that start with 'test_'.

Testing with Coverage
# Only collect coverage info for our app and generate branch coverage
poetry run coverage run -m pytest

poetry run coverage report

# Show lines missing coverage
poetry run coverage report -m

Formatting

This repository uses black to format its files. You can read more about it here

To run black on the project:

# To check which files would be updated
black --check .

# To run black on the whole repo
black .