Group configuration by component ownership

This commit is contained in:
ms2k 2026-07-20 02:21:33 +09:00
commit 67cc0cb802

View file

@ -30,7 +30,7 @@ import Network.Wai.Test
, srequest
)
import Nuthatch.Api
import Nuthatch.Config (Config)
import Nuthatch.Config (Config (..), HttpConfig)
import Nuthatch.Http.Auth
( authenticationHandler
, loginResponse
@ -79,6 +79,9 @@ tests = testGroup "typed HTTP boundary"
@?= "healthz"
]
httpConfig :: HttpConfig
httpConfig = cfgHttp testConfig
testRouteSelection :: IO ()
testRouteSelection = do
calls <- newIORef 0
@ -324,11 +327,11 @@ typedTestServer calls =
testAuthenticationBoundary :: IO ()
testAuthenticationBoundary = do
tokenResult <- mintSession testConfig "issuer" "subject" Nothing
tokenResult <- mintSession httpConfig "issuer" "subject" Nothing
token <- either (fail . T.unpack) pure tokenResult
let csrf = CsrfToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
responseHeaders = getHeaders
(loginResponse testConfig token csrf)
(loginResponse httpConfig token csrf)
cookieHeaders =
[ value
| (name, value) <- responseHeaders
@ -353,7 +356,7 @@ testAuthenticationBoundary = do
(length (filter ("HttpOnly" `BS.isInfixOf`) cookieHeaders) == 2)
calls <- newIORef 0
let app = productionAuthTestApplication testConfig calls
let app = productionAuthTestApplication httpConfig calls
cookie =
"nuthatch_session=" <> TE.encodeUtf8 (unSessionToken token)
<> "; nuthatch_csrf=" <> TE.encodeUtf8 (unCsrfToken csrf)
@ -415,7 +418,7 @@ testCanonicalProductRoutes = do
simpleStatus response @?= status404
readIORef calls >>= (@?= 0)
productionAuthTestApplication :: Config -> IORef Int -> Application
productionAuthTestApplication :: HttpConfig -> IORef Int -> Application
productionAuthTestApplication cfg calls =
utf8Boundary $
serveWithContext