Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c3e1dbe
Now and AssIDStore interpreters
isovector Nov 9, 2021
263f946
Add AReqIDStore.Mem
isovector Nov 9, 2021
a6235c5
add boolTTL helper
isovector Nov 9, 2021
db1e01f
Add BindCookieStore.Mem
isovector Nov 9, 2021
2072759
Add SAMLUserStore.Mem
isovector Nov 9, 2021
b948402
Make format
isovector Nov 9, 2021
96995d0
Add DefaultSsoCode.Mem
isovector Nov 9, 2021
3db57a0
Add ScimExternalIdStore.Mem
isovector Nov 9, 2021
c4b51ef
Add ScimTokenStore.Mem
isovector Nov 9, 2021
7f5dbb8
Add ScimUserTimesStore.Mem
isovector Nov 9, 2021
c8bd681
make format
isovector Nov 9, 2021
2252951
Changelog
isovector Nov 9, 2021
ae3d3ea
Merge branch 'develop' into in-mem-interpreters
isovector Nov 22, 2021
b983824
Pull out VerdictFormatStore
isovector Nov 22, 2021
39737af
Remove stale comment
isovector Nov 22, 2021
edfa1eb
Also emit internal state
isovector Nov 22, 2021
7b94658
DefaultSsoCodeSpec
isovector Nov 23, 2021
be84e41
NowSpec
isovector Nov 23, 2021
fb048ae
Add interpreter names
isovector Nov 23, 2021
09954ef
Generalize IdPSpec
isovector Nov 23, 2021
8fd3197
IdPSpec
isovector Nov 23, 2021
eef3d07
ScimExternalIdStoreSpec
isovector Nov 23, 2021
e2deed3
Better names for ScimExternalIdStoreSpec
isovector Nov 23, 2021
ca0f5ed
make format
isovector Nov 23, 2021
4738048
changelog.d
isovector Nov 23, 2021
962f2e8
Fix module name
isovector Nov 23, 2021
1c0808c
Merge branch 'develop' into in-mem-specs
isovector Nov 24, 2021
d03760e
Hi CI
isovector Nov 25, 2021
1c2ef7d
More CI
isovector Nov 25, 2021
e9ee28c
CI
isovector Dec 1, 2021
10e1515
Merge branch 'develop' into in-mem-specs
isovector Dec 1, 2021
348673e
Update services/spar/test/Test/Spar/Sem/IdPSpec.hs
isovector Dec 3, 2021
2eb6688
Upgrade IdPSpec to 0.9.0.0
isovector Dec 6, 2021
d50f114
Merge branch 'in-mem-specs' of github.com:wireapp/wire-server into in…
isovector Dec 6, 2021
8f03a63
Fix a bug from merge
isovector Dec 6, 2021
278a1b9
Update IdPRawMetadataStoreSpec
isovector Dec 9, 2021
c2d3e23
Fixed DefaultSsoCodeSpec
isovector Dec 9, 2021
79b43c1
Add a prelude to delete/delete
isovector Dec 9, 2021
ca156e7
Fix NowSpec
isovector Dec 9, 2021
097b0aa
Fix ScimExternalIdStoreSpec
isovector Dec 9, 2021
3d21824
Merge branch 'develop' into in-mem-specs
isovector Dec 9, 2021
0b5190c
make format
isovector Dec 10, 2021
ee531ae
OCI
isovector Dec 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/in-mem-specs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added laws for DefaultSsoCode, Now, IdP and ScimExternalIdStore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be a bit confusing for the casual reader of the release notes. i'll fix it on develop after merging.

2 changes: 1 addition & 1 deletion services/spar/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ tests:
- QuickCheck
- spar
- uri-bytestring
- polysemy-check
- polysemy-check >= 0.9

executables:
spar:
Expand Down
7 changes: 5 additions & 2 deletions services/spar/spar.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 34138a2c7fa249191ae03bc1581a7c95c94b12080f104da084a9bc37ac54c9ad
-- hash: 4a323def34cfdc7673cea02e13fe518d53d7b04bae552bff2d0784dfb6964162

name: spar
version: 0.1
Expand Down Expand Up @@ -514,8 +514,11 @@ test-suite spec
Test.Spar.Intra.BrigSpec
Test.Spar.Roundtrip.ByteString
Test.Spar.ScimSpec
Test.Spar.Sem.DefaultSsoCodeSpec
Test.Spar.Sem.IdPRawMetadataStoreSpec
Test.Spar.Sem.IdPSpec
Test.Spar.Sem.NowSpec
Test.Spar.Sem.ScimExternalIdStoreSpec
Test.Spar.TypesSpec
Paths_spar
hs-source-dirs:
Expand Down Expand Up @@ -564,7 +567,7 @@ test-suite spec
, network-uri
, optparse-applicative
, polysemy
, polysemy-check
, polysemy-check >=0.9
, polysemy-plugin
, raw-strings-qq
, retry
Expand Down
2 changes: 2 additions & 0 deletions services/spar/src/Spar/Sem/DefaultSsoCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ data DefaultSsoCode m a where
Store :: SAML.IdPId -> DefaultSsoCode m ()
Delete :: DefaultSsoCode m ()

deriving instance Show (DefaultSsoCode m a)

makeSem ''DefaultSsoCode
2 changes: 2 additions & 0 deletions services/spar/src/Spar/Sem/Now.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ data Now m a where

makeSem ''Now

deriving instance Show (Now m a)

