-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Parent Issue
Part of #5472 — Unit Testing Framework: Milestone 2
Depends On
- Unit Testing Phase 2.1: Test Infrastructure Foundation (Glo* Stubs & Harness) #5473 — Phase 2.1: Test Infrastructure Foundation
Why Authentication First
MySQL_Authentication and PgSQL_Authentication have the lowest coupling of any interesting component:
- 72 references to
GloMyAuthacross the codebase (vs 403 forGloAdminor 378 forGloMTH) - Self-contained data structures:
creds_group_twraps a btree map +PtrArraywith its own rwlock - No dependency on
GloAdminfor coreadd()/lookup()/del()operations (Admin only populates the auth store; it doesn't participate in lookups) - Clear interface with well-defined behavior that is critical to test: authentication is a security boundary
Scope
Test File
test/tap/tests/unit/auth_unit-t.cpp
Test Cases
Core CRUD operations:
add()a frontend user →lookup()returns correctaccount_details_t(username, password, default_hostgroup, default_schema, etc.)add()a backend user →lookup()with correctcred_username_typereturns it; wrong type returns emptydel()a user → subsequentlookup()returns emptyexists()returns true for added users, false for unknown users- Adding duplicate username → verify behavior (overwrite? error?)
- Adding user with empty username / very long username / special characters
Credential management:
set_SHA1()→ verify SHA1 hash is stored and retrievableset_clear_text_password()→ verify password is stored correctly- Lookup with
PASSWORD_TYPEflag matching
Connection counting:
increase_frontend_user_connections()increments counterdecrease_frontend_user_connections()decrements counter- Connection count respects
max_connections— verify the enforcement behavior
Bulk operations:
set_all_inactive()→ all users marked inactiveremove_inactives()→ inactive users purged; active users remainset_all_inactive()+ selectively re-add()+remove_inactives()→ simulates config reload
Checksums:
get_runtime_checksum()returns deterministic value for same user set- Adding/removing a user changes the checksum
- Checksum is order-independent (adding users A,B gives same checksum as B,A)
Memory:
memory_usage()returns non-zero after addsmemory_usage()decreases after deleting usersreset()brings memory usage to baseline
Frontend vs Backend separation:
- Users added as frontend are not visible in backend lookups and vice versa
- Same username can exist in both frontend and backend with different credentials
PgSQL equivalents:
- Mirror key test cases for
PgSQL_Authenticationto verify parity
Acceptance Criteria
- All test cases pass when run standalone (no running ProxySQL, no Docker)
- Tests complete in under 2 seconds total
- No memory leaks under ASAN
- Tests pass on both Linux and macOS
- Tests cover both
MySQL_AuthenticationandPgSQL_Authentication - Test file follows existing TAP conventions (
plan(),ok(),is(), etc.)
Reactions are currently unavailable