Skip to content

Commit

Permalink
Include headers in a federator unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti authored and mdimjasevic committed Jan 4, 2024
1 parent 5fb22c2 commit 841245a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions services/federator/test/unit/Test/Federator/ExternalServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@ mockService status = interpret $ \case
requestBrigSuccess :: TestTree
requestBrigSuccess =
testCase "should forward response from brig when status is 200" $ do
request <-
request0 <-
exampleRequest
"test/resources/unit/localhost.example.com.pem"
"/federation/brig/get-user-by-handle"
let request =
request0
{ Wai.requestHeaders =
("Invalid-Header", "foo")
: ("X-Wire-API-Version", "v0")
: Wai.requestHeaders request0
}
Right cert <- decodeCertificate <$> BS.readFile "test/resources/unit/localhost.example.com.pem"

let assertMetrics :: Member (Embed IO) r => Sem (Metrics ': r) a -> Sem r a
Expand All @@ -140,7 +147,7 @@ requestBrigSuccess =
. runInputConst noClientCertSettings
. runInputConst scaffoldingFederationDomainConfigs
$ callInward Brig (RPC "get-user-by-handle") Nothing aValidDomain (CertHeader cert) request
let expectedCall = Call Brig "/federation/get-user-by-handle" [] "\"foo\"" aValidDomain
let expectedCall = Call Brig "/federation/get-user-by-handle" [("X-Wire-API-Version", "v0")] "\"foo\"" aValidDomain
assertEqual "one call to brig should be made" [expectedCall] actualCalls
Wai.responseStatus res @?= HTTP.status200
body <- Wai.lazyResponseBody res
Expand Down

0 comments on commit 841245a

Please sign in to comment.