mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-07-08 07:41:53 +08:00
Fix registration OTP anchor and batch task state
This commit is contained in:
@@ -70,3 +70,37 @@ def test_update_account_preserves_pending_status_when_other_tokens_remain(tmp_pa
|
||||
assert updated.refresh_token == ""
|
||||
assert updated.token_sync_status == "pending"
|
||||
assert updated.token_sync_updated_at is not None
|
||||
|
||||
|
||||
def test_update_outlook_refresh_token_persists_nested_config_changes(tmp_path):
|
||||
manager = DatabaseSessionManager(f"sqlite:///{tmp_path}/test.db")
|
||||
manager.create_tables()
|
||||
manager.migrate_tables()
|
||||
|
||||
with manager.session_scope() as session:
|
||||
service = crud.create_email_service(
|
||||
session,
|
||||
service_type="outlook",
|
||||
name="outlook-service",
|
||||
config={
|
||||
"accounts": [
|
||||
{"email": "first@example.com", "refresh_token": "old-first"},
|
||||
{"email": "second@example.com", "refresh_token": "old-second"},
|
||||
]
|
||||
},
|
||||
)
|
||||
service_id = service.id
|
||||
|
||||
crud.update_outlook_refresh_token(
|
||||
session,
|
||||
service_id=service_id,
|
||||
email="second@example.com",
|
||||
new_refresh_token="new-second",
|
||||
)
|
||||
|
||||
with manager.session_scope() as session:
|
||||
reloaded = crud.get_email_service_by_id(session, service_id)
|
||||
|
||||
assert reloaded is not None
|
||||
assert reloaded.config["accounts"][0]["refresh_token"] == "old-first"
|
||||
assert reloaded.config["accounts"][1]["refresh_token"] == "new-second"
|
||||
|
||||
Reference in New Issue
Block a user