Previously, information about each test-suite was repeated in 3 separate places: - as a label and as implicit knowledge in the test-suite itself, - as a comment in Main.hs, and - as a configuration in SpecHelper.hs. With this change, there will be a single source of truth in the test suite itself. This will allow a single test-suite to easily test multiple different configurations.
25 lines
846 B
Haskell
25 lines
846 B
Haskell
module Feature.Auth.BinaryJwtSecretSpec where
|
|
|
|
import Network.HTTP.Types
|
|
import Test.Hspec
|
|
import Test.Hspec.Wai
|
|
|
|
import PostgREST.Config (AppConfig (..), parseSecret)
|
|
|
|
import Protolude
|
|
import SpecHelper
|
|
|
|
spec :: SpecWithConfig
|
|
spec withConfig = withConfig (
|
|
baseCfg {
|
|
configJwtSecret = Just generateSecret
|
|
, configJWKS = rightToMaybe $ parseSecret generateSecret
|
|
}
|
|
) $ describe "server started with binary JWT secret" $
|
|
|
|
-- this test will stop working 9999999999s after the UNIX EPOCH
|
|
it "succeeds with jwt token encoded with a binary secret" $ do
|
|
let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjk5OTk5OTk5OTksInJvbGUiOiJwb3N0Z3Jlc3RfdGVzdF9hdXRob3IiLCJpZCI6Impkb2UifQ.Dpss-QoLYjec5OTsOaAc3FNVsSjA89wACoV-0ra3ClA"
|
|
request methodGet "/authors_only" [auth] ""
|
|
`shouldRespondWith` 200
|