-- | Check a time against 'Now', checking if it's still alive (hasn't occurred yet.)
boolTTL ::
Member Now r =>
Expand Down
2 changes: 2 additions & 0 deletions services/spar/src/Spar/Sem/ScimExternalIdStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ data ScimExternalIdStore m a where
Lookup :: TeamId -> Email -> ScimExternalIdStore m (Maybe UserId)
Delete :: TeamId -> Email -> ScimExternalIdStore m ()

deriving instance Show (ScimExternalIdStore m a)

makeSem ''ScimExternalIdStore
8 changes: 7 additions & 1 deletion services/spar/test/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
module Arbitrary where

import Data.Aeson
import Data.Id (TeamId)
import Data.Id (TeamId, UserId)
import Data.Proxy
import Data.String.Conversions (cs)
import Data.Swagger hiding (Header (..))
Expand Down Expand Up @@ -97,6 +97,8 @@ instance Arbitrary E.Replaced where

instance CoArbitrary a => CoArbitrary (E.GetIdPResult a)

-- TODO(sandy): IdPIds are unlikely to collide. Does the size parameter
-- affect them?
instance CoArbitrary IdPId

instance CoArbitrary WireIdP
Expand All @@ -105,6 +107,10 @@ instance CoArbitrary WireIdPAPIVersion

instance CoArbitrary TeamId

instance CoArbitrary UserId

instance CoArbitrary Time

instance CoArbitrary Issuer where
coarbitrary (Issuer ur) = coarbitrary $ show ur

Expand Down
173 changes: 173 additions & 0 deletions services/spar/test/Test/Spar/Sem/DefaultSsoCodeSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{-# LANGUAGE QuantifiedConstraints #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-}

module Test.Spar.Sem.DefaultSsoCodeSpec where

import Arbitrary ()
import Imports
import Polysemy
import Polysemy.Check
import SAML2.WebSSO.Types
import qualified Spar.Sem.DefaultSsoCode as E
import Spar.Sem.DefaultSsoCode.Mem
import Test.Hspec
import Test.Hspec.QuickCheck
import Test.QuickCheck

deriveGenericK ''E.DefaultSsoCode

propsForInterpreter ::
PropConstraints r f =>
String ->
(forall a. Sem r a -> IO (f a)) ->
Spec
propsForInterpreter interpreter lower = do
describe interpreter $ do
prop "delete/delete" $ prop_deleteDelete Nothing lower
prop "delete/get" $ prop_deleteGet Nothing lower
prop "delete/store" $ prop_deleteStore Nothing lower
prop "get/store" $ prop_getStore Nothing lower
prop "store/delete" $ prop_storeStore Nothing lower
prop "store/get" $ prop_storeGet Nothing lower
prop "store/store" $ prop_storeStore Nothing lower

spec :: Spec
spec = modifyMaxSuccess (const 1000) $ do
propsForInterpreter "defaultSsoCodeToMem" $ pure . run . defaultSsoCodeToMem

-- | All the constraints we need to generalize properties in this module.
-- A regular type synonym doesn't work due to dreaded impredicative
-- polymorphism.
class
(Functor f, Member E.DefaultSsoCode r, forall z. Show z => Show (f z), forall z. Eq z => Eq (f z)) =>
PropConstraints r f

instance
(Functor f, Member E.DefaultSsoCode r, forall z. Show z => Show (f z), forall z. Eq z => Eq (f z)) =>
PropConstraints r f

prop_storeGet ::
PropConstraints r f =>
Maybe (f (Maybe IdPId) -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_storeGet =
prepropLaw @'[E.DefaultSsoCode] $ do
s <- arbitrary
pure $
simpleLaw
( do
E.store s
E.get
)
( do
E.store s
pure (Just s)
)

prop_getStore ::
PropConstraints r f =>
Maybe (f () -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_getStore =
prepropLaw @'[E.DefaultSsoCode] $ do
pure $
simpleLaw
( do
E.get >>= maybe (pure ()) E.store
)
( do
pure ()
)

prop_storeDelete ::
PropConstraints r f =>
Maybe (f () -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_storeDelete =
prepropLaw @'[E.DefaultSsoCode] $ do
s <- arbitrary
pure $
simpleLaw
( do
E.store s
E.delete
)
( do
E.delete
)

prop_deleteStore ::
PropConstraints r f =>
Maybe (f () -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_deleteStore =
prepropLaw @'[E.DefaultSsoCode] $ do
s <- arbitrary
pure $
simpleLaw
( do
E.delete
E.store s
)
( do
E.store s
)

prop_storeStore ::
PropConstraints r f =>
Maybe (f () -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_storeStore =
prepropLaw @'[E.DefaultSsoCode] $ do
s <- arbitrary
s' <- arbitrary
pure $
simpleLaw
( do
E.store s
E.store s'
)
( do
E.store s'
)

prop_deleteDelete ::
PropConstraints r f =>
Maybe (f () -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_deleteDelete =
prepropLaw @'[E.DefaultSsoCode] $ do
pure $
simpleLaw
( do
E.delete
E.delete
)
( do
E.delete
)

prop_deleteGet ::
PropConstraints r f =>
Maybe (f (Maybe IdPId) -> String) ->
(forall a. Sem r a -> IO (f a)) ->
Property
prop_deleteGet =
prepropLaw @'[E.DefaultSsoCode] $ do
pure $
simpleLaw
( do
E.delete
E.get
)
( do
E.delete
pure Nothing
)
Loading