Files
Jo 06278615fb Fix: Increase login_attempt.ip_address column length for IPv6 support (#107035)
* fix: increase login_attempt.ip_address column length for IPv6 support

- Expand ip_address column from VARCHAR(30) to VARCHAR(50) to accommodate IPv6 addresses
- Add database migration with support for PostgreSQL, MySQL, and SQLite
- Add comprehensive integration tests for various IPv6 address formats
- Resolves 500 errors when login fails over IPv6, now returns proper 401 errors

Fixes #106362

* test: add missing test skip to TestIntegrationIPv6AddressSupport

Skip integration test when running with -short flag to separate unit and integration tests

* Update pkg/services/sqlstore/migrations/login_attempt_mig.go

Co-authored-by: Victor Cinaglia <victor@grafana.com>

* fix missing bracket

* fix: resolve PostgreSQL timestamp overflow in IPv6 test

- Use controlled time mock instead of time.Now() to avoid timestamp conversion issues
- Follow existing test patterns with xormStore and mock time functions
- Add proper Since parameter to GetIPLoginAttemptCount query
- Fixes PostgreSQL error: 'pq: value "-62135596800" is out of range for type integer'

* fix: resolve PostgreSQL UTF-8 encoding error in IPv6 test

Replace string(rune(i)) with fmt.Sprintf to avoid null bytes (0x00)
when i=0, which caused 'invalid byte sequence for encoding UTF8' error

---------

Co-authored-by: Victor Cinaglia <victor@grafana.com>
2025-06-24 16:11:45 +02:00
..