Skip to content

Commit

Permalink
Merge pull request #185 from well-typed/finley/fix-tests-on-mac
Browse files Browse the repository at this point in the history
Explicitly use `127.0.0.1` in test suite where appropriate
  • Loading branch information
edsko authored Jul 11, 2024
2 parents 978cba0 + 5a05d57 commit eab96f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
20 changes: 4 additions & 16 deletions test-grapesy/Test/Driver/ClientServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ data TlsFail =
-- self signed.
TlsFailValidation

-- | Client uses the wrong address (@localhost@ instead of @127.0.0.1@)
--
-- This too will result in a TLS failure (hostname mismatch). To ensure we
-- get the TLS failure we expect, we /do/ add the server's certificate to
-- the client's trusted certs.
| TlsFailHostname

-- | The server is not configured for TLS
| TlsFailUnsupported

Expand Down Expand Up @@ -323,7 +316,6 @@ isExpectedTLSException :: ClientServerConfig -> TLSException -> Bool
isExpectedTLSException cfg tls =
case (useTLS cfg, tls) of
(Just (TlsFail TlsFailValidation) , HandshakeFailed _) -> True
(Just (TlsFail TlsFailHostname) , HandshakeFailed _) -> True
(Just (TlsFail TlsFailUnsupported) , HandshakeFailed _) -> True
_otherwise -> False

Expand Down Expand Up @@ -449,14 +441,14 @@ withTestServer cfg firstTestFailure handlerLock serverHandlers k = do
case useTLS cfg of
Nothing -> Server.ServerConfig {
serverInsecure = Just Server.InsecureConfig {
insecureHost = Nothing
insecureHost = Just "127.0.0.1"
, insecurePort = serverPort cfg
}
, serverSecure = Nothing
}
Just (TlsFail TlsFailUnsupported) -> Server.ServerConfig {
serverInsecure = Just Server.InsecureConfig {
insecureHost = Nothing
insecureHost = Just "127.0.0.1"
, insecurePort = serverPort cfg
}
, serverSecure = Nothing
Expand Down Expand Up @@ -558,8 +550,6 @@ runTestClient cfg firstTestFailure port clientRun = do
Client.NoServerValidation
TlsFail TlsFailValidation ->
Client.ValidateServer mempty
TlsFail TlsFailHostname ->
correctClientSetup
TlsFail TlsFailUnsupported ->
correctClientSetup
)
Expand All @@ -581,10 +571,8 @@ runTestClient cfg firstTestFailure port clientRun = do
clientAuthority :: Client.Address
clientAuthority =
case useTLS cfg of
Just tlsSetup -> Client.Address {
addressHost = case tlsSetup of
TlsFail TlsFailHostname -> "localhost"
_otherwise -> "127.0.0.1"
Just _tlsSetup -> Client.Address {
addressHost = "127.0.0.1"
, addressPort = port
, addressAuthority = Nothing
}
Expand Down
4 changes: 0 additions & 4 deletions test-grapesy/Test/Sanity/StreamingType/NonStreaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ tests = testGroup "Test.Sanity.StreamingType.NonStreaming" [
test_increment def {
useTLS = Just $ TlsFail TlsFailValidation
}
, testCase "hostname" $
test_increment def {
useTLS = Just $ TlsFail TlsFailHostname
}
, testCase "unsupported" $
test_increment def {
useTLS = Just $ TlsFail TlsFailUnsupported
Expand Down

0 comments on commit eab96f5

Please sign in to comment.