Add reproducible browser and accessibility gates
This commit is contained in:
parent
4d31c441d0
commit
9ad8d27adf
1 changed files with 1887 additions and 103 deletions
43
test/BrowserSessionFixture.hs
Normal file
43
test/BrowserSessionFixture.hs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
module Main (main) where
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.Text as T
|
||||
import Nuthatch.Config (HttpConfig (..), secret)
|
||||
import Nuthatch.Session (mintSession, newCsrfToken)
|
||||
import Nuthatch.Types
|
||||
( CsrfToken (..)
|
||||
, SessionToken (..)
|
||||
)
|
||||
import System.Environment (getArgs, lookupEnv)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
[output] <- getArgs
|
||||
jwtSecret <- maybe (fail "NUTHATCH_JWT_SECRET is required") pure
|
||||
=<< lookupEnv "NUTHATCH_JWT_SECRET"
|
||||
token <- mintSession
|
||||
(fixtureHttpConfig (T.pack jwtSecret))
|
||||
"https://browser-fixture.invalid"
|
||||
"browser-user"
|
||||
(Just "Browser Fixture")
|
||||
>>= either (fail . T.unpack) pure
|
||||
csrf <- newCsrfToken
|
||||
A.encodeFile output $
|
||||
A.object
|
||||
[ "session" A..= unSessionToken token
|
||||
, "csrf" A..= unCsrfToken csrf
|
||||
]
|
||||
|
||||
fixtureHttpConfig :: T.Text -> HttpConfig
|
||||
fixtureHttpConfig jwtSecret = HttpConfig
|
||||
{ cfgListenHost = "127.0.0.1"
|
||||
, cfgListenPort = 8080
|
||||
, cfgTlsCertPath = ""
|
||||
, cfgTlsKeyPath = ""
|
||||
, cfgPublicBaseUrl = "https://nuthatch.invalid"
|
||||
, cfgJwtSecret = secret jwtSecret
|
||||
, cfgSessionHours = 1
|
||||
, cfgCookieName = "nuthatch_session"
|
||||
, cfgCsrfCookieName = "nuthatch_csrf"
|
||||
, cfgOidcTransactionCookieName = "nuthatch_oidc"
|
||||
}
|
||||
Loading…
Reference in a new issue