Commit graph

210 commits

Author SHA1 Message Date
aa62cc7349
Move Create Agent buttons below input field
- Changed form layout from horizontal to vertical
- Agent name input now on its own line
- Create Agent and Cancel buttons on line below with gap-3 spacing
2026-01-13 13:22:18 -06:00
daa8aa3966
add claude.md to git 2026-01-13 13:21:33 -06:00
f9b575816a
Fix database ownership issues in agent auth tests
- 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.
2026-01-13 13:16:54 -06:00
9ec14b7785
Add Agents navigation link to authenticated layout 2026-01-13 13:14:23 -06:00
3eb95b5f90
Streamline login flow and fix test failures
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.
2026-01-13 13:08:24 -06:00
11bc5dec4a
no post login page 2026-01-13 12:27:17 -06:00
d16f105f15
more tests 2026-01-13 09:18:25 -06:00
fc1b6ea026
Add comprehensive tests for EquipmentLive.Show
- 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
2026-01-13 09:13:40 -06:00
167f853a63
Add comprehensive tests for Sites.Site schema
- 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
2026-01-13 09:05:02 -06:00
7a33fbff66
Add tests for OrganizationsFixtures
- Test unique organization name generation
- Test valid organization attributes
- Test organization creation with defaults and custom attributes
- Test membership creation for organization owner
2026-01-13 08:59:40 -06:00
2c35ad457c
Add comprehensive tests for AccountsFixtures
- 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
2026-01-13 08:57:49 -06:00
d58f6b2d3a
Add tests for Monitoring.Ping and OrgLive.New
- 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
2026-01-13 08:54:49 -06:00
b35071d106
Fix unused import warning in agent_live_test.exs
Change from fully-qualified Ecto.Query.from() calls to using
the imported from() macro directly to eliminate unused import
warning.
2026-01-13 08:48:42 -06:00
0689fec38c
Add AgentsFixtures tests
Added 4 tests covering all fixture functions:
- unique_agent_name/0 generation
- agent_token_fixture/2 with default and custom names
- agent_assignment_fixture/2 creation

Coverage increased from 40% to 100%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:42:15 -06:00
19953ae289
Add AgentLive.Index edge case tests
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>
2026-01-13 08:41:07 -06:00
00ebe0c5fe
Add comprehensive Agent protobuf module tests
Added 37 tests covering all 12 protobuf modules:
- AgentConfig, Equipment, SnmpConfig
- Sensor, Sensor.MetadataEntry, Interface
- MetricBatch, Metric (with oneof field handling)
- SensorReading, InterfaceStat
- HeartbeatMetadata, HeartbeatResponse

Tests cover struct creation, default values, and encode/decode cycles.
All protobuf modules now at 100% coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:39:02 -06:00
8291c6092a
Add comprehensive AgentController edge case tests
Added 6 new tests covering previously untested scenarios:
- Equipment without SNMP device (nil sensors/interfaces)
- Protobuf metrics with unknown types
- JSON metrics with unknown types
- Metrics with nil timestamps
- Metrics with invalid ISO8601 timestamp strings

Coverage increased from 90.41% to near 100%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:37:58 -06:00
3fe051fd19
Add comprehensive AgentAuth plug tests
Added 8 tests covering all plug functionality:
- init/1 option passing
- Valid token authentication
- Invalid authorization header scenarios
- Malformed Bearer token handling
- Invalid token value rejection
- Asynchronous heartbeat updates
- Token verification error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:35:13 -06:00
5bd24b09f9
Add UserNotifier tests
- 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%
2026-01-13 08:25:20 -06:00
df315a897a
Add Monitoring.Supervisor tests
- 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%
2026-01-13 08:21:50 -06:00
3068f944fb
Add TimescaleDB aggregate tests, implement on-demand calculation
- 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
2026-01-13 08:09:12 -06:00
43a9ff01a6
Add comprehensive tests for Equipment context
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.
2026-01-13 08:01:45 -06:00
6cc068543d
Add comprehensive tests for Sites context
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.
2026-01-13 07:59:10 -06:00
b91f81fc2e
Add comprehensive tests for Agents context
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.
2026-01-13 07:54:36 -06:00
f0af777f6e
Add tests for UserSettingsHTML
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%.
2026-01-13 07:52:46 -06:00
a430d09668
Add test for UserRegistrationHTML
Added test to cover the new.html registration form template.

