openentity 0.5.2__tar.gz → 0.5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openentity-0.5.2 → openentity-0.5.3}/PKG-INFO +1 -1
- {openentity-0.5.2 → openentity-0.5.3}/openentity/__init__.py +1 -1
- {openentity-0.5.2 → openentity-0.5.3}/openentity/identity.py +14 -2
- {openentity-0.5.2 → openentity-0.5.3}/pyproject.toml +1 -1
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_core.py +2 -2
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_identity.py +12 -0
- {openentity-0.5.2 → openentity-0.5.3}/uv.lock +1 -1
- {openentity-0.5.2 → openentity-0.5.3}/.gitignore +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/README.md +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/cli.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/client.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/core.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/httpsig.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/issuer.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/report.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/schema.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/openentity/schemas/openentity-1.0.json +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_cli.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_client.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_httpsig.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_issuer.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_parity.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_trust.py +0 -0
- {openentity-0.5.2 → openentity-0.5.3}/tests/test_verifier.py +0 -0
|
@@ -37,8 +37,13 @@ def _keychain_set(seed_hex: str) -> bool:
|
|
|
37
37
|
return False
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
def home() -> pathlib.Path:
|
|
41
|
+
"""OPENENTITY_HOME, else ~/.openentity: where the key file and integrations' state live."""
|
|
42
|
+
return pathlib.Path(os.environ.get("OPENENTITY_HOME", "~/.openentity")).expanduser()
|
|
43
|
+
|
|
44
|
+
|
|
40
45
|
def _file() -> pathlib.Path:
|
|
41
|
-
return
|
|
46
|
+
return home() / "identity.key"
|
|
42
47
|
|
|
43
48
|
|
|
44
49
|
class Identity:
|
|
@@ -54,10 +59,17 @@ class Identity:
|
|
|
54
59
|
return self.kp.seed
|
|
55
60
|
|
|
56
61
|
@classmethod
|
|
57
|
-
def
|
|
62
|
+
def load(cls) -> "Identity | None":
|
|
63
|
+
"""The existing identity, or None. Never creates one."""
|
|
58
64
|
for source, read in (("keychain", _keychain_get), ("file", lambda: _file().read_text().strip() if _file().exists() else None)):
|
|
59
65
|
if h := read():
|
|
60
66
|
return cls(bytes.fromhex(h), source)
|
|
67
|
+
return None
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def load_or_create(cls) -> "Identity":
|
|
71
|
+
if found := cls.load():
|
|
72
|
+
return found
|
|
61
73
|
seed = os.urandom(32)
|
|
62
74
|
if _keychain_set(seed.hex()):
|
|
63
75
|
return cls(seed, "keychain")
|
|
@@ -7,7 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
9
|
|
|
10
|
-
from openentity import cli, core
|
|
10
|
+
from openentity import __version__, cli, core
|
|
11
11
|
|
|
12
12
|
ROOT = Path(__file__).resolve().parents[3]
|
|
13
13
|
VECTORS = ROOT / "test-vectors"
|
|
@@ -198,7 +198,7 @@ def test_adopt_and_cli(tmp_path, monkeypatch, capsys):
|
|
|
198
198
|
def test_cli_version(capsys):
|
|
199
199
|
with pytest.raises(SystemExit) as e:
|
|
200
200
|
cli.main(["--version"])
|
|
201
|
-
assert e.value.code == 0 and
|
|
201
|
+
assert e.value.code == 0 and __version__ in capsys.readouterr().out
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
# ---- shared vectors, checked with the independent verifier's own logic ----
|
|
@@ -45,3 +45,15 @@ def test_keychain_failure_falls_back_to_file(monkeypatch):
|
|
|
45
45
|
monkeypatch.delenv("OPENENTITY_KEYCHAIN")
|
|
46
46
|
monkeypatch.setattr(identity, "_run", lambda argv, stdin=None: None) # no `security`, no `secret-tool`
|
|
47
47
|
assert Identity.load_or_create().source == "file"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_load_never_creates_a_key(home):
|
|
51
|
+
"""Read-only callers (a trust gate) must not mint an identity as a side effect."""
|
|
52
|
+
assert Identity.load() is None
|
|
53
|
+
assert not (home / "identity.key").exists()
|
|
54
|
+
a = Identity.load_or_create()
|
|
55
|
+
assert Identity.load().did == a.did
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_home_follows_openentity_home(home):
|
|
59
|
+
assert identity.home() == home
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|