Skip to content

Commit 3af4fe2

Browse files
authored
Spar Polysemy: Rename ScimTokenStore.GetByTeam -> ScimTokenStore.LookupByTeam (#2068)
* Rename ScimTokenStore.GetByTeam -> ScimTokenStore.LookupByTeam * changelog * CI
1 parent 38318bf commit 3af4fe2

File tree

8 files changed

+10
-9
lines changed

8 files changed

+10
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rename Spar.Sem.ScimTokenStore.GetByTeam to LookupByTeam

services/spar/src/Spar/API.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ idpDelete zusr idpid (fromMaybe False -> purge) = withDebugLog "idpDelete" (cons
473473
-- Delete tokens associated with given IdP (we rely on the fact that
474474
-- each IdP has exactly one team so we can look up all tokens
475475
-- associated with the team and then filter them)
476-
tokens <- ScimTokenStore.getByTeam team
476+
tokens <- ScimTokenStore.lookupByTeam team
477477
for_ tokens $ \ScimTokenInfo {..} ->
478478
when (stiIdP == Just idpid) $ ScimTokenStore.delete team stiId
479479
-- Delete IdP config
@@ -565,7 +565,7 @@ assertNoScimOrNoIdP ::
565565
TeamId ->
566566
Sem r ()
567567
assertNoScimOrNoIdP teamid = do
568-
numTokens <- length <$> ScimTokenStore.getByTeam teamid
568+
numTokens <- length <$> ScimTokenStore.lookupByTeam teamid
569569
numIdps <- length <$> IdPEffect.getConfigsByTeam teamid
570570
when (numTokens > 0 && numIdps > 0) $ do
571571
throwSparSem $

services/spar/src/Spar/App.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ autoprovisionSamlUserWithId mbteam buid suid = do
294294
guardScimTokens :: IdP -> Sem r ()
295295
guardScimTokens idp = do
296296
let teamid = idp ^. idpExtraInfo . wiTeam
297-
scimtoks <- ScimTokenStore.getByTeam teamid
297+
scimtoks <- ScimTokenStore.lookupByTeam teamid
298298
unless (null scimtoks) $ do
299299
throwSparSem SparSamlCredentialsNotFound
300300

services/spar/src/Spar/Scim/Auth.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ createScimToken zusr CreateScimToken {..} = do
128128
let descr = createScimTokenDescr
129129
teamid <- Intra.Brig.authorizeScimTokenManagement zusr
130130
BrigAccess.ensureReAuthorised zusr createScimTokenPassword
131-
tokenNumber <- fmap length $ ScimTokenStore.getByTeam teamid
131+
tokenNumber <- fmap length $ ScimTokenStore.lookupByTeam teamid
132132
maxTokens <- inputs maxScimTokens
133133
unless (tokenNumber < maxTokens) $
134134
throwSparSem E.SparProvisioningTokenLimitReached
@@ -190,4 +190,4 @@ listScimTokens ::
190190
Sem r ScimTokenList
191191
listScimTokens zusr = do
192192
teamid <- Intra.Brig.authorizeScimTokenManagement zusr
193-
ScimTokenList <$> ScimTokenStore.getByTeam teamid
193+
ScimTokenList <$> ScimTokenStore.lookupByTeam teamid

services/spar/src/Spar/Sem/ScimTokenStore.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Wire.API.User.Scim
2525
data ScimTokenStore m a where
2626
Insert :: ScimToken -> ScimTokenInfo -> ScimTokenStore m ()
2727
Lookup :: ScimToken -> ScimTokenStore m (Maybe ScimTokenInfo)
28-
GetByTeam :: TeamId -> ScimTokenStore m [ScimTokenInfo]
28+
LookupByTeam :: TeamId -> ScimTokenStore m [ScimTokenInfo]
2929
Delete :: TeamId -> ScimTokenId -> ScimTokenStore m ()
3030
DeleteByTeam :: TeamId -> ScimTokenStore m ()
3131

services/spar/src/Spar/Sem/ScimTokenStore/Cassandra.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ scimTokenStoreToCassandra =
4545
embed @m . \case
4646
Insert st sti -> insertScimToken st sti
4747
Lookup st -> lookupScimToken st
48-
GetByTeam tid -> getScimTokens tid
48+
LookupByTeam tid -> getScimTokens tid
4949
Delete tid ur -> deleteScimToken tid ur
5050
DeleteByTeam tid -> deleteTeamScimTokens tid
5151

services/spar/src/Spar/Sem/ScimTokenStore/Mem.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ scimTokenStoreToMem = (runState mempty .) $
3333
reinterpret $ \case
3434
Insert st sti -> modify $ M.insert st sti
3535
Lookup st -> gets $ M.lookup st
36-
GetByTeam tid -> gets $ filter ((== tid) . stiTeam) . M.elems
36+
LookupByTeam tid -> gets $ filter ((== tid) . stiTeam) . M.elems
3737
Delete tid stid -> modify $ M.filter $ \sti -> not $ stiTeam sti == tid && stiId sti == stid
3838
DeleteByTeam tid -> modify $ M.filter (not . (== tid) . stiTeam)

services/spar/test-integration/Test/Spar/DataSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ testDeleteTeam = it "cleans up all the right tables after deletion" $ do
285285
liftIO $ tokenInfo `shouldBe` Nothing
286286
-- The team from 'team_provisioning_by_team':
287287
do
288-
tokens <- runSpar $ ScimTokenStore.getByTeam tid
288+
tokens <- runSpar $ ScimTokenStore.lookupByTeam tid
289289
liftIO $ tokens `shouldBe` []
290290
-- The users from 'user':
291291
do

0 commit comments

Comments
 (0)