- 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%
Added 5 new test cases for EquipmentLive.Show module:
- Test with tab parameter (interfaces tab)
- Test equipment status with monitoring checks
- Test SNMP device information display
- Test recent events display
- Test handling of missing equipment
Coverage improvement: ToweropsWeb.EquipmentLive.Show 35.51% → 46.38%
Overall coverage: 59.88% → 60.40%
All 21 tests pass successfully.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added extensive test suites to improve overall test coverage from 55.62% to 59.88%:
- Created Towerops.Snmp test suite (38 tests) - coverage: 10.87% → 97.83%
- Created Towerops.Snmp.Profiles.Cisco tests (14 tests) - coverage: 20.22% → 57.30%
- Created Towerops.Snmp.Profiles.NetSnmp tests (13 tests) - coverage: 56.79% → 92.59%
- Created Towerops.Monitoring.Supervisor tests (10 tests) - coverage: 21.21% → 63.64%
- Enhanced Towerops.Monitoring tests with TimescaleDB aggregate tests (skipped in test env)
Tests use Mox for SNMP client mocking with proper mock expectations for get/walk operations.
All tests follow established patterns and pass successfully.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add MIB files from LibreNMS in priv/mibs/ for reference
- Create MibParser module to validate OIDs against official MIB definitions
- Add MIB validation tests to ensure hardcoded OIDs match MIB specs
- Refactor SNMP tests to be generic/behavior-focused instead of vendor-specific
- Remove vendor-specific test files (cisco_test, net_snmp_test)
- All 104 tests passing with automated OID validation
Enhance SNMP error logging to include:
- Target IP address
- SNMP version (v1/v2c)
- Timeout value in milliseconds
- OID being queried
Before:
[warning] SNMP GET failed for "1.3.6.1.2.1.2.2.1.10.15729368": :timeout
After:
[warning] SNMP GET failed for 192.168.1.1 (v2c, timeout: 5000ms) OID "1.3.6.1.2.1.2.2.1.10.15729368": :timeout
This makes it much easier to diagnose SNMP issues by immediately knowing which
device is timing out and what the network configuration is.
Updated all SNMP operations: GET, WALK, and GET-BULK.
Use Plug.Telemetry's dynamic log level feature to disable logging for
/health requests. This is the proper Phoenix way to exclude specific
endpoints from request logs.
- Add log_level/1 function to endpoint that returns false for /health
- Configure Plug.Telemetry to use dynamic log level
- Remove log: false from router (handled by endpoint now)
This prevents Kubernetes health probe spam in application logs.
When exiting impersonation, now redirects to the superuser's default
organization's equipment list page instead of /admin. Falls back to /orgs
if the superuser has no organizations.
Critical bug fix: fetch_current_scope_for_user and mount_current_scope
were calling Accounts.get_user(nil) when impersonating session flag was
true but superuser_id or target_user_id were nil.
This caused FunctionClauseError crashes for all logged-out users if they
had stale impersonation session data.
Changes:
- Check if both superuser_id and target_user_id exist before calling get_user
- Clear invalid impersonation state if IDs are missing
- Apply fix to both fetch_current_scope_for_user (controllers) and
mount_current_scope (LiveViews)
This ensures graceful handling of corrupted/partial session state.
Changed signed_in_path to redirect users to their default organization's
equipment page instead of the organization list.
Behavior:
- If user has organizations, redirect to first org's equipment page
- First org is determined by most recently joined (membership.inserted_at)
- If user has no organizations, redirect to /orgs to create one
This provides a better UX by landing users directly at their equipment
list instead of requiring an extra click through the org selector.
Security improvements to prevent potential issues:
1. Port Validation (normalize_port):
- Validate port range is 1-65535
- Use Integer.parse instead of String.to_integer to prevent crashes
- Return default port 161 for any invalid input
2. SNMP Test Validation (validate_test_snmp_input):
- Validate IP address format before allowing SNMP tests
- Require non-empty community string
- Prevent network scanning with invalid/missing IPs
- Return clear error messages for validation failures
These changes ensure user input is properly validated and prevent:
- Integer overflow/underflow with ports
- Process crashes from invalid input
- Unauthorized network scanning via SNMP test feature
- SNMP requests with missing credentials