Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Core v2.5.0 — Tests & Internal Hardening
Summary
Adds 249 unit tests across 16 test classes covering every critical subsystem, eliminates magic strings via enums and constants, fixes thread safety issues in static registries, and replaces silent exception swallowing with proper logging.
Changes
1. Unit test suite (249 tests)
Added: 16 test classes
ContainerTest— DI resolve, singleton, constructor/field injection, circular detection, interface bindingBlueprintTest— SQL generation per DB type (SQLite, MySQL, PostgreSQL), modifiers, full table scenariosAuthPasswordTest— BCrypt hash/check, unicode, long passwordsAuthTest— login/logout, session attributes, user resolution, hasRole, token auth, brute force integrationLoginRateLimiterTest— lockout after 5 failures, IP/username independence, reset on successRouteLoaderTest— resolvePrefix edge cases (trailing slash, whitespace, no annotation), named routesRequestValidatorTest— all 14 validation rules, chained rules, early stop, validateSafeValidationErrorsTest— add, first-error-only, count, defensive copyEnvLoaderTest— .env loading, get/getRequired/getInt/getBoolean, singleton guardArgParserTest— positional params, options, flags, defaults, type coercion, variadicInMemoryCacheDriverTest— put/get, TTL expiry, forget, putAll/getAllCacheTest— facade delegation, remember patternCsrfTokenRepositoryTest— token generation, validation, expiry, removalRoleCheckerTest— registration of roles, login-required, token-required pathsLocalDiskTest— read/write/delete/list, stream, URL generation, path traversal protectionStorageManagerTest— disk selection, delegation, multi-disk isolation, chaining2.
DatabaseTypeenum — eliminates DB type magic stringsAdded:
DatabaseType.javaModified:
DB.java,Migration.java,MigrationManager.java,DatabaseLoader.java"sqlite"/"mysql"/"postgresql"string comparisons withDatabaseType.SQLITE/MYSQL/POSTGRESQLDB.getType()now returnsDatabaseTypeinstead ofStringBlueprintconstructor takesDatabaseTypeinstead ofStringDatabaseType.fromString()handles null/empty with SQLITE default3.
SessionKeysconstants — eliminates session attribute magic stringsAdded:
SessionKeys.javaModified:
Auth.java,RouteHandler.java"logged","user_id","username","role","flash_error"replaced withSessionKeys.*constants4.
EnvKeysconstants — eliminates environment variable magic stringsAdded:
EnvKeys.javaModified:
Obsidian.java,WebServer.java,ErrorHandler.java,RoleChecker.java,DatabaseLoader.java,CacheLoader.java,StorageLoader.java,PebbleTemplateEngine.java,FlowScriptExtension.java"ENVIRONMENT","PORT_WEB","DB_TYPE","CACHE_DRIVER","STORAGE_*","SITE_URL"replaced withEnvKeys.*constants5. Thread safety — concurrent collections in static registries
Modified:
RoleChecker.java,MiddlewareManager.java,Route.java,TemplateManager.javaHashMap→ConcurrentHashMapHashSet→ConcurrentHashMap.newKeySet()ArrayList→CopyOnWriteArrayList6. Silent exception handling — catch ignored → proper logging
Modified:
Auth.java,ArgParser.java,CommandDiscovery.java,CliComponents.javacatch (Exception ignored) {}replaced withlogger.warn()/logger.debug()where appropriateAuth.java: TokenResolver instantiation failure is now logged (was silently swallowed)CliComponents.java:InterruptedExceptionnow restores interrupt flag viaThread.currentThread().interrupt()Loggerfield toAuth,ArgParser,CommandDiscoveryBreaking Changes
DB.getType()returnsDatabaseTypeinstead ofString. Apps comparing with"sqlite"must useDatabaseType.SQLITEinstead. All other changes are internal.