node and account names
This commit is contained in:
@@ -48,6 +48,36 @@ def test_register_rejects_duplicate_identifiers():
|
||||
store.register(email="DUP@example.com", password="other-secret")
|
||||
|
||||
|
||||
def test_register_and_update_nickname():
|
||||
store = AccountStore()
|
||||
account = store.register(
|
||||
email="nick@example.com",
|
||||
password="secret-123",
|
||||
nickname=" Alpha ",
|
||||
)
|
||||
assert account["nickname"] == "Alpha"
|
||||
updated = store.update_profile(account["account_id"], nickname="Beta")
|
||||
assert updated["nickname"] == "Beta"
|
||||
cleared = store.update_profile(account["account_id"], nickname=None)
|
||||
assert cleared["nickname"] is None
|
||||
|
||||
|
||||
def test_nickname_replicates_across_stores():
|
||||
leader = AccountStore()
|
||||
follower = AccountStore()
|
||||
account = leader.register(
|
||||
email="nick@example.com",
|
||||
password="secret-123",
|
||||
nickname="HiveNick",
|
||||
)
|
||||
leader.update_profile(account["account_id"], nickname="Renamed")
|
||||
events, _ = leader.events_since(0)
|
||||
follower.apply_events(events)
|
||||
view = follower.get_account(account["account_id"])
|
||||
assert view is not None
|
||||
assert view["nickname"] == "Renamed"
|
||||
|
||||
|
||||
def test_login_by_email_or_wallet():
|
||||
store = AccountStore()
|
||||
account = store.register(
|
||||
@@ -168,6 +198,27 @@ def test_register_login_and_account_view(account_tracker):
|
||||
assert me["usage"]["requests"] == 0
|
||||
|
||||
|
||||
def test_account_nickname_register_and_profile_update(account_tracker):
|
||||
url, _ = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST", {
|
||||
"email": "nick@example.com",
|
||||
"password": "secret-123",
|
||||
"nickname": "Operator",
|
||||
})
|
||||
assert reg["account"]["nickname"] == "Operator"
|
||||
|
||||
updated = _call(
|
||||
f"{url}/v1/account/profile",
|
||||
"POST",
|
||||
{"nickname": "Renamed"},
|
||||
token=reg["session_token"],
|
||||
)
|
||||
assert updated["account"]["nickname"] == "Renamed"
|
||||
|
||||
me = _call(f"{url}/v1/account", token=reg["session_token"])
|
||||
assert me["account"]["nickname"] == "Renamed"
|
||||
|
||||
|
||||
def test_login_sets_cookie_and_cookie_auth_survives_tracker_restart(tmp_path):
|
||||
accounts_db = str(tmp_path / "accounts.db")
|
||||
tracker = TrackerServer(
|
||||
|
||||
Reference in New Issue
Block a user