Skip to content

Commit

Permalink
Assert expected server config
Browse files Browse the repository at this point in the history
... to guard against accidental change.
  • Loading branch information
supersven committed Dec 23, 2024
1 parent 64193e7 commit 542bcc6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions integration/test/Test/LegalHold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ testLHPreventAddingNonConsentingUsers v = do
mems `shouldMatchSet` forM us (\m -> m %. "qualified_id")

testLHGetAndUpdateSettings :: (HasCallStack) => ImplicitConsent -> LhApiVersion -> App ()
testLHGetAndUpdateSettings implicitConsent v = setLHFeatureConfigForServer implicitConsent $ \dom -> do
testLHGetAndUpdateSettings implicitConsent v = ensureLHFeatureConfigForServer implicitConsent $ \dom -> do
withMockServer def (lhMockAppV v) $ \lhDomAndPort _chan -> do
(owner, tid, [alice]) <- createTeam dom 2
stranger <- randomUser dom def
Expand Down Expand Up @@ -1120,13 +1120,16 @@ testNoCommonVersion = do
data ImplicitConsent = ImplicitConsent | ExplicitConsent
deriving (Eq, Show, Generic)

setLHFeatureConfigForServer :: ImplicitConsent -> (String {- domain -} -> App ()) -> App ()
setLHFeatureConfigForServer ImplicitConsent app =
-- we could do `setField "settings.featureFlags.legalhold"
-- "whitelist-teams-and-implicit-consent"`, but this is already the default.
-- TODO: make this an assertion, not a comment!
-- | Ensure that the LH config is as expected: Either by expecting it from the
-- current server's config. Or, by creating a new one.
ensureLHFeatureConfigForServer :: ImplicitConsent -> (String {- domain -} -> App ()) -> App ()
ensureLHFeatureConfigForServer ImplicitConsent app = do
-- This should be set in the server's config file. Thus, we only assert here
-- (to guard against accidential change.)
cfg <- readServiceConfig Galley
(cfg %. "settings.featureFlags.legalhold") `shouldMatch` "whitelist-teams-and-implicit-consent"
app =<< asString OwnDomain
setLHFeatureConfigForServer ExplicitConsent app =
ensureLHFeatureConfigForServer ExplicitConsent app =
withModifiedBackend (def {galleyCfg = upd}) app
where
upd = setField "settings.featureFlags.legalhold" "disabled-by-default"

0 comments on commit 542bcc6

Please sign in to comment.