diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d396961..fc64036 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,10 +23,6 @@ repos: hooks: - id: pyupgrade args: [--py37-plus] -- repo: https://github.com/asottile/setup-cfg-fmt - rev: ce506f9063be3e882d391cdf7b6a3d5f8359add8 # frozen: v1.20.1 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/jackdewinter/pymarkdown rev: be56696256d5491e8a907b72e5a3852034546adb # frozen: v0.9.5 hooks: diff --git a/.woodpecker.yml b/.woodpecker.yml index efd8e6e..9344b5e 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -3,7 +3,7 @@ pipeline: group: test image: python:3.7-alpine commands: - - pip install pipenv==2022.9.4 + - pip install pipenv==2022.10.25 - pipenv install --dev --deploy - pipenv run almake test-pytest # We only test with pytest on 3.7 @@ -22,7 +22,7 @@ pipeline: group: test image: python:3.9-alpine commands: - - pip install pipenv==2022.9.4 pre-commit==2.22.0 + - pip install pipenv==2022.10.25 pre-commit==2.22.0 - pre-commit run --all-files - pipenv install --dev --deploy - pipenv run almake test @@ -33,7 +33,7 @@ pipeline: group: test image: python:3.10-alpine commands: - - pip install pipenv==2022.9.4 pre-commit==2.22.0 + - pip install pipenv==2022.10.25 pre-commit==2.22.0 - pre-commit run --all-files - pipenv install --dev --deploy - pipenv run almake test diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eab1fd..8b908d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.2.0 - 2022-11-01] + +### Changed + +- Use new format for new tokens. + ## [7.1.2 - 2022-11-01] ### Changed diff --git a/src/sporestack/__init__.py b/src/sporestack/__init__.py index eab2838..1b09812 100644 --- a/src/sporestack/__init__.py +++ b/src/sporestack/__init__.py @@ -1,5 +1,5 @@ -"""SporeStack API and CLI for launching servers with Bitcoin or Monero""" +"""SporeStack API and CLI for launching servers with Monero or Bitcoin""" __all__ = ["api", "api_client", "exceptions"] -__version__ = "7.1.2" +__version__ = "7.2.0" diff --git a/src/sporestack/utils.py b/src/sporestack/utils.py index 9ababd8..7ef7c8b 100644 --- a/src/sporestack/utils.py +++ b/src/sporestack/utils.py @@ -14,7 +14,7 @@ def checksum(to_hash: str) -> str: def random_machine_id() -> str: """ - These used to be 64 hex characters. Now they have a new format. + Machine IDs have a 32 character format with a checksum. """ to_hash = f"ss_m_{secrets.token_hex(11)}" return f"{to_hash}_{checksum(to_hash)}" @@ -22,6 +22,7 @@ def random_machine_id() -> str: def random_token() -> str: """ - 64 hex characters. + Tokens have a 32 character format with a checksum. """ - return secrets.token_hex(32) + to_hash = f"ss_t_{secrets.token_hex(11)}" + return f"{to_hash}_{checksum(to_hash)}" diff --git a/tests/test_utils.py b/tests/test_utils.py index 32f501b..9a6403a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,5 +7,11 @@ def test_random_machine_id() -> None: assert utils.random_machine_id().startswith("ss_m_") +def test_random_token() -> None: + assert utils.random_token() != utils.random_token() + assert len(utils.random_token()) == 32 + assert utils.random_token().startswith("ss_t_") + + def test_hash() -> None: assert utils.checksum("ss_m_1deadbeefcafedeadbeef1") == "0892"