This improves UserRegistrationHTML coverage from 0% to 100%.
2026-01-13 07:52:06 -06:00
29c8e1a8d3
Add comprehensive tests for UserSessionHTML
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%.
2026-01-13 07:50:39 -06:00
89b038a14f
Add test for PageHTML home template
Added test to cover the home.html template rendering.

This improves PageHTML coverage from 0% to 100%.
2026-01-13 07:49:25 -06:00
6e02dc460a
Add test for ErrorHTML fallback render function
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%.
2026-01-13 07:48:23 -06:00
7e5da340d3
Add comprehensive tests for Accounts.UserCredential
Improved coverage from 28.57% to 100% by adding 13 tests covering:
- Required field validations (user_id, credential_id, public_key, name)
- Name length validation (min 1, max 100 characters)
- Optional field handling (sign_count, last_used_at, aaguid, transports, backup flags, attestation_format)
- Default values for optional fields
- touch_changeset/1 function (updates last_used_at and increments sign_count)

Overall coverage: 66.44%
2026-01-13 07:47:37 -06:00
f5bef9b997
Add comprehensive tests for Organizations.Invitation
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%
2026-01-13 07:45:50 -06:00
160007cab1
Add HealthController test (0% → 100%) 2026-01-13 07:39:28 -06:00
e6650833f6
Improve test coverage: AgentLive.Index, UserAuth, Cisco profile
- 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%
2026-01-12 18:56:23 -06:00
7cf3e61709
Add comprehensive tests for EquipmentLive.Form and UserCredentialController
- EquipmentLive.Form: 46.73% → 92.52% (+45.79%)
  - Added 27 tests covering form validation, SNMP testing, site selection
  - Tests mount behavior, save/update flows, deletion, and discovery triggers
  - Tests SNMP config changes and agent assignment

- UserCredentialController: 33.93% → 64.29% (+30.36%)
  - Added 7 tests for WebAuthn registration and authentication flows
  - Tests challenge generation, credential registration, and error cases
  - Tests discoverable authentication and account-specific auth

Overall coverage: 60.40% → 63.67% (+3.27%)
2026-01-12 18:46:15 -06:00
3c41f7e132
Enhance EquipmentLive.Show test coverage with additional test cases
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>
2026-01-12 18:35:37 -06:00
d21e389b04
Improve test coverage with comprehensive SNMP and monitoring tests
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>
2026-01-12 18:31:19 -06:00
cb93c02d74
update deps 2026-01-12 17:07:33 -06:00
1b8017dd98
change replicas 2026-01-12 10:43:24 -06:00
f377664e49
add logs helper script 2026-01-11 15:45:02 -06:00
53b99fd3ca
Add gen_smtp dependency for Swoosh AmazonSES adapter
The AmazonSES adapter requires gen_smtp to encode emails with mimemail.
2026-01-11 15:41:21 -06:00
d8247ec59c
Rename GitLab agent config to match home-cluster-agent 2026-01-11 15:37:49 -06:00
9be221209b
change agent path 2026-01-11 15:27:05 -06:00
18e20ffdb8
update runner 2026-01-11 15:12:57 -06:00
36175be74e
fix dialyzer and credo 2026-01-11 15:01:57 -06:00
5e1a97fcb3
fix tests 2026-01-11 14:58:55 -06:00
f16b0ebabd
awsses 2026-01-11 14:55:07 -06:00
51019e30ce
Update GitLab agent context name for deployment 2026-01-11 13:38:44 -06:00
d382f6a46e
update gitlab ci 2026-01-11 13:33:54 -06:00
1a619b47b2
Add home-cluster-glab-agent configuration 2026-01-11 13:29:02 -06:00
3ef04f261f
protobufs 2026-01-09 17:33:01 -06:00