create your journal โ solstone".encode() in resp.data
def test_init_renders_version(self, fresh_client):
try:
from importlib.metadata import version as _v
expected = _v("solstone")
except Exception:
expected = "dev"
assert _read_init_state(fresh_client)["version"] in {expected, "dev"}
def test_init_state_carries_thinking_lanes(self, fresh_client):
state = _read_init_state(fresh_client)
assert state["lanes"] == [dict(lane) for lane in LANES]
assert state["confidential"]["lane_detail"] == dict(CONFIDENTIAL_LANE_DETAIL)
assert set(state["confidential"]["lane_detail"]) == {
"heading",
"sub",
"mechanism",
"egress",
"claims",
"attestation",
"early_access",
}
def test_init_renders_journal_path_in_welcome(self, fresh_client):
journal_path = str(Path(get_journal()))
resp = fresh_client.get("/init")
assert _read_init_state(fresh_client)["journal_path"] == journal_path
assert b"solstone is three things working together" not in resp.data
assert b"solstone is two things working together" not in resp.data
assert b"your journal lives on this computer." in resp.data
assert (
b"sol experiences your day with you and keeps it all here, in your journal"
in resp.data
)
def test_init_sol_agent_section_renders(self, fresh_client):
resp = fresh_client.get("/init")
assert b">how should sol think?<" in resp.data
assert b'id="provider-lanes"' in resp.data
assert b'id="provider-skip"' in resp.data
def test_init_sol_agent_paragraphs(self, fresh_client):
resp = fresh_client.get("/init")
assert (
b"sol reasons about your journal and answers you. it thinks the way "
b"you choose here \xe2\x80\x94 and you can change it anytime in "
b"thinking."
) in resp.data
assert (
b"when you finish, thinking opens to the lane you picked. "
b"the fork lives in thinking from here on \xe2\x80\x94 switch anytime."
) in resp.data
def test_init_no_legacy_trust_note(self, fresh_client):
resp = fresh_client.get("/init")
assert b"your key is stored locally" not in resp.data
def test_init_lane_cards_are_dynamic(self, fresh_client):
resp = fresh_client.get("/init")
assert b'id="provider-lane-local"' not in resp.data
assert b'id="provider-lane-confidential"' not in resp.data
assert b'id="provider-lane-byo"' not in resp.data
assert b"LANE_GLYPHS" in resp.data
def test_machine_card_present_and_verbatim(self, fresh_client):
resp = fresh_client.get("/init")
assert b"your journal lives on this computer." in resp.data
assert (
b"sol experiences your day with you and keeps it all here, "
b"in your journal. nothing else is required to start."
) in resp.data
assert b"sol pbc offers a few optional services" not in resp.data
assert (
b"turn them on if they help. turn them off whenever you want. or never."
not in resp.data
)
assert (
b"observers \xe2\x80\x94 experience your day along with you"
not in resp.data
)
assert b"where memories are stored and curated by sol" not in resp.data
def test_machine_card_section_id(self, fresh_client):
resp = fresh_client.get("/init")
assert b'id="section-machine-card"' in resp.data
assert b'id="section-trinity"' not in resp.data
def test_identity_hint_refresh(self, fresh_client):
resp = fresh_client.get("/init")
assert (
b"optional \xe2\x80\x94 just helps sol know what to call you." in resp.data
)
assert (
b"optional \xe2\x80\x94 helps sol address you correctly." not in resp.data
)
def test_footer_note_refresh(self, fresh_client):
resp = fresh_client.get("/init")
assert (
b"your journal stays on this computer "
b"\xe2\x80\x94 nothing leaves unless you send it."
) in resp.data
assert b"your data stays on your machine" not in resp.data
def test_portal_unreachable_stub_inert_on_default_path(self, fresh_client):
resp = fresh_client.get("/init")
assert b"portal-unreachable" not in resp.data
assert b"can't reach sol pbc right now." not in resp.data
assert b"L11-stub: portal-unreachable" not in resp.data
def test_init_retention_radios_present(self, fresh_client):
resp = fresh_client.get("/init")
assert resp.data.count(b'")
assert form_start < button < form_end
def test_init_redirects_when_configured(self, configured_client):
resp = configured_client.get("/init")
assert resp.status_code == 302
assert resp.headers["Location"] == "/"
def test_init_empty_journal_materializes_config(self, tmp_path, monkeypatch):
client, journal = _make_empty_client(tmp_path, monkeypatch)
resp = client.get("/init")
assert resp.status_code == 200
config = _read_config(journal)
assert config["identity"]["name"] == "OS User"
assert config["identity"]["preferred"] == "osuser"
assert config["identity"]["timezone"] == "America/Denver"
assert "convey" not in config
state = _read_init_state(client)
assert state["identity_name"] == "OS User"
assert state["identity_preferred"] == "osuser"
def test_init_escapes_identity_values(self, journal_copy):
config = _read_config(journal_copy)
config.pop("setup", None)
config["identity"]["name"] = ""
seed_journal_config(config, journal_copy)
app = create_app(str(journal_copy))
app.config["TESTING"] = True
resp = app.test_client().get("/init")
assert b"" not in resp.data
state = app.test_client().get("/init/api/state").get_json()
assert state["identity_name"] == ""
def test_init_does_not_overwrite_existing_identity(self, journal_copy):
config = _read_config(journal_copy)
config.pop("setup", None)
config["identity"]["name"] = "Existing User"
config["identity"]["preferred"] = "Existing"
config["identity"]["timezone"] = "UTC"
seed_journal_config(config, journal_copy)
before = _read_config(journal_copy)
app = create_app(str(journal_copy))
app.config["TESTING"] = True
resp = app.test_client().get("/init")
after = _read_config(journal_copy)
assert resp.status_code == 200
assert after == before
def test_init_get_does_not_overwrite_corrupt_config(self, journal_copy):
app = create_app(str(journal_copy))
app.config["TESTING"] = True
client = app.test_client()
config_path = journal_copy / "config" / "journal.json"
config_path.write_bytes(b"{ invalid json }")
before = config_path.read_bytes()
resp = client.get("/init")
assert resp.status_code == 500
assert resp.get_json()["reason_code"] == "corrupt_config"
assert config_path.read_bytes() == before
class TestInitMark:
def test_mark_section_scaffold(self, fresh_client):
resp = fresh_client.get("/init")
assert resp.status_code == 200
assert b'id="section-journal-mark"' in resp.data
assert b"this is your journal" in resp.data
assert b'id="journal-mark-display"' in resp.data
def test_mark_routes_referenced(self, fresh_client):
resp = fresh_client.get("/init")
assert b"/init/mark/regenerate" in resp.data
assert b"/init/mark/lock" in resp.data
assert b"/init/mark" in resp.data
def test_mark_svg_wrapper_present(self, fresh_client):
resp = fresh_client.get("/init")
assert b'viewBox="0 0 24 24"' in resp.data
assert b'stroke-width="2"' in resp.data
def test_mark_error_branches_present(self, fresh_client):
resp = fresh_client.get("/init")
assert b'id="journal-mark-error"' in resp.data
assert b'id="journal-mark-retry"' in resp.data
assert resp.data.count(b"showMarkError(") >= 4
def test_mark_copy_verbatim(self, fresh_client):
resp = fresh_client.get("/init")
for text in (
"this is your journal",
"every journal has its own mark โ two symbols and two words, unique to yours. you'll recognize it whenever you connect a device.",
"try another",
"lock it in",
"lock it in and this mark is your journal's, for good โ it can't be changed later. try as many as you like first.",
"locked in ยท this is your journal's mark, for good.",
):
assert text.encode() in resp.data
def test_no_jid_token(self, fresh_client):
resp = fresh_client.get("/init")
assert re.search(r"\bjid\b", resp.data.decode()) is None
def test_finalize_blocked_when_unlocked(self, fresh_client):
resp = fresh_client.post(
"/init/finalize",
json={"name": "X"},
content_type="application/json",
)
assert resp.status_code == 400
assert resp.get_json()["reason_code"] == "identity_not_locked"
def test_finalize_catch_routes_server_error(self, fresh_client):
resp = fresh_client.get("/init")
assert b"data.warnings" in resp.data
assert b"err.serverMessage" in resp.data
assert b"showFinalizeError" in resp.data
def test_mark_locked_on_commit(self, fresh_client):
_commit_journal_identity()
resp = fresh_client.get("/init/mark")
assert resp.get_json()["locked"] is True
def test_regenerate_blocked_when_locked(self, fresh_client):
_commit_journal_identity()
resp = fresh_client.post("/init/mark/regenerate")
assert resp.status_code == 400
assert resp.get_json()["reason_code"] == "invalid_operation_for_state"
def test_linked_assets_load(self, fresh_client):
resp = fresh_client.get("/init")
assert resp.status_code == 200
text = resp.data.decode()
urls = re.findall(r'