Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Reduce duplication of mock https servers in integration tests.

Open
#812 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell
Domain
testing

Research direction

Start with the duplicated server helpers in services/brig/test/integration/API/Provider.hs and services/galley/test/integration/API/Teams/LegalHold.hs, then run git grep -Hn runTLS to confirm the remaining instances. Compare the available bilge and wai-utilities locations with the shown withMockIdP variant. Done means a shared implementation replaces the listed helpers and the integration tests still pass.

Written by the indexing model from the issue text.

Description

good first issue help wanted

There are a number of functions that create https servers for integration tests:

The following variant has more sophisticated error reporting, but it has been introduced in spar and then removed in the same PR, so it's gone from the code for now:

-- | Copied from galley's 'withTestService'
--
-- FUTUREWORK: use 'asyncWithBound' (that requires the test case to run in IO, though, or some
-- 'unliftIO' magic.)
--
-- The https server may take a few miliseconds (or, depending on your test setup, longer)
-- before it is available.  To accomodate for this, the test will be run several times if it
-- throws an exception, and only after a few re-tries, the latest exception will be thrown.
withMockIdP
    :: (HasCallStack)
    => (Chan e -> Application)  -- ^ the mock service
    -> (Chan e -> TestSpar a)   -- ^ the test
    -> TestSpar a
withMockIdP createApp go = do
    config <- view teMockIdP
    let tlss = Warp.tlsSettings (cert config) (privateKey config)
    let defs = Warp.defaultSettings { Warp.settingsPort = botPort config }
    buf <- liftIO newChan
    srv <- liftIO . Async.async $
        Warp.runTLS tlss defs $
            createApp buf
    patiently (reportIfServerDied srv >> go buf) `finally` liftIO (Async.cancel srv)
  where
    reportIfServerDied :: Async.Async () -> TestSpar ()
    reportIfServerDied srv = liftIO (Async.poll srv >>= maybe (pure ()) print)

    patiently :: TestSpar a -> TestSpar a
    patiently = recovering policy continue . const
      where
        policy = limitRetries 3 <> exponentialBackoff 100000
        continue = [\_ -> Control.Monad.Catch.Handler (\(SomeException _) -> pure True)]

Tasks:

  • provide a variant of withMockIdP from some library (bilge? wai-utilities?)
  • use that implementation instead of the ones listed above.
Dominant language
Haskell
Stars
2.8k
Forks
332
Avg merge
3d 7h
Merged PRs (30d)
49

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wireapp/wire-server

All issues in wireapp/wire-server

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.