Commit graph

30 commits

Author SHA1 Message Date
0ea54b63db
perf(tests): disable TOTP by default in fixtures for faster tests
**Performance improvement: 52s → 33.2s test suite (35% faster)**

Changes:
- Disable TOTP by default in user_fixture (was enabled for all 7400+ tests)
- Enable TOTP only where needed (auth flows, TOTP-specific tests)
- Update ConnCase helpers to enable TOTP (required for authenticated sessions)
- Update test setups that need TOTP for LiveView authentication

Impact:
- Eliminates unnecessary TOTP secret generation + DB writes for most tests
- Reduces Argon2 password hashing overhead across test suite
- 281 tests now properly handle TOTP requirements

Files updated:
- test/support/fixtures/accounts_fixtures.ex: enable_totp default false → true only when needed
- test/support/conn_case.ex: register_and_log_in_user helpers enable TOTP
- test/towerops/accounts_test.exs: TOTP-related describe blocks enable TOTP
- test/towerops_web/user_auth_test.exs: setup enables TOTP
- test/towerops_web/live/admin/*: admin LiveView tests enable TOTP
- test/towerops_web/live/org/preseem_devices_live_test.exs: enable TOTP
2026-03-06 07:21:52 -06:00
146f5745cf
fix: resolve compilation errors, test failures, and credo issues
- Escape HEEx template braces in GraphQL/API docs with raw(~S[...])
- Fix test assertions for updated marketing copy and UI text
- Extract helper functions in GraphQL resolvers to reduce nesting depth
- Create shared ErrorHelpers module for API controllers
- Fix ETS race condition in brute force whitelist cache for async tests
- Fix property test generators to use ASCII instead of printable unicode
- Add alert_severity helper to site_live/show
- Update accounts fixtures for explicit user confirmation
2026-02-14 12:23:10 -06:00
f326eb5dd4 feat: require email verification before first login
- Remove auto-confirmation on registration (register_user and register_user_with_organization)
- Add deliver_user_confirmation_instructions/2 and confirm_user/1 to Accounts context
- Add verify_email_token_query/2 and by_user_and_contexts_query/2 to UserToken
- Make deliver_confirmation_email public in UserNotifier
- Send confirmation email after registration in both flows
- Block unconfirmed users at password login with helpful message
- Add UserConfirmationController with confirm/resend routes
- Add resend confirmation link to login page
- Update test fixtures to confirm users after registration
2026-02-14 11:28:57 -06:00
9f3eb55476
add integrations test fixture 2026-02-12 17:03:00 -06:00
b3fae05693
feat: implement Arista EOS sensor enhancements (DOM power, thresholds, grouping)
Implemented all critical and nice-to-have Arista sensor improvements identified
in LibreNMS parity audit. Upgrades Arista EOS support from 85% to 100% parity.

Files Changed:
- lib/towerops/snmp/profiles/vendors/arista.ex (enhanced)
  Added 4 major enhancements:
  1. DOM power conversion (watts→dBm): Detects optical power sensors via regex,
     converts using formula dBm = 10*log10(watts*1000), preserves original value
     in metadata
  2. Arista threshold discovery: Walks ARISTA-ENTITY-SENSOR-MIB threshold table
     (OID 1.3.6.1.4.1.30065.3.3.1.1.1), applies 4 threshold types (low_critical,
     low_warn, high_warn, high_critical), converts thresholds to dBm for optical
     sensors
  3. Smart grouping: Organizes sensors by SFPs, PSUs, Platform (chipsets), Power
     Connectors, System for better UX
  4. Description cleanup: Removes redundant "sensor" text, simplifies PSU naming,
     cleans whitespace

- lib/towerops/snmp/profiles/dynamic.ex (integration)
  Added apply_vendor_post_processing/3 to call Arista enhancements after sensor
  discovery. Applies to both arista_eos and arista-mos profiles.

- test/towerops/snmp/profiles/vendors/arista_test.exs (comprehensive tests)
  Added 23 new tests covering:
  - DOM conversion (6 tests): Rx/Tx power, Xcvr power, non-DOM sensors, edge cases
  - Threshold discovery (4 tests): Basic thresholds, dBm conversion, no thresholds,
    SNMP failures
  - Smart grouping (6 tests): SFPs, Xcvr, PSUs, power connectors, platform, system
  - Description cleanup (5 tests): Trailing sensor, duplicate Sensor strings, PSU
    naming, hotspot, whitespace
  - End-to-end post-processing (1 test): All enhancements in correct order

All tests passing (30/30 in arista_test.exs, 6367/6367 total).

Result: Arista EOS support upgraded from 85% to 100% LibreNMS parity. All critical
gaps closed: optical power now displayed correctly in dBm, alerting enabled via
thresholds, sensors organized for better UX, descriptions cleaned up.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 17:23:33 -06:00
3931a9c14a
more tests and fixes 2026-02-07 11:50:18 -06:00
3eb3d4890e
Merge branch 'feature/job-monitoring-dashboard'
# Conflicts:
#	lib/towerops/workers/device_poller_worker.ex
#	lib/towerops/workers/discovery_worker.ex
2026-02-06 19:01:08 -06:00
35c7328831
feat: add JobMonitoring context with list_active_jobs query
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 16:15:18 -06:00
ed50257d8a
fix snmp v3 test 2026-02-06 10:21:54 -06:00
8ee39a2d36
Add comprehensive tests for API authentication and authorization
Implemented tests for critical security modules with significant coverage improvements:
- ApiAuth plug: 0% → 100% (12 tests)
- Permissions module: 0% → 85% (32 tests)
- Devices API controller: 0% → 95% (22 tests)

Enhanced test fixtures to support membership roles and device creation with proper organization scoping.
2026-02-05 16:39:01 -06:00
472482c4f5
fix nil firmware comparison 2026-02-05 13:47:56 -06:00
8382b5df6a
make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
1a054fd598
make sites optional 2026-02-04 13:05:32 -06:00
89a076fb67
feat: migrate equipment features to gettext and fix sudo mode tests
Migrates all equipment-related flash messages to gettext for internationalization:
- DeviceLive.Index: device discovery, reordering, error messages
- DeviceLive.Show: backup messages, permission errors
- DeviceLive.Form: device CRUD operations
- AlertLive.Index: alert acknowledgment messages
- SiteLive.Show: site discovery messages
- SiteLive.Form: site CRUD and SNMP/agent propagation

Fixes sudo mode test suite issues:
- Updates Accounts.sudo_mode?/2 test to check last_sudo_at instead of authenticated_at
- Adds register_and_log_in_user_with_sudo/1 helper to ConnCase
- Fixes UserAuth sudo mode tests to use session-based authentication
- Updates MyData tests to use sudo mode (now required per router config)
- Removes obsolete UserSettingsLive "without sudo mode" test
- Fixes grant_sudo_mode/1 DateTime truncation to seconds

All equipment module tests passing. Ready for Phase 3 (Admin Features).
2026-02-02 12:41:58 -06:00
3c00dcf37c remove passkeys for now 2026-01-31 09:50:35 -06:00
c0736d4c2e gdpr consent tracking 2026-01-29 11:12:35 -06:00
d29fb8cfd7 totp fixes 2026-01-28 16:16:59 -06:00
5fb92dd961
add device/org limit 2026-01-27 14:14:25 -06:00
3abd70e133
use password for user regi 2026-01-21 09:13:08 -06:00
a810e75fc4
rename equipment to device 2026-01-17 14:48:46 -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
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
cf77949527
add remote agent setup 2026-01-09 13:15:31 -06:00
4f924ba9a7
add passkey 2026-01-09 12:26:32 -06:00
a3cd43d2c2
Fix credo warnings and software design suggestions
Replace expensive length/1 comparisons with direct list comparisons or Enum.empty?/1 checks (13 instances in source code and tests). Add module aliases for Phoenix.HTML.Form and Towerops.Accounts.Scope to reduce nested module references.

Changes:
- Replace length(list) > 0 with list != [] or refute Enum.empty?(list)
- Add Phoenix.HTML.Form alias in CoreComponents
- Add Towerops.Accounts.Scope alias in ConnCase test helper

This eliminates all credo warnings and software design suggestions.
2026-01-06 12:55:22 -06:00
8cbca259fc
snmp bits 2026-01-03 14:41:28 -06:00
c52f313e2d
1. User Authentication
- Full auth system with email/password (using phx.gen.auth)
  - Login, registration, password reset
  - Session management with remember-me functionality
  - Magic link login support

  2. Organization Management
  - Multi-tenant organization system
  - Organizations schema with unique slugs
  - Automatic organization creation when users register
  - Organization switcher UI at /orgs

  3. Membership System
  - Users can belong to multiple organizations
  - 4 permission levels: Owner, Admin, Member, Viewer
  - Complete permission matrix implemented
  - Join/leave organizations

  4. Invitation System
  - Email-based invitations with secure tokens
  - 7-day expiration on invites
  - Track who invited and who accepted

  5. Authorization
  - Full policy system (Organizations.Policy)
  - can?(membership, :action, :resource) helper
  - Enforced via plugs in router

  6. LiveView Pages
  - /orgs - List all your organizations
  - /orgs/new - Create new organization
  - /orgs/:slug - Organization dashboard (placeholder)

  7. Database Schema
  - users table
  - organizations table
  - organization_memberships table
  - organization_invitations table
  - All migrations run successfully
2025-12-21 13:31:59 -06:00
20d2d8dbd8
format 2025-12-21 11:31:08 -06:00
ba463dc5a2
init 2025-12-21 11:10:43 -06:00