diff --git a/test/Network/Connection/CPP.hs b/test/Network/Connection/CPP.hs new file mode 100644 index 0000000..7efeb8e --- /dev/null +++ b/test/Network/Connection/CPP.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE CPP #-} + +{- | +Module : Network.Connection.CPP +Copyright : (c) 2022 Tim Emiola +Maintainer : Tim Emiola +SPDX-License-Identifier: BSD3 +-} +module Network.Connection.CPP (noCheckSettings) where + +import Network.Connection (TLSSettings (..)) + + +#if MIN_VERSION_crypton_connection(0,4,0) +import Data.Default (def) +#endif + +#if MIN_VERSION_crypton_connection(0,4,0) +noCheckSettings :: TLSSettings +noCheckSettings = TLSSettingsSimple True False False def +#else +noCheckSettings :: TLSSettings +noCheckSettings = TLSSettingsSimple True False False +#endif diff --git a/test/Test/Fetch.hs b/test/Test/Fetch.hs index 814887d..f1ce176 100644 --- a/test/Test/Fetch.hs +++ b/test/Test/Fetch.hs @@ -24,7 +24,7 @@ import Data.Conduit import qualified Data.Conduit.Binary as CB import Data.Int (Int64) import Data.Maybe (fromMaybe) -import Network.Connection (TLSSettings (..)) +import Network.Connection.CPP (noCheckSettings) import Network.HTTP.Client ( BodyReader , Request @@ -39,14 +39,13 @@ import Network.HTTP.Client , withResponse ) import Network.HTTP.Client.TLS (mkManagerSettings) --- import Network.HTTP.Simple (setRequestManager, withResponse) import Network.HTTP.Types (hContentLength, statusCode) import Test.HttpReply fetch :: Request -> IO HttpReply fetch req = do - let mSettings = mkManagerSettings (TLSSettingsSimple True False False) Nothing + let mSettings = mkManagerSettings noCheckSettings Nothing mSettings' = managerSetProxy proxyFromRequest mSettings m <- newManager mSettings' withResponse req m getSrc diff --git a/test/Test/NginxGateway.hs b/test/Test/NginxGateway.hs index 30f1f8d..9e4285d 100644 --- a/test/Test/NginxGateway.hs +++ b/test/Test/NginxGateway.hs @@ -30,7 +30,7 @@ import Data.List (find) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text -import Network.Connection (TLSSettings (..)) +import Network.Connection.CPP (noCheckSettings) import qualified Network.HTTP.Client as HC import qualified Network.HTTP.Client.TLS as HC import Network.HTTP.Types.Header (hHost) @@ -217,9 +217,8 @@ pingHttps handle = toPinged @HC.HttpException Proxy $ do -- that differs from the connection IP address, that's not supported by -- http-client-tls mkBadTlsManager :: IO HC.Manager -mkBadTlsManager = do - let tlsSettings = TLSSettingsSimple True False False - HC.newTlsManagerWith $ HC.mkManagerSettings tlsSettings Nothing +mkBadTlsManager = + HC.newTlsManagerWith $ HC.mkManagerSettings noCheckSettings Nothing -- | Determine the status from a secure Get to host localhost. diff --git a/wai-middleware-delegate.cabal b/wai-middleware-delegate.cabal index f78e142..63d0e57 100644 --- a/wai-middleware-delegate.cabal +++ b/wai-middleware-delegate.cabal @@ -64,6 +64,7 @@ test-suite integration-test Test.NginxGateway Test.TestRequests Test.WithExtras + Network.Connection.CPP hs-source-dirs: test build-depends: @@ -75,7 +76,7 @@ test-suite integration-test , case-insensitive , conduit , conduit-extra - , crypton-connection >=0.3.1 && < 0.4 + , crypton-connection >=0.3.1 && < 0.5 , data-default , directory >=1.3 && <1.4 , filepath >=1.4 && <1.6