module Test.FeatureFlags.Totp where
import Test.FeatureFlags.Util
import Testlib.Prelude
testTotp :: (HasCallStack) => APIAccess -> App ()
testTotp :: HasCallStack => APIAccess -> App ()
testTotp APIAccess
access =
String -> FeatureTests
mkFeatureTests String
"mfa-totp"
FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests
forall a b. a -> (a -> b) -> b
& Value -> FeatureTests -> FeatureTests
addUpdate Value
validConfig
FeatureTests -> (FeatureTests -> FeatureTests) -> FeatureTests
forall a b. a -> (a -> b) -> b
& Value -> FeatureTests -> FeatureTests
addInvalidUpdate Value
invalidConfig
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
validConfig :: Value
validConfig :: Value
validConfig =
[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
"require_for_all_members" String -> Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Bool
True,
String
"compulsory_for_owners_and_admins" String -> Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Bool
True
]
]
invalidConfig :: Value
invalidConfig :: Value
invalidConfig =
[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
"require_for_all_members" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= (String
"yes" :: String),
String
"compulsory_for_owners_and_admins" String -> Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Bool
False
]
]
testPatchTotp :: (HasCallStack) => App ()
testPatchTotp :: HasCallStack => App ()
testPatchTotp = do
Domain -> String -> Value -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App ()
checkPatch Domain
OwnDomain String
"mfa-totp"
(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"]
Domain -> String -> Value -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App ()
checkPatch Domain
OwnDomain String
"mfa-totp"
(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
"disabled"]
Domain -> String -> Value -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App ()
checkPatch Domain
OwnDomain String
"mfa-totp"
(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
"disabled"]
Domain -> String -> Value -> App ()
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> String -> Value -> App ()
checkPatch Domain
OwnDomain String
"mfa-totp"
(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
"config"
String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [Pair] -> Value
object
[ String
"require_for_all_members" String -> Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Bool
True,
String
"compulsory_for_owners_and_admins" String -> Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Bool
False
]
]