Skip to content

Commit

Permalink
Fix running tests with tls-2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marinelli committed Dec 15, 2024
1 parent c982be2 commit 7de4e96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions http-client-tls/http-client-tls.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ test-suite spec
, http-client-tls
, http-types
, crypton-connection
, data-default
, tls

benchmark benchmark
main-is: Bench.hs
Expand Down
21 changes: 18 additions & 3 deletions http-client-tls/test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
import Test.Hspec
import Network.Connection
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import Network.HTTP.Client.TLS hiding (tlsManagerSettings)
import Network.HTTP.Types
import Control.Monad (join)
import Data.Default
import qualified Network.TLS as TLS

main :: IO ()
main = hspec $ do
let tlsSettings = def
-- We have this becuase since the relases of the `tls` package 2.0.0,
-- the default value for the supportedExtendedMainSecret is `RequireEMS`,
-- that is required for every server speaking the TLS 1.2 protocol.
-- The badssl.com does not yet support TLS 1.2 with EMS, so what we could do,
-- for now, is to switch back to `AllowEMS`.
#if MIN_VERSION_crypton_connection(0,4,0)
{settingClientSupported = def {TLS.supportedExtendedMainSecret = TLS.AllowEMS}}
#endif

let tlsManagerSettings = mkManagerSettings tlsSettings Nothing

it "make a TLS connection" $ do
manager <- newManager tlsManagerSettings
withResponse "https://httpbin.org/status/418" manager $ \res ->
Expand Down Expand Up @@ -52,13 +67,13 @@ main = hspec $ do
-- https://github.com/snoyberg/http-client/issues/289
it "accepts TLS settings" $ do
let
tlsSettings = TLSSettingsSimple
tlsSettings' = tlsSettings
{ settingDisableCertificateValidation = True
, settingDisableSession = False
, settingUseServerName = False
}
socketSettings = Nothing
managerSettings = mkManagerSettings tlsSettings socketSettings
managerSettings = mkManagerSettings tlsSettings' socketSettings
manager <- newTlsManagerWith managerSettings
let url = "https://wrong.host.badssl.com"
request <- parseRequest url
Expand Down

0 comments on commit 7de4e96

Please sign in to comment.