module Test.FeatureFlags.EnforceFileDownloadLocation where import qualified API.GalleyInternal as Internal import SetupHelpers import Test.FeatureFlags.Util import Testlib.Prelude testPatchEnforceFileDownloadLocation :: (HasCallStack) => FeatureTable -> App () testPatchEnforceFileDownloadLocation :: HasCallStack => FeatureTable -> App () testPatchEnforceFileDownloadLocation FeatureTable table = do FeatureTable -> Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table Domain OwnDomain String "enforceFileDownloadLocation" (Value -> App ()) -> Value -> App () forall a b. (a -> b) -> a -> b $ [Pair] -> Value object [String "lockStatus" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "unlocked"] FeatureTable -> Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table Domain OwnDomain String "enforceFileDownloadLocation" (Value -> App ()) -> Value -> App () forall a b. (a -> b) -> a -> b $ [Pair] -> Value object [String "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "enabled"] FeatureTable -> Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table Domain OwnDomain String "enforceFileDownloadLocation" (Value -> App ()) -> Value -> App () forall a b. (a -> b) -> a -> b $ [Pair] -> Value object [String "lockStatus" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "unlocked", String "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "enabled"] FeatureTable -> Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table Domain OwnDomain String "enforceFileDownloadLocation" (Value -> App ()) -> Value -> App () forall a b. (a -> b) -> a -> b $ [Pair] -> Value object [String "lockStatus" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "locked", String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object []] FeatureTable -> Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table Domain OwnDomain String "enforceFileDownloadLocation" (Value -> App ()) -> Value -> App () forall a b. (a -> b) -> a -> b $ [Pair] -> Value object [String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [String "enforcedDownloadLocation" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "/tmp"]] do (Value user, String tid, [Value] _) <- Domain -> Int -> App (Value, String, [Value]) forall domain. (HasCallStack, MakesValue domain) => domain -> Int -> App (Value, String, [Value]) createTeam Domain OwnDomain Int 0 Domain -> String -> FeatureTable -> App () forall domain. (HasCallStack, MakesValue domain) => domain -> String -> FeatureTable -> App () updateMigrationState Domain OwnDomain String tid FeatureTable table App Response -> (Response -> App ()) -> App () forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse ( Value -> String -> String -> Value -> App Response forall domain team. (HasCallStack, MakesValue domain, MakesValue team) => domain -> team -> String -> Value -> App Response Internal.patchTeamFeature Value user String tid String "enforceFileDownloadLocation" ([Pair] -> Value object [String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [String "enforcedDownloadLocation" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String ""]]) ) ((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 400 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 "empty-download-location" testEnforceDownloadLocation :: (HasCallStack) => FeatureTable -> APIAccess -> App () testEnforceDownloadLocation :: HasCallStack => FeatureTable -> APIAccess -> App () testEnforceDownloadLocation FeatureTable table APIAccess access = do String -> FeatureTests mkFeatureTests String "enforceFileDownloadLocation" FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addUpdate ( [Pair] -> Value object [ String "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "enabled", String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [String "enforcedDownloadLocation" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "/tmp"] ] ) FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addUpdate ([Pair] -> Value object [String "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "disabled", String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object []]) FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addInvalidUpdate ( [Pair] -> Value object [ String "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "enabled", String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [ String "enforcedDownloadLocation" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [] ] ] ) FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & FeatureTable -> FeatureTests -> FeatureTests setTable FeatureTable table FeatureTests -> (FeatureTests -> App ()) -> App () forall a b. a -> (a -> b) -> b & Domain -> APIAccess -> FeatureTests -> App () forall domain. (HasCallStack, MakesValue domain) => domain -> APIAccess -> FeatureTests -> App () runFeatureTests Domain OwnDomain APIAccess access