chore: fix tests
This commit is contained in:
parent
c4501f1d08
commit
d44b903b3e
@ -51,7 +51,6 @@ makeUsers (fromIntegral -> n) = do
|
|||||||
let baseid = "user." <> tshow i
|
let baseid = "user." <> tshow i
|
||||||
u' = u { userIdent = CI.mk baseid
|
u' = u { userIdent = CI.mk baseid
|
||||||
, userEmail = CI.mk $ baseid <> "@example.com"
|
, userEmail = CI.mk $ baseid <> "@example.com"
|
||||||
, userLdapPrimaryKey = Just $ baseid <> ".ldap"
|
|
||||||
}
|
}
|
||||||
return u'
|
return u'
|
||||||
uids <- insertMany users
|
uids <- insertMany users
|
||||||
|
|||||||
@ -10,7 +10,6 @@ module Model.TypesSpec
|
|||||||
|
|
||||||
import TestImport
|
import TestImport
|
||||||
import TestInstances ()
|
import TestInstances ()
|
||||||
import Settings
|
|
||||||
|
|
||||||
import Utils (guardOn)
|
import Utils (guardOn)
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ import qualified Data.Aeson.Types as Aeson
|
|||||||
import Model.Types.LanguagesSpec ()
|
import Model.Types.LanguagesSpec ()
|
||||||
|
|
||||||
import System.IO.Unsafe
|
import System.IO.Unsafe
|
||||||
import Yesod.Auth.Util.PasswordStore
|
|
||||||
|
|
||||||
import Database.Persist.Sql (SqlBackend, fromSqlKey, toSqlKey)
|
import Database.Persist.Sql (SqlBackend, fromSqlKey, toSqlKey)
|
||||||
|
|
||||||
@ -217,21 +215,6 @@ instance Arbitrary Value where
|
|||||||
arbitrary' = scale (`div` 2) arbitrary
|
arbitrary' = scale (`div` 2) arbitrary
|
||||||
shrink = genericShrink
|
shrink = genericShrink
|
||||||
|
|
||||||
instance Arbitrary AuthenticationMode where
|
|
||||||
arbitrary = oneof
|
|
||||||
[ pure AuthLDAP
|
|
||||||
, do
|
|
||||||
pw <- encodeUtf8 . pack . getPrintableString <$> arbitrary
|
|
||||||
let
|
|
||||||
PWHashConf{..} = appAuthPWHash compileTimeAppSettings
|
|
||||||
authPWHash = unsafePerformIO . fmap decodeUtf8 $ makePasswordWith pwHashAlgorithm pw (pwHashStrength `div` 2)
|
|
||||||
return $ AuthPWHash{..}
|
|
||||||
]
|
|
||||||
|
|
||||||
shrink AuthLDAP = []
|
|
||||||
shrink AuthNoLogin = []
|
|
||||||
shrink (AuthPWHash _) = [AuthLDAP]
|
|
||||||
|
|
||||||
instance Arbitrary LecturerType where
|
instance Arbitrary LecturerType where
|
||||||
arbitrary = genericArbitrary
|
arbitrary = genericArbitrary
|
||||||
shrink = genericShrink
|
shrink = genericShrink
|
||||||
@ -462,8 +445,6 @@ spec = do
|
|||||||
[ eqLaws, ordLaws, boundedEnumLaws, showReadLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ]
|
[ eqLaws, ordLaws, boundedEnumLaws, showReadLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ]
|
||||||
lawsCheckHspec (Proxy @CorrectorState)
|
lawsCheckHspec (Proxy @CorrectorState)
|
||||||
[ eqLaws, ordLaws, showReadLaws, boundedEnumLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ]
|
[ eqLaws, ordLaws, showReadLaws, boundedEnumLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ]
|
||||||
lawsCheckHspec (Proxy @AuthenticationMode)
|
|
||||||
[ eqLaws, ordLaws, showReadLaws, jsonLaws, persistFieldLaws ]
|
|
||||||
lawsCheckHspec (Proxy @Value)
|
lawsCheckHspec (Proxy @Value)
|
||||||
[ persistFieldLaws ]
|
[ persistFieldLaws ]
|
||||||
lawsCheckHspec (Proxy @Scientific)
|
lawsCheckHspec (Proxy @Scientific)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@cip.ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
|
-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@cip.ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
|
||||||
--
|
--
|
||||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ module ModelSpec where
|
|||||||
|
|
||||||
import TestImport
|
import TestImport
|
||||||
|
|
||||||
import Settings (getTimeLocale', VerpMode(..))
|
import Settings
|
||||||
|
|
||||||
import Model.TypesSpec ()
|
import Model.TypesSpec ()
|
||||||
import MailSpec ()
|
import MailSpec ()
|
||||||
@ -34,9 +34,10 @@ import qualified Data.CryptoID.Class.ImplicitNamespace as Implicit
|
|||||||
import qualified Data.CryptoID.Class as Explicit
|
import qualified Data.CryptoID.Class as Explicit
|
||||||
import Data.Binary.SerializationLength
|
import Data.Binary.SerializationLength
|
||||||
|
|
||||||
import Control.Monad.Catch.Pure (Catch, runCatch)
|
import System.IO.Unsafe
|
||||||
|
import Yesod.Auth.Util.PasswordStore
|
||||||
|
|
||||||
import System.IO.Unsafe (unsafePerformIO)
|
import Control.Monad.Catch.Pure (Catch, runCatch)
|
||||||
|
|
||||||
import Data.Universe
|
import Data.Universe
|
||||||
|
|
||||||
@ -102,7 +103,12 @@ instance Arbitrary User where
|
|||||||
[ getPrintableString <$> arbitrary
|
[ getPrintableString <$> arbitrary
|
||||||
, on (\l d -> l <> "@" <> d) getPrintableString <$> arbitrary <*> arbitrary
|
, on (\l d -> l <> "@" <> d) getPrintableString <$> arbitrary <*> arbitrary
|
||||||
]
|
]
|
||||||
userAuthentication <- arbitrary
|
userPasswordHash <-
|
||||||
|
let genPwd = do
|
||||||
|
pw <- encodeUtf8 . pack . getPrintableString <$> arbitrary
|
||||||
|
let PWHashConf{..} = appAuthPWHash compileTimeAppSettings
|
||||||
|
return . unsafePerformIO . fmap decodeUtf8 $ makePasswordWith pwHashAlgorithm pw (pwHashStrength `div` 2)
|
||||||
|
in oneof [ pure Nothing, Just <$> genPwd ]
|
||||||
userLastAuthentication <- arbitrary
|
userLastAuthentication <- arbitrary
|
||||||
userTokensIssuedAfter <- arbitrary
|
userTokensIssuedAfter <- arbitrary
|
||||||
userMatrikelnummer <- fmap pack . assertM' (not . null) <$> listOf (elements ['0'..'9'])
|
userMatrikelnummer <- fmap pack . assertM' (not . null) <$> listOf (elements ['0'..'9'])
|
||||||
@ -146,14 +152,7 @@ instance Arbitrary User where
|
|||||||
userExamOfficeGetLabels <- arbitrary
|
userExamOfficeGetLabels <- arbitrary
|
||||||
|
|
||||||
userCreated <- arbitrary
|
userCreated <- arbitrary
|
||||||
userLastLdapSynchronisation <- arbitrary
|
userLastSync <- arbitrary
|
||||||
userLdapPrimaryKey <- oneof
|
|
||||||
[ pure Nothing
|
|
||||||
, fmap Just $ pack <$> oneof
|
|
||||||
[ getPrintableString <$> arbitrary
|
|
||||||
, on (\l d -> l <> "@" <> d) getPrintableString <$> arbitrary <*> arbitrary
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
return User{..}
|
return User{..}
|
||||||
shrink = genericShrink
|
shrink = genericShrink
|
||||||
|
|||||||
@ -21,8 +21,9 @@ fakeUser adjUser = adjUser User{..}
|
|||||||
UserDefaultConf{..} = appUserDefaults compileTimeAppSettings
|
UserDefaultConf{..} = appUserDefaults compileTimeAppSettings
|
||||||
|
|
||||||
userMatrikelnummer = Nothing
|
userMatrikelnummer = Nothing
|
||||||
userAuthentication = AuthLDAP
|
userPasswordHash = Nothing
|
||||||
userLastAuthentication = Nothing
|
userLastAuthentication = Nothing
|
||||||
|
userLastSync = Nothing
|
||||||
userTokensIssuedAfter = Nothing
|
userTokensIssuedAfter = Nothing
|
||||||
userIdent = "dummy@example.invalid"
|
userIdent = "dummy@example.invalid"
|
||||||
userEmail = "dummy@example.invalid"
|
userEmail = "dummy@example.invalid"
|
||||||
@ -48,8 +49,6 @@ fakeUser adjUser = adjUser User{..}
|
|||||||
userShowSex = userDefaultShowSex
|
userShowSex = userDefaultShowSex
|
||||||
userNotificationSettings = def
|
userNotificationSettings = def
|
||||||
userCreated = unsafePerformIO getCurrentTime
|
userCreated = unsafePerformIO getCurrentTime
|
||||||
userLastLdapSynchronisation = Nothing
|
|
||||||
userLdapPrimaryKey = Nothing
|
|
||||||
userMobile = Nothing
|
userMobile = Nothing
|
||||||
userTelephone = Nothing
|
userTelephone = Nothing
|
||||||
userCompanyPersonalNumber = Nothing
|
userCompanyPersonalNumber = Nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user