module Test.License where
import API.Galley
import SetupHelpers
import Test.Meetings (withLicensedBackend, withLicensedBackendFlags)
import Testlib.Prelude
assertMeetingsFlags :: (HasCallStack, MakesValue resp) => resp -> [(String, Bool)] -> App ()
assertMeetingsFlags :: forall resp.
(HasCallStack, MakesValue resp) =>
resp -> [(String, Bool)] -> App ()
assertMeetingsFlags resp
resp [(String, Bool)]
flags =
[(String, Bool)] -> ((String, Bool) -> App ()) -> App ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(String, Bool)]
flags (((String, Bool) -> App ()) -> App ())
-> ((String, Bool) -> App ()) -> App ()
forall a b. (a -> b) -> a -> b
$ \(String
flag, Bool
expected) -> do
v <- resp
resp resp -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. (String
"meetings." String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
flag)
asBool v >>= (`shouldMatch` expected)
testLicense :: (HasCallStack) => App ()
testLicense :: HasCallStack => App ()
testLicense = do
(owner, _, _) <- Domain -> Int -> App (Value, String, [Value])
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> Int -> App (Value, String, [Value])
createTeam Domain
OwnDomain Int
1
resp <- getLicense owner >>= getJSON 200
assertMeetingsFlags
resp
[("invitation_links", False), ("emails_sending", False), ("calendars_integration", False)]
withLicensedBackend $ \String
dom -> do
(ownerL, _, _) <- String -> Int -> App (Value, String, [Value])
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> Int -> App (Value, String, [Value])
createTeam String
dom Int
1
respL <- getLicense ownerL >>= getJSON 200
assertMeetingsFlags
respL
[("invitation_links", True), ("emails_sending", True), ("calendars_integration", True)]
testLicenseMixedFlags :: (HasCallStack) => App ()
testLicenseMixedFlags :: HasCallStack => App ()
testLicenseMixedFlags =
Bool -> Bool -> Bool -> (String -> App ()) -> App ()
forall a.
HasCallStack =>
Bool -> Bool -> Bool -> (String -> App a) -> App a
withLicensedBackendFlags Bool
True Bool
False Bool
True ((String -> App ()) -> App ()) -> (String -> App ()) -> App ()
forall a b. (a -> b) -> a -> b
$ \String
dom -> do
(owner, _, _) <- String -> Int -> App (Value, String, [Value])
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> Int -> App (Value, String, [Value])
createTeam String
dom Int
1
resp <- getLicense owner >>= getJSON 200
assertMeetingsFlags
resp
[("invitation_links", True), ("emails_sending", False), ("calendars_integration", True)]