- Add tab selector in Monitoring Configuration section for choosing monitoring mode
- SNMP & ICMP mode: enables ICMP pings + SNMP discovery (default)
- ICMP Only mode: enables only ICMP ping monitoring, hides SNMP fields
- Monitoring mode controls snmp_enabled field automatically on save
- Test SNMP Connection button shows informational message when agent is configured
(agents handle SNMP testing during their polling cycle)
- Update all tests to use tab selector instead of setting snmp_enabled directly
- All 818 tests passing with no Credo warnings
- Add Monitoring.get_latency_data/2 to query successful checks with response times
- Support 'latency' sensor type in GraphLive.Show with configurable time ranges
- Add latency chart to device show page alongside other metric charts
- Add comprehensive tests for get_latency_data/2 (limit, since, failed checks)
- All 813 tests passing with no Credo warnings
Implemented hierarchical SNMP community string inheritance following TDD:
Schema changes:
- Updated Device.changeset to remove required validation for snmp_community
- Community string is now optional when SNMP is enabled
- Allows inheritance from site or organization level
Inheritance hierarchy:
- Device-level community (highest priority)
- Site-level community
- Organization-level community
- nil (no community set at any level)
Form updates:
- extract_snmp_config now resolves inherited community for SNMP testing
- validate_test_snmp_input provides clearer error message about inheritance
- SNMP test uses effective community from hierarchy
Tests:
- Added tests for creating devices with nil/empty community string
- Added comprehensive SNMP configuration inheritance tests
- Tests verify hierarchy: device > site > org > default
- All 28 device tests passing
All 808 tests passing (2 pre-existing alert notifier failures unrelated to this change)
No Credo warnings
Implemented ability to rename agents through a new edit page following TDD:
Backend changes:
- Added update_agent_token/2 in Agents context for updating agent names
- Added update_changeset/2 in AgentToken schema that only allows name updates
- Security: Token field cannot be changed, only name field is allowed
LiveView implementation:
- Created AgentLive.Edit module with mount, validate, and save handlers
- Created edit.html.heex template with form for renaming agents
- Added route /orgs/:org_slug/agents/:id/edit
- Added Edit button to agent show page header
- Validates organization ownership using Repo.get_by!
Tests:
- Added comprehensive context tests for update_agent_token/2
- Added LiveView tests for edit page functionality
- Tests cover: loading, validation, save/redirect, auth, and org ownership
All 801 tests passing, no Credo warnings.
Replace the revoke functionality with delete to properly clean up agent references.
When an agent is deleted:
- All direct device assignments are removed
- Agent is removed from site defaults
- Agent is removed from organization defaults
- Devices automatically fall back to site/org agents or cloud polling
This ensures no orphaned references and provides better clarity about
what happens to device monitoring when an agent is removed.
- Add delete_agent_token/1 function in Agents context
- Update LiveView to use delete_agent event instead of revoke_agent
- Update UI button from "Revoke" to "Delete" with clearer confirmation message
- Add comprehensive tests for delete functionality and fallback behavior
- All 792 tests passing, no Credo warnings
- Create UserSettingsLive to replace UserSettingsController
- Convert email/password forms to LiveView with proper form handling
- Add mobile session management (toggle alerts, revoke devices)
- Add require_sudo_mode on_mount hook to UserAuth
- Create dedicated live_session for sudo mode routes in router
- Keep UserSettingsController for email confirmation via token only
- Add MobileSessions.get_session/1 function for test support
- Update tests to match LiveView behavior (password update redirects to login)
- Remove old controller tests for email/password updates (now in LiveView)
Bandit 1.10.1 does not support read_timeout/write_timeout in http_1_options
or stream_idle_timeout in http_2_options. These invalid options caused the
application to crash on startup with 'Unsupported key(s) in http_1_options'.
Moved read_timeout to thousand_island_options where it belongs, and removed
the unsupported write_timeout and stream_idle_timeout options.
Also fixed UserSettingsHTMLTest to include the missing mobile_sessions assign
that is required by the edit.html.heex template.
Set explicit min/max bounds on chart x-axis to ensure all graphs
consistently show 24 hours of data, even when data points are sparse.
Also fix AlertNotifierTest race condition by disabling async execution.
Add three-level agent assignment hierarchy (Equipment > Site > Organization)
allowing flexible agent deployment strategies. Agents now receive only equipment
assigned to them through direct assignment or inheritance from site/organization
defaults.
Key changes:
- Add agent_token_id to Sites table with migration
- Implement get_effective_agent_token/1 for hierarchical resolution
- Add list_agent_polling_targets/1 to return polling targets per agent
- Update API config endpoint to use hierarchical polling targets
- Add agent assignment UI to equipment, site, and organization forms
- Show agent source (direct/site/org/none) in equipment form
- Add equipment count column to agent list
- Update terminology from "poll from server" to "cloud polling"
Tests:
- Add 8 comprehensive tests for list_agent_polling_targets/1
- Add end-to-end test for hierarchical config endpoint
- All 775 tests passing
- Update AgentAuth plug to use synchronous heartbeat updates in test env
- Refactor async heartbeat logic to reduce nesting (Credo)
- Remove Process.sleep from tests (no longer needed with sync updates)
This fixes 'owner exited' database errors in the test suite by avoiding
async Task spawns during tests, which caused DB connection ownership
conflicts with Ecto's sandbox mode.
Login flow improvements:
- Remove "Welcome back!" flash message on successful login
- Auto-login users clicking magic links without confirmation prompt
- Always use "remember me" for magic link logins
- Fix Accounts.login_user_by_magic_link/1 to handle invalid token format
Test fixes:
- Add @tag :integration to Ping tests (require actual system ping)
- Add halt() calls to UserAuth.start_impersonation error paths
Users now go directly to their intended destination after clicking a
magic link, with no interruption for "log in and stay logged in" choice.
- Test equipment information display
- Test overview tab rendering
- Test metrics display with monitoring checks
- Test empty state handling
- Test periodic data refresh
- Test authentication requirement
- Test event handling (equipment_status_changed, discovery_completed)
- Test tab switching functionality
- Test valid changesets with required and all fields
- Test validation for name, description, location lengths
- Test parent site relationships and circular reference validation
- Test all constraint validations
- Test unique organization name generation
- Test valid organization attributes
- Test organization creation with defaults and custom attributes
- Test membership creation for organization owner
- Test all fixture generation functions
- Test user creation (confirmed and unconfirmed)
- Test scope fixtures
- Test password setting
- Test token generation and manipulation
- Test credential fixtures
- Add comprehensive tests for Towerops.Monitoring.Ping module
- Test successful pings, timeouts, error handling, and OS detection
- Add tests for ToweropsWeb.OrgLive.New LiveView
- Test form validation, organization creation, and authentication
Added 4 tests covering previously untested scenarios:
- Agent with warning status (2-5 minutes offline)
- Agent with offline status (>5 minutes offline)
- Last seen time formatting (hours and days)
Coverage increased from 80% to near 100%.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Test deliver_update_email_instructions/2
- Test deliver_login_instructions/2 for confirmed and unconfirmed users
- Verify email content and recipients
- Coverage remains at 67.05%
- Test start_monitor/1 and stop_monitor/1
- Test start_snmp_poller/1 and stop_snmp_poller/1
- Test start_all_monitors/0 and start_all_snmp_pollers/0
- Verify process lifecycle management
- Coverage: 67.05% -> 67.09%
- Updated Monitoring module to calculate hourly/daily stats on-demand from monitoring_checks table
- Removed TimescaleDB continuous aggregate dependency (disabled due to licensing)
- Enabled all previously skipped TimescaleDB tests with proper test data
- Fixed UUID encoding for SQL queries using Ecto.UUID.dump!
- Fixed Decimal handling in uptime percentage calculation
- Added test for get_uptime_percentage with nil checks
- Monitoring module now at 100% coverage
Added 6 new tests to improve coverage:
- list_snmp_enabled_equipment/0 for SNMP-enabled equipment filtering
- update_snmp_poll_time/1 for updating polling timestamps
- create_event/1 for creating equipment events with proper schema
- list_equipment_events/2 for event retrieval and ordering
- list_equipment_events/2 with limit parameter
This improves Equipment coverage from 87.50% to higher.
Added 5 new tests to improve coverage:
- list_root_sites/1 for filtering root sites without parents
- list_child_sites/1 for getting child sites of a parent
- list_child_sites/1 edge case with no children
- get_site!/1 for verifying preload behavior with parent and child sites
This improves Sites coverage from 83.33% to higher.
Added 9 new tests to expand coverage:
- get_agent_token!/1 success and failure cases
- update_agent_token_heartbeat/3 edge cases (nil and empty metadata)
- get_equipment_assignment/1 for assigned and unassigned equipment
- update_equipment_assignment/2 for creating, updating, and removing assignments
This improves Agents coverage from 89.29% to higher.
Added 2 tests covering the edit.html settings form template:
- Settings form rendering with email, password, and passkeys sections
- Warning message when user cannot register passkey
This improves UserSettingsHTML coverage from 0% to 100%.
Added 5 tests covering both new.html and confirm.html templates:
- Login form rendering with multiple authentication methods
- Reauthentication message display
- Confirmation form for unconfirmed users
- Login form for confirmed users
- Simplified login for reauthentication with current_scope
This improves UserSessionHTML coverage from 50.00% to 100%.
Added test to cover the fallback render/2 function that handles
error codes without custom templates (401, 403, 503, etc.).
This improves ErrorHTML coverage from 0% to 100%.
Improved coverage from 60.00% to 100% by adding 13 tests covering:
- Required field validations (email, role, organization_id, invited_by_id)
- Email format validation
- Automatic token generation using crypto
- Token preservation when provided
- Automatic expires_at generation (7 days from now)
- Expires_at preservation when provided
- All valid role values (admin, member, viewer)
- Accepted_at field handling
Overall coverage: 66.34%
- Added comprehensive tests for ToweropsWeb.AgentLive.Index
- Tests mount, create_agent, revoke_agent, and close_token_modal events
- Tests agent status display and last_seen formatting
- Coverage improved from 57.50% to 80.00%
- Enhanced ToweropsWeb.UserAuth tests
- Added tests for impersonation functionality
- Added tests for organization loading and membership verification
- Added tests for superuser authorization
- Coverage improved from 51.08% to 61.87%
- Expanded Towerops.Snmp.Profiles.Cisco tests
- Added tests for all sensor type parsing functions
- Added tests for different sensor scales, statuses, and error conditions
- Tests sensor discovery with various data formats
- Coverage improved from 57.30% to 100.00%
Overall test coverage improved from 64.25% to 65.86%