fix(auth): preserve OAuth project sessions

This commit is contained in:
HumbleTurtle
2026-07-18 19:32:29 -03:00
parent e1a4cf93f0
commit a2958b108f
3 changed files with 198 additions and 19 deletions
+20 -1
View File
@@ -29,10 +29,13 @@ def run():
mod.oauth_loopback_authorize = lambda args: {
"api_base_url": "https://api.example.test",
"access_token": "oauth-token",
"refresh_token": "oauth-refresh-token",
"refresh_expires_at": "2099-01-01T00:00:00Z",
"expires_in": 3600,
"scope": args["scope"],
"project_id": PROJECT_ID,
}
mod.save_auth = save_auth
mod.save_auth_file_credentials = save_auth
mod.request_json = lambda method, path: {
"id": PROJECT_ID,
@@ -41,9 +44,10 @@ def run():
"encryption_state": "plaintext",
}
result = mod.operator_loopback_login({"open_browser": False})
result = mod.operator_project_attach({"open_browser": False})
assert saves[0]["token"] == "oauth-token"
assert saves[0]["refresh_token"] == "oauth-refresh-token"
assert saves[0]["project_id"] == PROJECT_ID
assert saves[0]["account_mode"] == "operator_project"
assert "napseer.projects.read" in saves[0]["oauth_scope"]
@@ -51,6 +55,21 @@ def run():
assert result["project_id"] == PROJECT_ID
assert result["project"]["name"] == "Existing Project"
saves.clear()
mod.oauth_loopback_authorize = lambda args: {
"api_base_url": "https://api.example.test",
"access_token": "account-token",
"refresh_token": "account-refresh-token",
"refresh_expires_at": "2099-01-01T00:00:00Z",
"expires_in": 3600,
"scope": args["scope"],
}
result = mod.operator_account_login({"open_browser": False})
assert saves[0]["refresh_token"] == "account-refresh-token"
assert saves[0]["account_mode"] == "operator_account"
assert "project_id" not in saves[0]
assert result["mode"] == "operator_account"
print("ok: project attach OAuth smoke passed")