Upgrade hspec-wai dependency to 0.10.
This commit is contained in:
committed by
Steve Chavez
parent
962fba4d16
commit
60b64d3e81
@@ -11,7 +11,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion =
|
||||
describe "and/or params used for complex boolean logic" $ do
|
||||
context "used with GET" $ do
|
||||
|
||||
@@ -11,7 +11,7 @@ import Protolude
|
||||
import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "server started with asymmetric JWK" $
|
||||
|
||||
-- this test will stop working 9999999999s after the UNIX EPOCH
|
||||
|
||||
@@ -11,7 +11,7 @@ import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "test handling of aud claims in JWT" $ do
|
||||
|
||||
-- this test will stop working 9999999999s after the UNIX EPOCH
|
||||
|
||||
@@ -12,7 +12,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion = describe "authorization" $ do
|
||||
let single = ("Accept","application/vnd.pgrst.object+json")
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import Protolude
|
||||
import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "server started with binary JWT secret" $
|
||||
|
||||
-- this test will stop working 9999999999s after the UNIX EPOCH
|
||||
|
||||
@@ -19,7 +19,7 @@ import Test.Hspec.Wai.JSON
|
||||
|
||||
import Protolude hiding (get)
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Queryiny in parallel" $
|
||||
it "should not raise 'transaction in progress' error" $
|
||||
@@ -35,13 +35,13 @@ spec =
|
||||
, matchHeaders = []
|
||||
}
|
||||
|
||||
raceTest :: Int -> WaiExpectation -> WaiExpectation
|
||||
raceTest :: Int -> WaiExpectation st -> WaiExpectation st
|
||||
raceTest times = liftBaseDiscard go
|
||||
where
|
||||
go test = void $ mapConcurrently (const test) [1..times]
|
||||
|
||||
instance MonadBaseControl IO WaiSession where
|
||||
type StM WaiSession a = StM Session a
|
||||
instance MonadBaseControl IO (WaiSession st) where
|
||||
type StM (WaiSession st) a = StM Session a
|
||||
liftBaseWith f = WaiSession $
|
||||
liftBaseWith $ \runInBase ->
|
||||
f $ \k -> runInBase (unWaiSession k)
|
||||
@@ -49,5 +49,5 @@ instance MonadBaseControl IO WaiSession where
|
||||
{-# INLINE liftBaseWith #-}
|
||||
{-# INLINE restoreM #-}
|
||||
|
||||
instance MonadBase IO WaiSession where
|
||||
instance MonadBase IO (WaiSession st) where
|
||||
liftBase = liftIO
|
||||
|
||||
@@ -14,7 +14,7 @@ import Protolude
|
||||
import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "CORS" $ do
|
||||
let preflightHeaders = [
|
||||
|
||||
@@ -10,7 +10,7 @@ import Text.Heredoc
|
||||
|
||||
import Protolude hiding (get)
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Deleting" $ do
|
||||
context "existing record" $ do
|
||||
|
||||
@@ -10,7 +10,7 @@ import Text.Heredoc
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "resource embedding disambiguation" $ do
|
||||
context "ambiguous requests that give 300 Multiple Choices" $ do
|
||||
|
||||
@@ -9,7 +9,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "extra search path" $ do
|
||||
|
||||
it "finds the ltree <@ operator on the public schema" $
|
||||
|
||||
@@ -10,7 +10,7 @@ import Text.Heredoc
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper (acceptHdrs)
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "When raw-media-types is set to \"text/html\"" $
|
||||
it "can get raw output with Accept: text/html" $
|
||||
request methodGet "/rpc/welcome.html" (acceptHdrs "text/html") ""
|
||||
|
||||
@@ -20,7 +20,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion = do
|
||||
describe "Posting new record" $ do
|
||||
context "disparate json types" $ do
|
||||
|
||||
@@ -11,7 +11,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion = describe "json and jsonb operators" $ do
|
||||
context "Shaping response with select parameter" $ do
|
||||
it "obtains a json subfield one level with casting" $
|
||||
|
||||
@@ -13,7 +13,7 @@ import Protolude
|
||||
import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "server started without JWT secret" $ do
|
||||
|
||||
-- this test will stop working 9999999999s after the UNIX EPOCH
|
||||
|
||||
@@ -7,7 +7,7 @@ import Test.Hspec.Wai
|
||||
|
||||
import Protolude hiding (get)
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Non existent api schema" $ do
|
||||
it "succeeds when requesting root path" $
|
||||
|
||||
@@ -9,7 +9,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "features supported on PostgreSQL 9.5" $
|
||||
context "json array negative index" $ do
|
||||
it "can select with negative indexes" $ do
|
||||
|
||||
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "features supported on PostgreSQL 9.6" $ do
|
||||
context "GUC headers on function calls" $ do
|
||||
|
||||
@@ -6,7 +6,7 @@ import Test.Hspec hiding (pendingWith)
|
||||
import Protolude
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "GET / with proxy" $
|
||||
it "returns a valid openapi spec with proxy" $
|
||||
|
||||
@@ -11,7 +11,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Requesting many items with server limits(max-rows) enabled" $ do
|
||||
it "restricts results" $
|
||||
|
||||
@@ -14,7 +14,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion = do
|
||||
|
||||
describe "Querying a table with a column called count" $
|
||||
|
||||
@@ -19,7 +19,7 @@ defaultRange = [json| { "min": 0, "max": 15 } |]
|
||||
emptyRange :: BL.ByteString
|
||||
emptyRange = [json| { "min": 2, "max": 2 } |]
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = do
|
||||
describe "POST /rpc/getitemrange" $ do
|
||||
context "without range headers" $ do
|
||||
|
||||
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude
|
||||
import SpecHelper (acceptHdrs)
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = describe "When raw-media-types config variable is missing or left empty" $ do
|
||||
let firefoxAcceptHdrs = acceptHdrs "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
|
||||
chromeAcceptHdrs = acceptHdrs "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"
|
||||
|
||||
@@ -11,7 +11,7 @@ import Protolude hiding (get)
|
||||
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "root spec function" $ do
|
||||
it "accepts application/openapi+json" $
|
||||
|
||||
@@ -17,7 +17,7 @@ import PostgREST.Types (PgVersion, pgVersion100, pgVersion109,
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: PgVersion -> SpecWith Application
|
||||
spec :: PgVersion -> SpecWith ((), Application)
|
||||
spec actualPgVersion =
|
||||
describe "remote procedure call" $ do
|
||||
context "a proc that returns a set" $ do
|
||||
|
||||
@@ -13,7 +13,7 @@ import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Requesting singular json object" $ do
|
||||
let pgrstObj = "application/vnd.pgrst.object+json"
|
||||
|
||||
@@ -17,7 +17,7 @@ import PostgREST.Config (docsVersion)
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec = do
|
||||
|
||||
describe "OpenAPI" $ do
|
||||
|
||||
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
|
||||
import Protolude hiding (get)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "Reading and writing to unicode schema and table names" $
|
||||
it "Can read and write values" $ do
|
||||
|
||||
@@ -11,7 +11,7 @@ import Text.Heredoc
|
||||
import Protolude hiding (get, put)
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWith Application
|
||||
spec :: SpecWith ((), Application)
|
||||
spec =
|
||||
describe "UPSERT" $ do
|
||||
context "with POST" $ do
|
||||
|
||||
+16
-14
@@ -65,20 +65,22 @@ main = do
|
||||
|
||||
refDbStructure <- newIORef $ Just dbStructure
|
||||
|
||||
let withApp = return $ postgrest (testCfg testDbConn) refDbStructure pool getTime $ pure ()
|
||||
maxRowsApp = return $ postgrest (testMaxRowsCfg testDbConn) refDbStructure pool getTime $ pure ()
|
||||
unicodeApp = return $ postgrest (testUnicodeCfg testDbConn) refDbStructure pool getTime $ pure ()
|
||||
proxyApp = return $ postgrest (testProxyCfg testDbConn) refDbStructure pool getTime $ pure ()
|
||||
noJwtApp = return $ postgrest (testCfgNoJWT testDbConn) refDbStructure pool getTime $ pure ()
|
||||
binaryJwtApp = return $ postgrest (testCfgBinaryJWT testDbConn) refDbStructure pool getTime $ pure ()
|
||||
audJwtApp = return $ postgrest (testCfgAudienceJWT testDbConn) refDbStructure pool getTime $ pure ()
|
||||
asymJwkApp = return $ postgrest (testCfgAsymJWK testDbConn) refDbStructure pool getTime $ pure ()
|
||||
asymJwkSetApp = return $ postgrest (testCfgAsymJWKSet testDbConn) refDbStructure pool getTime $ pure ()
|
||||
nonexistentSchemaApp = return $ postgrest (testNonexistentSchemaCfg testDbConn) refDbStructure pool getTime $ pure ()
|
||||
extraSearchPathApp = return $ postgrest (testCfgExtraSearchPath testDbConn) refDbStructure pool getTime $ pure ()
|
||||
rootSpecApp = return $ postgrest (testCfgRootSpec testDbConn) refDbStructure pool getTime $ pure ()
|
||||
htmlRawOutputApp = return $ postgrest (testCfgHtmlRawOutput testDbConn) refDbStructure pool getTime $ pure ()
|
||||
responseHeadersApp = return $ postgrest (testCfgResponseHeaders testDbConn) refDbStructure pool getTime $ pure ()
|
||||
let app cfg = return ((), postgrest (cfg testDbConn) refDbStructure pool getTime $ pure ())
|
||||
|
||||
let withApp = app testCfg
|
||||
maxRowsApp = app testMaxRowsCfg
|
||||
unicodeApp = app testUnicodeCfg
|
||||
proxyApp = app testProxyCfg
|
||||
noJwtApp = app testCfgNoJWT
|
||||
binaryJwtApp = app testCfgBinaryJWT
|
||||
audJwtApp = app testCfgAudienceJWT
|
||||
asymJwkApp = app testCfgAsymJWK
|
||||
asymJwkSetApp = app testCfgAsymJWKSet
|
||||
nonexistentSchemaApp = app testNonexistentSchemaCfg
|
||||
extraSearchPathApp = app testCfgExtraSearchPath
|
||||
rootSpecApp = app testCfgRootSpec
|
||||
htmlRawOutputApp = app testCfgHtmlRawOutput
|
||||
responseHeadersApp = app testCfgResponseHeaders
|
||||
|
||||
let reset, analyze :: IO ()
|
||||
reset = resetDb testDbConn
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"
|
||||
matchContentTypeSingular :: MatchHeader
|
||||
matchContentTypeSingular = "Content-Type" <:> "application/vnd.pgrst.object+json; charset=utf-8"
|
||||
|
||||
validateOpenApiResponse :: [Header] -> WaiSession ()
|
||||
validateOpenApiResponse :: [Header] -> WaiSession () ()
|
||||
validateOpenApiResponse headers = do
|
||||
r <- request methodGet "/" headers ""
|
||||
liftIO $
|
||||
|
||||
Reference in New Issue
Block a user