dashboarddefaults: key display mappings by stable FQDN (from BIOS serial), IP fallback

A display's DHCP IP can change; its FQDN (F<serial>.<domain>, domain from the
display_fqdn_domain setting) is stable and the collector already reports the
serial. Add a nullable unique fqdn column (varchar191 so the index fits utf8mb4
without innodb_large_prefix), make ipaddress nullable, and require fqdn OR ip.
visitor-location + display-role resolve by FQDN first, then IP; create/update
accept fqdn. Core migration 7d31, verified up/down/idempotent on MySQL 5.6.
'Business unit' wording -> 'location' in the validation messages.
This commit is contained in:
cproudlock
2026-07-29 07:20:52 -04:00
parent b539e36096
commit 3ba808028c
4 changed files with 160 additions and 22 deletions

View File

@@ -129,7 +129,29 @@ def test_dashboard_role_requires_businessunit(client, db, auth_headers):
'ipaddress': '10.20.30.55', 'displayrole': 'dashboard',
}, headers=auth_headers)
assert resp.status_code == 400
assert 'businessunitid' in resp.get_json()['data']['error']['message'].lower()
assert 'location' in resp.get_json()['data']['error']['message'].lower()
def test_fqdn_mapping_create_and_resolve(client, db, auth_headers):
# A mapping can be keyed by FQDN (no IP), and /display-role resolves it.
resp = client.post('/api/dashboarddefaults', json={
'fqdn': 'FABC123.device.geaerospace.net', 'displayrole': 'lobby',
}, headers=auth_headers)
assert resp.status_code == 201, resp.data
assert resp.get_json()['data']['fqdn'] == 'fabc123.device.geaerospace.net'
# resolve by FQDN (case-insensitive)
r = client.get('/api/dashboarddefaults/display-role?fqdn=fabc123.device.geaerospace.net')
body = r.get_json()['data']
assert body['role'] == 'lobby'
assert body['path'] == '/tv'
def test_mapping_requires_fqdn_or_ip(client, db, auth_headers):
resp = client.post('/api/dashboarddefaults', json={'displayrole': 'lobby'},
headers=auth_headers)
assert resp.status_code == 400
assert 'fqdn or ipaddress' in resp.get_json()['data']['error']['message'].lower()
def test_invalid_role_rejected(client, db, auth_headers):