Skip to content

Commit

Permalink
Follow-up to /api-version changes (#2159)
Browse files Browse the repository at this point in the history
* Add test for additional api-version info

* Comment about /access having to be unversioned
  • Loading branch information
pcapriotti authored and fisx committed Mar 7, 2022
1 parent a7ba9a5 commit 63ec89f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/5-internal/api-version-endpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add tests for additional information returned by `GET /api-version`
2 changes: 2 additions & 0 deletions services/brig/src/Brig/User/API/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import Wire.Swagger as Doc (pendingLoginError)

routesPublic :: Routes Doc.ApiBuilder (Handler r) ()
routesPublic = do
-- Note: this endpoint should always remain available at its unversioned
-- path, since the login cookie hardcodes @/access@ as a path.
post "/access" (continue renewH) $
accept "application" "json"
.&. tokenRequest
Expand Down
18 changes: 15 additions & 3 deletions services/brig/test/integration/API/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ module API.Version (tests) where

import Bilge
import Bilge.Assert
import Brig.Options
import Imports
import qualified Network.Wai.Utilities.Error as Wai
import Test.Tasty
import Test.Tasty.HUnit
import Util
import Wire.API.Routes.Version

tests :: Manager -> Brig -> TestTree
tests p brig =
tests :: Manager -> Opts -> Brig -> TestTree
tests p opts brig =
testGroup
"version"
[ test p "GET /api-version" $ testVersion brig,
test p "GET /v1/api-version" $ testVersionV1 brig,
test p "GET /v500/api-version" $ testUnsupportedVersion brig
test p "GET /v500/api-version" $ testUnsupportedVersion brig,
test p "GET /api-version (federation info)" $ testFederationDomain opts brig
]

testVersion :: Brig -> Http ()
Expand All @@ -57,3 +59,13 @@ testUnsupportedVersion brig = do
responseJsonError =<< get (brig . path "/v500/api-version")
<!! const 404 === statusCode
liftIO $ Wai.label e @?= "unsupported-version"

testFederationDomain :: Opts -> Brig -> Http ()
testFederationDomain opts brig = do
let domain = setFederationDomain (optSettings opts)
vinfo <-
responseJsonError =<< get (brig . path "/api-version")
<!! const 200 === statusCode
liftIO $ do
vinfoFederation vinfo @?= True
vinfoDomain vinfo @?= domain
2 changes: 1 addition & 1 deletion services/brig/test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ runTests iConf brigOpts otherArgs = do
includeFederationTests <- (== Just "1") <$> Blank.getEnv "INTEGRATION_FEDERATION_TESTS"
internalApi <- API.Internal.tests brigOpts mg db b (brig iConf) gd g

let versionApi = API.Version.tests mg b
let versionApi = API.Version.tests mg brigOpts b

let mlsApi = MLS.tests mg b brigOpts

Expand Down

0 comments on commit 63ec89f

Please sign in to comment.