diff --git a/test/Handler/Utils/SubmissionSpec.hs b/test/Handler/Utils/SubmissionSpec.hs index ed50724ba..4a16c559d 100644 --- a/test/Handler/Utils/SubmissionSpec.hs +++ b/test/Handler/Utils/SubmissionSpec.hs @@ -51,7 +51,6 @@ makeUsers (fromIntegral -> n) = do let baseid = "user." <> tshow i u' = u { userIdent = CI.mk baseid , userEmail = CI.mk $ baseid <> "@example.com" - , userLdapPrimaryKey = Just $ baseid <> ".ldap" } return u' uids <- insertMany users diff --git a/test/Model/TypesSpec.hs b/test/Model/TypesSpec.hs index fe9eb7325..b8b0eca50 100644 --- a/test/Model/TypesSpec.hs +++ b/test/Model/TypesSpec.hs @@ -10,7 +10,6 @@ module Model.TypesSpec import TestImport import TestInstances () -import Settings import Utils (guardOn) @@ -21,7 +20,6 @@ import qualified Data.Aeson.Types as Aeson import Model.Types.LanguagesSpec () import System.IO.Unsafe -import Yesod.Auth.Util.PasswordStore import Database.Persist.Sql (SqlBackend, fromSqlKey, toSqlKey) @@ -217,21 +215,6 @@ instance Arbitrary Value where arbitrary' = scale (`div` 2) arbitrary 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 arbitrary = genericArbitrary shrink = genericShrink @@ -462,8 +445,6 @@ spec = do [ eqLaws, ordLaws, boundedEnumLaws, showReadLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ] lawsCheckHspec (Proxy @CorrectorState) [ eqLaws, ordLaws, showReadLaws, boundedEnumLaws, jsonLaws, finiteLaws, pathPieceLaws, persistFieldLaws ] - lawsCheckHspec (Proxy @AuthenticationMode) - [ eqLaws, ordLaws, showReadLaws, jsonLaws, persistFieldLaws ] lawsCheckHspec (Proxy @Value) [ persistFieldLaws ] lawsCheckHspec (Proxy @Scientific) diff --git a/test/ModelSpec.hs b/test/ModelSpec.hs index 729f1a769..7fb5c4bc9 100644 --- a/test/ModelSpec.hs +++ b/test/ModelSpec.hs @@ -1,4 +1,4 @@ --- SPDX-FileCopyrightText: 2022 Gregor Kleen ,Sarah Vaupel ,Steffen Jost ,Steffen Jost +-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel , Gregor Kleen ,Sarah Vaupel ,Steffen Jost ,Steffen Jost -- -- SPDX-License-Identifier: AGPL-3.0-or-later @@ -9,7 +9,7 @@ module ModelSpec where import TestImport -import Settings (getTimeLocale', VerpMode(..)) +import Settings import Model.TypesSpec () import MailSpec () @@ -34,9 +34,10 @@ import qualified Data.CryptoID.Class.ImplicitNamespace as Implicit import qualified Data.CryptoID.Class as Explicit 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 @@ -102,7 +103,12 @@ instance Arbitrary User where [ getPrintableString <$> 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 userTokensIssuedAfter <- arbitrary userMatrikelnummer <- fmap pack . assertM' (not . null) <$> listOf (elements ['0'..'9']) @@ -146,14 +152,7 @@ instance Arbitrary User where userExamOfficeGetLabels <- arbitrary userCreated <- arbitrary - userLastLdapSynchronisation <- arbitrary - userLdapPrimaryKey <- oneof - [ pure Nothing - , fmap Just $ pack <$> oneof - [ getPrintableString <$> arbitrary - , on (\l d -> l <> "@" <> d) getPrintableString <$> arbitrary <*> arbitrary - ] - ] + userLastSync <- arbitrary return User{..} shrink = genericShrink diff --git a/test/User.hs b/test/User.hs index 239488fff..c3fba1640 100644 --- a/test/User.hs +++ b/test/User.hs @@ -21,8 +21,9 @@ fakeUser adjUser = adjUser User{..} UserDefaultConf{..} = appUserDefaults compileTimeAppSettings userMatrikelnummer = Nothing - userAuthentication = AuthLDAP + userPasswordHash = Nothing userLastAuthentication = Nothing + userLastSync = Nothing userTokensIssuedAfter = Nothing userIdent = "dummy@example.invalid" userEmail = "dummy@example.invalid" @@ -48,8 +49,6 @@ fakeUser adjUser = adjUser User{..} userShowSex = userDefaultShowSex userNotificationSettings = def userCreated = unsafePerformIO getCurrentTime - userLastLdapSynchronisation = Nothing - userLdapPrimaryKey = Nothing userMobile = Nothing userTelephone = Nothing userCompanyPersonalNumber = Nothing