Repository navigation
Extract OnBeginRequest logic into a testable core layer - #12
Merged
Merged
Conversation
Add src/core, an IIS/Windows-independent static library (IISNativeModuleCore) holding the Verdict enum (Continue/Finish mirroring RQ_NOTIFICATION_CONTINUE/RQ_NOTIFICATION_FINISH_REQUEST), the IRequest/IResponse/IContext/IEventProvider/IModule interfaces mirroring their IIS counterparts, and ModuleHandler, which now carries the full OnBeginRequest logic (403 for /forbidden paths, response header otherwise). IISRequestLevelModule becomes a thin adapter: it takes a non-owning core::IModule* via constructor injection, wraps the live IIS objects in the IISContext/IISRequest/IISResponse/IISEventProvider adapters, delegates, and maps the Verdict back to a REQUEST_NOTIFICATION_STATUS. The factory owns the shared stateless ModuleHandler and injects it into every instance it creates. Each class lives in its own header/source pair, and files in src/module, src/core, and test/core are named after the class they hold (IContext.h, ModuleHandler.h/.cpp, IISRequestLevelModule.h/.cpp, ModuleHandlerTest.cpp, ...); register_module.cpp and iis_native_module.def keep their names since they hold no class. test/core/ModuleHandlerTest.cpp exercises the real ModuleHandler through hand-rolled mocks of the core interfaces for the two scenarios from the issue: a /forbidden url (Finish, 403, error status reported) and a generic url (Continue, X-IISRequestLevelModule: 1). Closes #11 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
src/core, an IIS/Windows-independent static library (IISNativeModuleCore, namespacecore) holding theVerdictenum (Continue/FinishmirroringRQ_NOTIFICATION_CONTINUE/RQ_NOTIFICATION_FINISH_REQUEST), theIRequest/IResponse/IContext/IEventProvider/IModuleinterfaces mirroring their IIS counterparts, andModuleHandler— which now carries the fullOnBeginRequestlogic (403 + reason for/forbiddenpaths,X-IISRequestLevelModule: 1header otherwise). Nothing insrc/coreincludes Windows or IIS headers; HRESULT-shaped values travel asstd::int32_t.IISRequestLevelModulebecomes a thin adapter: it takes a non-owningcore::IModule*via constructor injection, wraps the live IIS objects in theIISContext/IISRequest/IISResponse/IISEventProvideradapters (one file pair per class), delegates, and maps the returnedVerdictback to aREQUEST_NOTIFICATION_STATUS. The factory owns the shared statelessModuleHandlerand injects it into every instance it creates.test/core/ModuleHandlerTest.cpp: hand-rolled mocks of the core interfaces exercise the realModuleHandlerfor the two scenarios from the issue — a/forbiddenurl (expectsFinish, 403, access-denied error on response and provider, no header) and a generic url (expectsContinueand theX-IISRequestLevelModule: 1header).src/module,src/core, andtest/coreare named after the class they hold (PascalCase);register_module.cppandiis_native_module.defkeep their names since they hold no class.Design decisions (confirmed during implementation)
IContextdeclaresGetRequest() -> IRequest*/GetResponse() -> IResponse*(the issue text had the names swapped).IResponsealso declaresSetHeader, soModuleHandlercan carry the complete current behavior including the header stamping.IModuleitself, so the realModuleHandlerlogic is what's exercised.Test plan
windows-x86-64-debug), including the newIISNativeModuleCoreTestCorescenarios plus the existing smoke testCloses #11
🤖 Generated with Claude Code