Files
computer-playbook/tests/unit/python/utils/roles/applications/test_dashboard.py
T
kevinveenbirkenbachandClaude Opus 5.5 afb82f57a1 feat(web-app-dashboard): let a role name the canonical domain its card opens
The dashboard card of every app opened its primary domain, so Matrix led to the Synapse status page and Stalwart to its admin UI. A role can now declare services.dashboard.card: <key of meta/domains.yml canonical>; docker_cards builds the card URL with lookup('canonical_url', app, key), the Apps menu reuses it, and roles_with_service('dashboard') hands the same domain to the tile e2e spec. Matrix sets card: element, Stalwart card: webmail. Without card nothing changes, and the prometheus/matomo target lists are untouched. A lint requires the key to resolve in the role's own domains.canonical.

The Matrix ansible flavor also sets Synapse's web_client_location to Element through matrix_synapse_configuration_extension_yaml, as the compose flavor already does, so matrix.<domain>/ redirects there. Merge note: feature/iam-profile-rbac defines the same extension variable inside the OIDC block; the next merge must combine both into one block (agreed with that session).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-25 21:01:06 +01:00

47 lines
1.4 KiB
Python

"""Unit tests for ``utils/roles/applications/dashboard.py``."""
from __future__ import annotations
import unittest
from ansible.errors import AnsibleError
from utils.roles.applications.dashboard import card_target_key
class TestCardTargetKey(unittest.TestCase):
def test_a_binding_without_the_key_targets_the_primary_domain(self):
self.assertEqual(
"", card_target_key("web-app-foo", {"enabled": True, "shared": True})
)
def test_a_missing_binding_targets_the_primary_domain(self):
self.assertEqual("", card_target_key("web-app-foo", None))
def test_the_named_key_is_returned(self):
self.assertEqual(
"element",
card_target_key("web-app-matrix", {"card": "element"}),
)
def test_surrounding_whitespace_is_dropped(self):
self.assertEqual(
"webmail",
card_target_key("web-app-stalwart", {"card": " webmail "}),
)
def test_an_alias_canonical_key_is_not_a_card_target(self):
self.assertEqual("", card_target_key("web-svc-cdn", {"canonical": "cdn"}))
def test_an_empty_key_fails_loudly(self):
with self.assertRaisesRegex(AnsibleError, "web-app-foo"):
card_target_key("web-app-foo", {"card": " "})
def test_a_non_string_key_fails_loudly(self):
with self.assertRaises(AnsibleError):
card_target_key("web-app-foo", {"card": ["element"]})
if __name__ == "__main__":
unittest.main()