{-# OPTIONS -Wno-ambiguous-fields #-} module Test.Apps where import API.Brig import SetupHelpers import Testlib.Prelude testCreateApp :: (HasCallStack) => App () testCreateApp :: HasCallStack => App () testCreateApp = do (Value alice, String tid, [Value bob]) <- Domain -> Int -> App (Value, String, [Value]) forall domain. (HasCallStack, MakesValue domain) => domain -> Int -> App (Value, String, [Value]) createTeam Domain OwnDomain Int 2 let new :: NewApp new = NewApp forall a. Default a => a def {name = "chappie"} :: NewApp App Response -> (Response -> App ()) -> App () forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Value -> String -> NewApp -> App Response forall creator. MakesValue creator => creator -> String -> NewApp -> App Response createApp Value bob String tid NewApp new) ((Response -> App ()) -> App ()) -> (Response -> App ()) -> App () forall a b. (a -> b) -> a -> b $ \Response resp -> do Response resp.status Int -> Int -> App () forall a. (MakesValue a, HasCallStack) => a -> Int -> App () `shouldMatchInt` Int 403 Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "label" App Value -> String -> App () forall a b. (MakesValue a, MakesValue b, HasCallStack) => a -> b -> App () `shouldMatch` String "create-app-no-permission" (String appId, String cookie) <- App Response -> (Response -> App (String, String)) -> App (String, String) forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Value -> String -> NewApp -> App Response forall creator. MakesValue creator => creator -> String -> NewApp -> App Response createApp Value alice String tid NewApp new) ((Response -> App (String, String)) -> App (String, String)) -> (Response -> App (String, String)) -> App (String, String) forall a b. (a -> b) -> a -> b $ \Response resp -> do Response resp.status Int -> Int -> App () forall a. (MakesValue a, HasCallStack) => a -> Int -> App () `shouldMatchInt` Int 200 String appId <- Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "user.id" App Value -> (App Value -> App String) -> App String forall a b. a -> (a -> b) -> b & App Value -> App String forall a. (HasCallStack, MakesValue a) => a -> App String asString String cookie <- Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "cookie" App Value -> (App Value -> App String) -> App String forall a b. a -> (a -> b) -> b & App Value -> App String forall a. (HasCallStack, MakesValue a) => a -> App String asString (String, String) -> App (String, String) forall a. a -> App a forall (f :: * -> *) a. Applicative f => a -> f a pure (String appId, String cookie) App String -> App () forall (f :: * -> *) a. Functor f => f a -> f () void (App String -> App ()) -> App String -> App () forall a b. (a -> b) -> a -> b $ App Response -> (Response -> App String) -> App String forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Domain -> String -> App Response forall uid. (HasCallStack, MakesValue uid) => uid -> String -> App Response renewToken Domain OwnDomain String cookie) ((Response -> App String) -> App String) -> (Response -> App String) -> App String forall a b. (a -> b) -> a -> b $ \Response resp -> do Response resp.status Int -> Int -> App () forall a. (MakesValue a, HasCallStack) => a -> Int -> App () `shouldMatchInt` Int 200 Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "user" App Value -> String -> App () forall a b. (MakesValue a, MakesValue b, HasCallStack) => a -> b -> App () `shouldMatch` String appId Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "token_type" App Value -> String -> App () forall a b. (MakesValue a, MakesValue b, HasCallStack) => a -> b -> App () `shouldMatch` String "Bearer" Response resp.json App Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "access_token" App Value -> (App Value -> App String) -> App String forall a b. a -> (a -> b) -> b & App Value -> App String forall a. (HasCallStack, MakesValue a) => a -> App String asString