Group configuration by component ownership
This commit is contained in:
parent
48a5b8a433
commit
67cc0cb802
1 changed files with 486 additions and 258 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue