-
Notifications
You must be signed in to change notification settings - Fork 332
Documentation for Federation Test Cases #2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b864788
7b354aa
12952b7
c0bdcfc
8dc5214
8a877a1
98fcc0d
9091c87
002ea71
332f11c
c6e087e
e5ad3ec
7142265
aac8ea0
7cfd78a
5553dd5
d3a58b6
1b765ac
acfd896
f205a21
1e528da
df8e175
bf29e7a
6546951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Tag integration tests for security audit. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,8 +39,11 @@ import Wire.API.Federation.Domain | |||||
| import Wire.API.User | ||||||
|
|
||||||
| -- FUTUREWORK(federation): move these tests to brig-integration (benefit: avoid duplicating all of the brig helper code) | ||||||
| -- FUTUREWORK(fisx): better yet, reorganize integration tests (or at least the helpers) so | ||||||
| -- they don't spread out over the different sevices. | ||||||
|
|
||||||
| -- | Path covered by this test | ||||||
| -- | This module contains tests for the interface between federator and brig. The tests call | ||||||
| -- federator directly, circumnventing ingress: | ||||||
| -- | ||||||
| -- +----------+ | ||||||
| -- |federator-| +------+--+ | ||||||
|
|
@@ -72,6 +75,14 @@ spec env = | |||||
| <!! const 200 === statusCode | ||||||
| liftIO $ bdy `shouldBe` expectedProfile | ||||||
|
|
||||||
| -- @SF.Federation @TSFI.RESTfulAPI @S2 @S3 @S7 | ||||||
| -- | ||||||
| -- (This is tested in unit tests; search for | ||||||
| -- 'validateDomainCertInvalid' and 'testDiscoveryFailure'.) | ||||||
| it "shouldRejectMissmatchingOriginDomainInward" $ | ||||||
| runTestFederator env $ pure () | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not look thoroughly as to why, but just
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, you're almost right: this would be much better if |
||||||
| -- @END | ||||||
|
|
||||||
| it "should be able to call cargohold" $ | ||||||
| runTestFederator env $ do | ||||||
| inwardCall "/federation/cargohold/get-asset" (encode ()) | ||||||
|
|
@@ -98,9 +109,11 @@ spec env = | |||||
| inwardCall "/i/users" (encode o) | ||||||
| !!! const 403 === statusCode | ||||||
|
|
||||||
| -- Matching client certificates against domain names is better tested in | ||||||
| -- unit tests. | ||||||
| it "should reject requests without a client certificate" $ | ||||||
| -- @SF.Federation @TSFI.RESTfulAPI @S2 @S3 @S7 | ||||||
| -- | ||||||
| -- See related tests in unit tests (for matching client certificates against domain names) | ||||||
| -- and "IngressSpec". | ||||||
| it "rejectRequestsWithoutClientCertInward" $ | ||||||
| runTestFederator env $ do | ||||||
| originDomain <- cfgOriginDomain <$> view teTstOpts | ||||||
| hdl <- randomHandle | ||||||
|
|
@@ -110,6 +123,10 @@ spec env = | |||||
| (encode hdl) | ||||||
| !!! const 403 === statusCode | ||||||
|
|
||||||
| -- TODO: ORMOLU_DISABLE | ||||||
| -- @END | ||||||
| -- ORMOLU_ENABLE | ||||||
|
|
||||||
| inwardCallWithHeaders :: | ||||||
| (MonadIO m, MonadHttp m, MonadReader TestEnv m, HasCallStack) => | ||||||
| ByteString -> | ||||||
|
|
@@ -132,15 +149,24 @@ inwardCall :: | |||||
| LBS.ByteString -> | ||||||
| m (Response (Maybe LByteString)) | ||||||
| inwardCall requestPath payload = do | ||||||
| originDomain :: Text <- cfgOriginDomain <$> view teTstOpts | ||||||
| inwardCallWithOriginDomain (toByteString' originDomain) requestPath payload | ||||||
|
|
||||||
| inwardCallWithOriginDomain :: | ||||||
| (MonadIO m, MonadHttp m, MonadReader TestEnv m, HasCallStack) => | ||||||
| ByteString -> | ||||||
| ByteString -> | ||||||
| LBS.ByteString -> | ||||||
| m (Response (Maybe LByteString)) | ||||||
| inwardCallWithOriginDomain originDomain requestPath payload = do | ||||||
| Endpoint fedHost fedPort <- cfgFederatorExternal <$> view teTstOpts | ||||||
| originDomain <- cfgOriginDomain <$> view teTstOpts | ||||||
| clientCertFilename <- clientCertificate . optSettings . view teOpts <$> ask | ||||||
| clientCert <- liftIO $ BS.readFile clientCertFilename | ||||||
| post | ||||||
| ( host (encodeUtf8 fedHost) | ||||||
| . port fedPort | ||||||
| . path requestPath | ||||||
| . header "X-SSL-Certificate" (HTTP.urlEncode True clientCert) | ||||||
| . header originDomainHeaderName (toByteString' originDomain) | ||||||
| . header originDomainHeaderName originDomain | ||||||
| . bytes (toByteString' payload) | ||||||
| ) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum, why isn't this generated? (just wondering, please don't do anything about this in this PR :))
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to document the federation errors at the beginning of this Swagger document and then any endpoint that can throw a federation error can throw one of these. This is to avoid repeating the lengthy enumeration of federation errors over and over again at every endpoint that can throw it.