Lifts the auth-essential users table from fewo-webapp into oatpp-authkit in temporal form per Option B from the issue body. The previous shape (id INTEGER autoinc + is_active flag) is replaced with the entity_id + valid_from/valid_until triple; soft-delete via valid_until = now() instead of toggling is_active. New files (all in oatpp-authkit): - dto/UserDto.hpp — auth-essential columns only: id, entity_id, username, password_hash, role, tls_cert_dn, valid_from, valid_until. Registered as temporal so TemporalRepository composes cleanly. Application- specific columns (email, profile data) belong on a consumer-side DTO + parallel SchemaContract that contributes additional columns to the same users table. - db/UserDb.hpp — DbClient with login-path queries (findLiveByUsername, findLiveByTlsCertDn) plus generic CRUD. UserSchema declares the schema: TEXT id, entity_id, username, password_hash, role, tls_cert_dn, with natural-key UNIQUE on (username, valid_until) so no two live rows can share a username while historical rows for the same username are allowed. - repo/ConcreteUserRepository.hpp — Repository<UserDto> adapter + makeUserRepository factory wrapping in TemporalRepository. - test/test_user_schema.cpp — verifies SchemaBuilder<UserSchema, TemporalRepository<UserDto>>::create produces the expected 5 DDL statements; specifically asserts is_active and created_at are NOT present in the temporal shape (Option B replacement). 13 of 13 tests pass. Bumped 0.11.0 → 0.12.0. Per owner directive on authkit#14: password_hash rides the temporal row. A separate security follow-up issue tracks the redaction policy for historical password hashes (likely blank the hash but keep the row so change-history is auditable). The migration of an existing non-temporal users table to this shape is documented in db/UserDb.hpp: Atlas-generated migration handles the structural conversion + backfill (each existing row becomes its own entity with entity_id = CAST(id AS TEXT)). Sessions/certificates FKs that referenced users.id (INTEGER) need rewiring to reference users.entity_id — that's a consumer-side rewire, separate PR. Closes #14 — the four migration sub-PRs (PR 1 role_templates, PRs 2+3 permissions, PR 4 users) are now landed; the umbrella issue can close. Follow-ups (security hash redaction, fewo-webapp consumer migration, Atlas CI integration) get their own issues. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
3.5 KiB
CMake
70 lines
3.5 KiB
CMake
# Minimal test harness for oatpp-authkit.
|
|
#
|
|
# Adds plain executable tests linked against the INTERFACE library and oatpp.
|
|
# No third-party test framework — assertions use <cassert> and a tiny REQUIRE
|
|
# macro so the suite stays portable and dependency-free.
|
|
|
|
find_package(oatpp REQUIRED)
|
|
|
|
add_executable(test_negotiation test_negotiation.cpp)
|
|
target_link_libraries(test_negotiation PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME negotiation COMMAND test_negotiation)
|
|
|
|
add_executable(test_body_size_limit test_body_size_limit.cpp)
|
|
target_link_libraries(test_body_size_limit PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME body_size_limit COMMAND test_body_size_limit)
|
|
|
|
add_executable(test_security_headers test_security_headers.cpp)
|
|
target_link_libraries(test_security_headers PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME security_headers COMMAND test_security_headers)
|
|
|
|
add_executable(test_json_serialization test_json_serialization.cpp)
|
|
target_link_libraries(test_json_serialization PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME json_serialization COMMAND test_json_serialization)
|
|
|
|
add_executable(test_repository_interface test_repository_interface.cpp)
|
|
target_link_libraries(test_repository_interface PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME repository_interface COMMAND test_repository_interface)
|
|
|
|
add_executable(test_repository_decorators test_repository_decorators.cpp)
|
|
target_link_libraries(test_repository_decorators PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME repository_decorators COMMAND test_repository_decorators)
|
|
|
|
add_executable(test_queryable test_queryable.cpp)
|
|
target_link_libraries(test_queryable PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME queryable COMMAND test_queryable)
|
|
|
|
add_executable(test_temporal_field_traits test_temporal_field_traits.cpp)
|
|
target_link_libraries(test_temporal_field_traits PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME temporal_field_traits COMMAND test_temporal_field_traits)
|
|
|
|
add_executable(test_audit_log_repository test_audit_log_repository.cpp)
|
|
target_link_libraries(test_audit_log_repository PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME audit_log_repository COMMAND test_audit_log_repository)
|
|
|
|
add_executable(test_schema_contract test_schema_contract.cpp)
|
|
target_link_libraries(test_schema_contract PRIVATE oatpp::authkit oatpp::oatpp)
|
|
add_test(NAME schema_contract COMMAND test_schema_contract)
|
|
|
|
# RoleTemplateDb pulls in oatpp-sqlite for its DbClient queries. Linking
|
|
# the test against oatpp::oatpp-sqlite provides the QUERY codegen
|
|
# definitions; the test itself doesn't open a real DB, only compiles
|
|
# against the schema declarations.
|
|
find_package(oatpp-sqlite QUIET)
|
|
find_package(Threads QUIET)
|
|
if(oatpp-sqlite_FOUND AND Threads_FOUND)
|
|
add_executable(test_role_template_schema test_role_template_schema.cpp)
|
|
target_link_libraries(test_role_template_schema
|
|
PRIVATE oatpp::authkit oatpp::oatpp oatpp::oatpp-sqlite Threads::Threads)
|
|
add_test(NAME role_template_schema COMMAND test_role_template_schema)
|
|
|
|
add_executable(test_user_permission_schema test_user_permission_schema.cpp)
|
|
target_link_libraries(test_user_permission_schema
|
|
PRIVATE oatpp::authkit oatpp::oatpp oatpp::oatpp-sqlite Threads::Threads)
|
|
add_test(NAME user_permission_schema COMMAND test_user_permission_schema)
|
|
|
|
add_executable(test_user_schema test_user_schema.cpp)
|
|
target_link_libraries(test_user_schema
|
|
PRIVATE oatpp::authkit oatpp::oatpp oatpp::oatpp-sqlite Threads::Threads)
|
|
add_test(NAME user_schema COMMAND test_user_schema)
|
|
endif()
|