Skip to content

Commit

Permalink
Merge pull request #1 from tiwilliam/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
tiwilliam authored Oct 29, 2023
2 parents b28c92f + 87f3e6f commit fae5bff
Show file tree
Hide file tree
Showing 23 changed files with 471 additions and 165 deletions.
Binary file added .coverage
Binary file not shown.
11 changes: 8 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ name: docs

on:
push:
branches:
- "main"
tags:
- "*"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
Expand All @@ -18,4 +23,4 @@ jobs:
python-version-file: ".python-version"
- run: |
pip install .[dev]
mkdocs gh-deploy --force
mike deploy --push --update-aliases ${{ github.ref_name }} latest
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Create virtualenv
run: python -m venv .venv
- name: Activate virtualenv
run: source .venv/bin/activate
- name: Install dependencies
run: pip install .[dev]
- name: Build crate
run: maturin develop
- name: Run tests
run: pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
/.shadowenv.d
*.so
__pycache__/
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.4
3.12.0
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"[rust]": {
"editor.formatOnSave": true
},
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter",
},
"files.insertFinalNewline": true,
"files.exclude": {
"**/*.so": true,
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/__pycache__": true,
"target": true,
"**/.pytest_cache": true,
".coverage": true,
}
}
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsmime"
version = "0.5.0"
version = "0.6.0"
edition = "2021"

[lib]
Expand Down
17 changes: 11 additions & 6 deletions Devfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ name: rsmime
version: 1

up:
- python: 3.11.4
- python: 3.12.0
- run: pip install .[dev]
- run: pip uninstall -y rsmime

commands:
build:
description: Build the package
tasks:
- run: maturin build --release --strip

docs:
description: Build new documentation HTML to site directory
develop:
description: Develop the package
tasks:
- run: maturin develop --release --strip

test:
description: Run tests
tasks:
- run: mkdocs build
- run: maturin develop --release --strip
- run: pytest -vv

docs:serve:
docs:
description: Serve and watch documentation for development
tasks:
- run: mkdocs serve
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI](https://img.shields.io/pypi/v/rsmime?color=gr)](https://pypi.org/project/rsmime/) [![Tests](https://github.com/tiwilliam/rsmime/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/tiwilliam/rsmime/actions/workflows/tests.yml)

Rust powered Python package for signing data in S/MIME format
Python package for signing and verifying S/MIME messages

[Documentation](https://tiwilliam.github.io/rsmime/)

Expand Down
20 changes: 9 additions & 11 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pip install rsmime
## Sign an attached message

```python
import rsmime
from rsmime import Rsmime
from rsmime.exceptions import SignError, CertificateError

raw_data = b'Some data to sign'
client = Rsmime("some.crt", "some.key")

try:
signed_data = rsmime.sign('some.crt', 'some.key', raw_data)
signed_data = client.sign(b"Some data to sign")
print(signed_data.decode())
except (SignError, CertificateError) as e:
print("Failed to sign:", e)
Expand All @@ -42,13 +42,13 @@ gRUKfNnUOID3xMWl65crFoIyCA==
## Sign a detached message

```python
import rsmime
from rsmime import Rsmime
from rsmime.exceptions import SignError, CertificateError

raw_data = b'Some data to sign'
client = Rsmime("some.crt", "some.key")

try:
signed_data = rsmime.sign('some.crt', 'some.key', raw_data, detached=True)
signed_data = client.sign(b"Some data to sign", detached=True)
print(signed_data.decode())
except (SignError, CertificateError) as e:
print("Failed to sign:", e)
Expand Down Expand Up @@ -82,13 +82,11 @@ lV7oyQKEY6sVyQkWP2rPmtPs85hsmZGmej0Tx4x7
## Verify a signed message

```python
import rsmime
from rsmime import Rsmime
from rsmime.exceptions import VerifyError

signed_data = b'...'

try:
raw_again = rsmime.verify(signed_data)
raw_again = Rsmime.verify(signed_data)
print(raw_again.decode())
except VerifyError as e:
print("Failed to verify:", e)
Expand All @@ -99,4 +97,4 @@ except VerifyError as e:
```bash
$ python verify.py
Some data to sign
```
```
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

## rsmime

Rust powered Python package for signing data in S/MIME format
Python package for signing and verifying S/MIME messages

<a href="https://pypi.org/project/rsmime/">![PyPI](https://img.shields.io/pypi/v/rsmime?color=gr&style=for-the-badge)</a>

## API Reference

::: rsmime

::: rsmime.Rsmime
::: rsmime.exceptions
25 changes: 12 additions & 13 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
site_name: rsmime
repo_name: rsmime
site_url: https://tiwilliam.github.io/rsmime/
repo_url: https://github.com/tiwilliam/rsmime
theme:
name: material
custom_dir: overrides
icon:
repo: fontawesome/brands/github
logo: material/sort-variant-lock
palette:
- scheme: default
primary: deep purple
toggle:
icon: material/toggle-switch
name: Switch to dark mode
- scheme: slate
primary: deep purple
toggle:
icon: material/toggle-switch-off-outline
name: Switch to light mode
logo: material/draw-pen

watch:
- python

extra:
version:
provider: mike
default: latest

markdown_extensions:
- pymdownx.highlight
- pymdownx.inlinehilite
Expand All @@ -29,6 +26,8 @@ markdown_extensions:
plugins:
- search
- autorefs
- mike:
version_selector: true
- mkdocstrings:
handlers:
python:
Expand All @@ -43,4 +42,4 @@ plugins:
separate_signature: true
show_signature_annotations: true
merge_init_into_class: true
show_if_no_docstring: false
show_if_no_docstring: false
8 changes: 8 additions & 0 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}

{% block outdated %}
You're not viewing the latest version.
<a href="{{ '../' ~ base_url }}">
<strong>Click here to go to latest.</strong>
</a>
{% endblock %}
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build-backend = "maturin"

[project]
name = "rsmime"
version = "0.5.0"
description = "Rust powered package for signing data in S/MIME format"
version = "0.6.0"
description = "Python package for signing and verifying S/MIME messages"
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
Expand All @@ -18,11 +18,14 @@ classifiers = [

[project.optional-dependencies]
dev = [
"black==23.10.1",
"callee==0.3.1",
"maturin",
"mike==1.1.2",
"mkdocs-autorefs==0.5.0",
"mkdocs-material==9.4.7",
"mkdocstrings[python]==0.23.0",
"black==23.10.1",
"pytest==7.4.3",
]

[tool.maturin]
Expand Down
2 changes: 1 addition & 1 deletion python/rsmime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__doc__ = rsmime.__doc__
if hasattr(rsmime, "__all__"):
__all__ = rsmime.__all__
__all__ = rsmime.__all__
Loading

0 comments on commit fae5bff

Please sign in to comment.