fix: copy field_map/profile_data_path in get_providers; improve caplog assertions

This commit is contained in:
2026-05-09 08:34:48 -04:00
parent a7bb183222
commit f24500a6b5
2 changed files with 7 additions and 10 deletions
+2 -2
View File
@@ -149,8 +149,8 @@ def get_providers(config: dict) -> list[ResolvedProvider]:
scope=defn["scope"],
client_id=client_id,
client_secret=client_secret,
field_map=defn["field_map"],
profile_data_path=defn["profile_data_path"],
field_map=dict(defn["field_map"]),
profile_data_path=list(defn["profile_data_path"]),
))
return result
+5 -8
View File
@@ -1,3 +1,4 @@
import logging
import time as time_mod
from unittest.mock import AsyncMock, MagicMock, patch
from urllib.parse import urlparse, parse_qs
@@ -425,38 +426,34 @@ def test_get_providers_nextcloud_urls_and_path():
def test_get_providers_skips_missing_client_id(caplog):
cfg = {"oauth": {"gitea": {"url": "https://git.example.com", "client_secret": "cs"}}}
import logging
with caplog.at_level(logging.WARNING, logger="hbd.server.oauth"):
result = oauth.get_providers(cfg)
assert result == []
assert caplog.text # a warning was logged
assert "missing" in caplog.text.lower()
def test_get_providers_skips_missing_client_secret(caplog):
cfg = {"oauth": {"gitea": {"url": "https://git.example.com", "client_id": "cid"}}}
import logging
with caplog.at_level(logging.WARNING, logger="hbd.server.oauth"):
result = oauth.get_providers(cfg)
assert result == []
assert caplog.text # a warning was logged
assert "missing" in caplog.text.lower()
def test_get_providers_skips_missing_url_for_gitea(caplog):
cfg = {"oauth": {"gitea": {"type": "gitea", "client_id": "cid", "client_secret": "cs"}}}
import logging
with caplog.at_level(logging.WARNING, logger="hbd.server.oauth"):
result = oauth.get_providers(cfg)
assert result == []
assert caplog.text # a warning was logged
assert "url" in caplog.text.lower()
def test_get_providers_skips_missing_url_for_nextcloud(caplog):
cfg = {"oauth": {"nc": {"type": "nextcloud", "client_id": "cid", "client_secret": "cs"}}}
import logging
with caplog.at_level(logging.WARNING, logger="hbd.server.oauth"):
result = oauth.get_providers(cfg)
assert result == []
assert caplog.text # a warning was logged
assert "url" in caplog.text.lower()
def test_get_providers_github_no_url_required():