module Test.FeatureFlags.Mls where import SetupHelpers import Test.FeatureFlags.Util import Testlib.Prelude testMls :: (HasCallStack) => FeatureTable -> APIAccess -> App () testMls :: HasCallStack => FeatureTable -> APIAccess -> App () testMls FeatureTable table APIAccess access = do Value user <- Domain -> CreateUser -> App Value forall domain. (HasCallStack, MakesValue domain) => domain -> CreateUser -> App Value randomUser Domain OwnDomain CreateUser forall a. Default a => a def String uid <- App Value -> App String forall a. (HasCallStack, MakesValue a) => a -> App String asString (App Value -> App String) -> App Value -> App String forall a b. (a -> b) -> a -> b $ Value user Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "id" String -> FeatureTests mkFeatureTests String "mls" FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addUpdate (String -> Value mls1 String uid) FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addUpdate Value mls2 FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addInvalidUpdate Value mlsInvalidConfig 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 testMlsPatch :: (HasCallStack) => FeatureTable -> App () testMlsPatch :: HasCallStack => FeatureTable -> App () testMlsPatch FeatureTable table = do Value mlsMigrationDefaultConfig <- Value defAllFeatures Value -> String -> App Value forall a. (HasCallStack, MakesValue a) => a -> String -> App Value %. String "mlsMigration.config" ServiceOverrides -> (HasCallStack => String -> App ()) -> App () forall a. HasCallStack => ServiceOverrides -> (HasCallStack => String -> App a) -> App a withModifiedBackend ServiceOverrides forall a. Default a => a def { galleyCfg = setField "settings.featureFlags.mlsMigration.defaults" ( object [ "lockStatus" .= "locked", "status" .= "disabled", "config" .= mlsMigrationDefaultConfig ] ) } ((HasCallStack => String -> App ()) -> App ()) -> (HasCallStack => String -> App ()) -> App () forall a b. (a -> b) -> a -> b $ \String domain -> do FeatureTable -> String -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table String domain String "mls" (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"] FeatureTable -> String -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table String domain String "mls" (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 -> String -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table String domain String "mls" (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 "status" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "enabled"] FeatureTable -> String -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table String domain String "mls" (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", String "config" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= [Pair] -> Value object [ String "protocolToggleUsers" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([] :: [String]), String "defaultProtocol" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "mls", String "supportedProtocols" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String "proteus", String "mls"], String "allowedCipherSuites" String -> [Int] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([Int 1] :: [Int]), String "defaultCipherSuite" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= Int -> Value forall a. ToJSON a => a -> Value toJSON (Int 1 :: Int) ] ] FeatureTable -> String -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => FeatureTable -> domain -> String -> Value -> App () checkPatchWithTable FeatureTable table String domain String "mls" (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 "protocolToggleUsers" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([] :: [String]), String "defaultProtocol" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "mls", String "supportedProtocols" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String "proteus", String "mls"], String "allowedCipherSuites" String -> [Int] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([Int 1] :: [Int]), String "defaultCipherSuite" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= Int -> Value forall a. ToJSON a => a -> Value toJSON (Int 1 :: Int) ] ] testMlsReadOnly :: (HasCallStack) => APIAccess -> App () testMlsReadOnly :: HasCallStack => APIAccess -> App () testMlsReadOnly APIAccess access = Domain -> APIAccess -> FeatureTests -> App () forall domain. (HasCallStack, MakesValue domain) => domain -> APIAccess -> FeatureTests -> App () runFeatureTestsReadOnly Domain OwnDomain APIAccess access (FeatureTests -> App ()) -> FeatureTests -> App () forall a b. (a -> b) -> a -> b $ String -> FeatureTests mkFeatureTests String "mls" FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests forall a b. a -> (a -> b) -> b & Value -> FeatureTests -> FeatureTests addUpdate Value mls2 testPatchMlsReadOnly :: (HasCallStack) => App () testPatchMlsReadOnly :: HasCallStack => App () testPatchMlsReadOnly = Domain -> String -> Value -> App () forall domain. (HasCallStack, MakesValue domain) => domain -> String -> Value -> App () checkPatchReadOnly Domain OwnDomain String "mls" Value mls2 mls1 :: String -> Value mls1 :: String -> Value mls1 String uid = [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 "protocolToggleUsers" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String uid], String "defaultProtocol" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "mls", String "supportedProtocols" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String "proteus", String "mls"], String "allowedCipherSuites" String -> [Int] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([Int 1] :: [Int]), String "defaultCipherSuite" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= Int -> Value forall a. ToJSON a => a -> Value toJSON (Int 1 :: Int) ] ] mls2 :: Value mls2 :: Value mls2 = [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 "protocolToggleUsers" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([] :: [String]), String "defaultProtocol" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "mls", String "supportedProtocols" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String "mls"], String "allowedCipherSuites" String -> [Int] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([Int 1] :: [Int]), String "defaultCipherSuite" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= Int -> Value forall a. ToJSON a => a -> Value toJSON (Int 1 :: Int) ] ] mlsInvalidConfig :: Value mlsInvalidConfig :: Value mlsInvalidConfig = [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 "protocolToggleUsers" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([] :: [String]), String "defaultProtocol" String -> String -> Pair forall a. ToJSON a => String -> a -> Pair .= String "mls", String "supportedProtocols" String -> [String] -> Pair forall a. ToJSON a => String -> a -> Pair .= [String "proteus"], String "allowedCipherSuites" String -> [Int] -> Pair forall a. ToJSON a => String -> a -> Pair .= ([Int 1] :: [Int]), String "defaultCipherSuite" String -> Value -> Pair forall a. ToJSON a => String -> a -> Pair .= Int -> Value forall a. ToJSON a => a -> Value toJSON (Int 1 :: Int) ] ]