Inventory links, cutsheet marks on faceplates, and single page titles
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (flake8) (push) Successful in 54s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m1s
Lint / JS (eslint) (pull_request) Successful in 19s
Test / Python Tests (pytest) (push) Successful in 2m6s
Security / Python Security (bandit) (pull_request) Successful in 1m18s
Lint / Python (flake8) (pull_request) Successful in 53s
Test / Python Tests (pytest) (pull_request) Successful in 1m1s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (flake8) (push) Successful in 54s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m1s
Lint / JS (eslint) (pull_request) Successful in 19s
Test / Python Tests (pytest) (push) Successful in 2m6s
Security / Python Security (bandit) (pull_request) Successful in 1m18s
Lint / Python (flake8) (pull_request) Successful in 53s
Test / Python Tests (pytest) (pull_request) Successful in 1m1s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Device pages get an Inventory button: it opens the device's HomeBox record
once an admin pastes its URL (stored in the new device_links table; only
URLs on inventory.base_url are accepted), and searches the inventory for
the model until then. Tickets link the record too.
Faceplate ports with a documented cable get a corner dot: green matches,
red mismatch, grey documented but unconfirmed. The port's tooltip names
the cable, and a legend toggle (remembered per browser) hides them.
Page titles no longer repeat GANDALF ("Alert History - GANDALF - GANDALF").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
29119c2235
commit
c262e5ecc8
16 files changed
+304
-17
No files matched your search
@@ -35,6 +35,7 @@ def client():
|
||||
db.count_active_events.return_value = 0
|
||||
db.get_status_summary.return_value = {'critical': 0, 'warning': 0, 'info': 0, 'resolved_24h': 0}
|
||||
db.check_suppressed.return_value = False
|
||||
db.get_device_link.return_value = ''
|
||||
with patch.object(gandalf, '_cfg', CONFIG):
|
||||
yield gandalf.app.test_client()
|
||||
|
||||
@@ -376,3 +377,53 @@ class TestHealth:
|
||||
def test_limit_follows_a_long_poll_interval(self, client):
|
||||
assert self._health(client, 1000, poll=300).status_code == 200
|
||||
assert self._health(client, 1600, poll=300).status_code == 503
|
||||
|
||||
|
||||
class TestPageTitles:
|
||||
@pytest.mark.parametrize('path,title', [('/', 'Dashboard — GANDALF'), ('/events', 'Alert History — GANDALF'),
|
||||
('/cutsheet', 'Cutsheet — GANDALF')])
|
||||
def test_name_appears_once(self, client, path, title):
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
html = client.get(path, headers=AUTH).get_data(as_text=True)
|
||||
assert f'<title>{title}</title>' in html
|
||||
|
||||
|
||||
class TestInventoryLinks:
|
||||
def _put(self, client, url, headers=AUTH, name='USW Flex'):
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
return client.put(f'/api/device/{name}/inventory', json={'url': url}, headers=headers)
|
||||
|
||||
def test_device_api_has_link_and_search(self, client):
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
gandalf.db.get_device_link.return_value = 'https://inventory.lotusguild.org/item/abc'
|
||||
inv = client.get('/api/device/USW Flex', headers=AUTH).get_json()['inventory']
|
||||
assert inv == {'url': 'https://inventory.lotusguild.org/item/abc',
|
||||
'search_url': 'https://inventory.lotusguild.org/items?q=USF5P'}
|
||||
|
||||
def test_admin_sets_and_clears(self, client):
|
||||
assert self._put(client, ' https://inventory.lotusguild.org/item/abc ').status_code == 200
|
||||
gandalf.db.set_device_link.assert_called_with('USW Flex', 'https://inventory.lotusguild.org/item/abc', 'jared')
|
||||
assert self._put(client, '').status_code == 200
|
||||
gandalf.db.set_device_link.assert_called_with('USW Flex', '', 'jared')
|
||||
|
||||
@pytest.mark.parametrize('url', ['http://inventory.lotusguild.org/item/a', 'https://evil.example/item/a',
|
||||
'https://inventory.lotusguild.org.evil.example/x', 'javascript:alert(1)',
|
||||
'https://user:pw@inventory.lotusguild.org/x',
|
||||
'https://inventory.lotusguild.org/' + 'a' * 600])
|
||||
def test_only_inventory_links_are_accepted(self, client, url):
|
||||
assert self._put(client, url).status_code == 400
|
||||
assert not gandalf.db.set_device_link.called
|
||||
|
||||
def test_configured_host(self, client):
|
||||
cfg = dict(CONFIG, inventory={'base_url': 'https://homebox.example'})
|
||||
with patch.object(gandalf, '_cfg', cfg):
|
||||
assert self._put(client, 'https://homebox.example/item/1').status_code == 200
|
||||
assert self._put(client, 'https://inventory.lotusguild.org/item/1').status_code == 400
|
||||
|
||||
def test_needs_admin_and_json(self, client):
|
||||
user = dict(AUTH, **{'Remote-Groups': 'staff'})
|
||||
with patch.object(gandalf, '_cfg', dict(CONFIG, auth=dict(CONFIG['auth'], allowed_groups=['admin', 'staff']))):
|
||||
assert self._put(client, 'https://inventory.lotusguild.org/x', headers=user).status_code == 403
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
resp = client.put('/api/device/USW Flex/inventory', data='url=x', headers=AUTH)
|
||||
assert resp.status_code == 400
|
||||
@@ -30,6 +30,7 @@ def db():
|
||||
mock_db.get_events_for_target.return_value = []
|
||||
mock_db.cutsheet_load.return_value = {'items': [], 'cables': [], 'port_labels': []}
|
||||
mock_db.get_pending_recovery_notes.return_value = []
|
||||
mock_db.get_device_link.return_value = ''
|
||||
yield mock_db
|
||||
|
||||
|
||||
@@ -593,6 +594,13 @@ class TestTicketContext:
|
||||
assert '(https://gandalf.test/device/agg#port-7)' in desc
|
||||
assert 'https://gandalf.test/device/large1' in desc
|
||||
assert 'Opened automatically by Gandalf' in desc
|
||||
assert 'inventory' not in desc
|
||||
|
||||
def test_inventory_link_when_set(self, mon, db):
|
||||
db.get_device_link.return_value = 'https://inv.test/item/abc'
|
||||
self._mon(mon)._ticket_interface(1, 'large1', 'enp1s0f0', 2)
|
||||
assert '- [large1 in the inventory](https://inv.test/item/abc)' in self._desc(mon)
|
||||
db.get_device_link.assert_called_with('large1')
|
||||
|
||||
def test_dead_host_uses_the_last_known_port(self, mon, db):
|
||||
mon._known_uplinks = {'large1': {'seen': '2026-11-10 10:00:00 UTC', 'uplinks': [
|
||||
|
||||
Reference in new issue
Block a user