test: move http header related tests from io tests to spec tests
Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
This commit is contained in:
committed by
Steve Chavez
parent
8fa26ee865
commit
b6c12abf0e
@@ -0,0 +1,34 @@
|
||||
module Feature.HttpHeaderSpec where
|
||||
|
||||
import Network.HTTP.Types
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai
|
||||
|
||||
import PostgREST.Config (AppConfig (..))
|
||||
import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..))
|
||||
|
||||
import Protolude
|
||||
import SpecHelper
|
||||
|
||||
spec :: SpecWithConfig
|
||||
spec withConfig = do
|
||||
withConfig baseCfg { configDbPreRequest = Just $ QualifiedIdentifier "test" "custom_vary_hdr" } $
|
||||
describe "Test HTTP Custom Header" $
|
||||
it "Test default Vary header value is overridden in pre-request database function" $
|
||||
request methodGet "/projects" []
|
||||
""
|
||||
`shouldRespondWith`
|
||||
ResponseMatcher
|
||||
{ matchStatus = 200
|
||||
, matchBody = MatchBody (\_ _ -> Nothing) -- match any body
|
||||
, matchHeaders = [ "Vary" <:> "X-Test-Accept" ] }
|
||||
|
||||
withConfig baseCfg $ describe "Test HTTP Default Header" $
|
||||
it "Test default Vary header value matches default one" $
|
||||
request methodGet "/projects" []
|
||||
""
|
||||
`shouldRespondWith`
|
||||
ResponseMatcher
|
||||
{ matchStatus = 200
|
||||
, matchBody = MatchBody (\_ _ -> Nothing) -- match any body
|
||||
, matchHeaders = [ "Vary" <:> "Accept, Prefer, Range" ] }
|
||||
@@ -29,6 +29,7 @@ import qualified Feature.Auth.NoJwtSecretSpec
|
||||
import qualified Feature.ConcurrentSpec
|
||||
import qualified Feature.CorsSpec
|
||||
import qualified Feature.ExtraSearchPathSpec
|
||||
import qualified Feature.HttpHeaderSpec
|
||||
import qualified Feature.NoSuperuserSpec
|
||||
import qualified Feature.ObservabilitySpec
|
||||
import qualified Feature.OpenApi.DisabledOpenApiSpec
|
||||
@@ -118,6 +119,7 @@ main = do
|
||||
, ("Feature.Auth.NoJwtSecretSpec" , Feature.Auth.NoJwtSecretSpec.spec)
|
||||
, ("Feature.ConcurrentSpec" , Feature.ConcurrentSpec.spec)
|
||||
, ("Feature.CorsSpec" , Feature.CorsSpec.spec)
|
||||
, ("Feature.HttpHeaderSpec" , Feature.HttpHeaderSpec.spec)
|
||||
, ("Feature.NoSuperuserSpec" , Feature.NoSuperuserSpec.spec)
|
||||
, ("Feature.ObservabilitySpec" , Feature.ObservabilitySpec.spec)
|
||||
, ("Feature.OpenApi.DisabledOpenApiSpec" , Feature.OpenApi.DisabledOpenApiSpec.spec)
|
||||
|
||||
Vendored
+7
@@ -3870,3 +3870,10 @@ create table visits (
|
||||
end_time timestamp,
|
||||
visit_type visit_type
|
||||
);
|
||||
|
||||
|
||||
create or replace function custom_vary_hdr() returns void as $$
|
||||
begin
|
||||
perform set_config('response.headers', '[{"Vary": "X-Test-Accept"}]', false);
|
||||
end
|
||||
$$ language plpgsql;
|
||||
|
||||
Reference in New Issue
Block a user