Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
4 changes: 2 additions & 2 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
- hint: { lhs: (() <$), rhs: void }
- hint: { lhs: return, rhs: pure }
## We want the latter to properly handle signals.
- error: { name: Use shutdown, lhs: runSettings, rhs: runSettingsWithShutdown }
- ignore: { name: Use shutdown, within: [Network.Wai.Utilities.Server, Federator.Response] }
# - error: { name: Use shutdown, lhs: runSettings, rhs: runSettingsWithShutdown }
# - ignore: { name: Use shutdown, within: [Network.Wai.Utilities.Server, Federator.Response] }
2 changes: 0 additions & 2 deletions libs/hscim/test/Test/Class/AuthSpec.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE QuasiQuotes #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
Expand Down
1 change: 0 additions & 1 deletion libs/hscim/test/Test/FilterSpec.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE QuasiQuotes #-}

-- This file is part of the Wire Server implementation.
--
Expand Down
1 change: 0 additions & 1 deletion libs/hscim/test/Test/MiscSpec.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE QuasiQuotes #-}

-- This file is part of the Wire Server implementation.
--
Expand Down
8 changes: 4 additions & 4 deletions libs/hscim/test/Test/Schema/GroupSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ spec = do
genMember :: Gen GroupClass.Member
genMember =
GroupClass.Member
<$> (Gen.text (Range.constant 0 20) Gen.unicode)
<*> (Gen.text (Range.constant 0 20) Gen.unicode)
<*> (Gen.text (Range.constant 0 20) Gen.unicode)
<$> Gen.text (Range.constant 0 20) Gen.unicode
<*> Gen.text (Range.constant 0 20) Gen.unicode
<*> Gen.text (Range.constant 0 20) Gen.unicode

genGroup :: Gen GroupClass.Group
genGroup =
GroupClass.Group
<$> Gen.list (Range.linear 0 10) genSchema
<*> (Gen.text (Range.constant 0 20) Gen.unicode)
<*> Gen.text (Range.constant 0 20) Gen.unicode
<*> Gen.list (Range.linear 0 10) genMember

genSchema :: Gen Text
Expand Down
5 changes: 1 addition & 4 deletions libs/hscim/test/Test/Schema/MetaSchemaSpec.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

-- This file is part of the Wire Server implementation.
--
Expand Down Expand Up @@ -48,7 +45,7 @@ spec = do
describe "MetaSchema" $ do
-- the extra 'decode' in the golden tests is to make attribute order not count for Eq.
it "`Supported ()` golden test" $ do
decode @Value (encode (Supported (ScimBool True) ())) `shouldBe` decode @Value ("{\"supported\":true}")
decode @Value (encode (Supported (ScimBool True) ())) `shouldBe` decode @Value "{\"supported\":true}"
it "`Supported a` golden test" $ do
decode @Value (encode (Supported (ScimBool True) (FilterConfig 3))) `shouldBe` decode @Value "{\"supported\":true,\"maxResults\":3}"
it "`Supported ()` roundtrips" $ do
Expand Down
27 changes: 13 additions & 14 deletions libs/hscim/test/Test/Schema/UserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ spec = do
let Right programmingLanguagePath = PatchOp.parsePath (User.supportedSchemas @PatchTag) "urn:hscim:test:programmingLanguage"
let operation = Operation Replace (Just programmingLanguagePath) (Just (toJSON @Text "haskell"))
let patchOp = PatchOp [operation]
User.extra <$> (User.applyPatch user patchOp) `shouldBe` Right (KeyMap.singleton "programmingLanguage" "haskell")
User.extra <$> User.applyPatch user patchOp `shouldBe` Right (KeyMap.singleton "programmingLanguage" "haskell")
describe "JSON serialization" $ do
it "handles all fields" $ do
require prop_roundtrip
Expand All @@ -129,7 +129,7 @@ spec = do
it "treats 'null' and '[]' as absence of fields" $
eitherDecode (encode minimalUserJsonRedundant) `shouldBe` Right minimalUser
it "allows casing variations in field names" $ do
require $ mk_prop_caseInsensitive (genUser)
require $ mk_prop_caseInsensitive genUser
require $ mk_prop_caseInsensitive (ListResponse.fromList . (: []) <$> genStoredUser)
eitherDecode (encode minimalUserJsonNonCanonical) `shouldBe` Right minimalUser
it "doesn't require the 'schemas' field" $
Expand Down Expand Up @@ -157,8 +157,7 @@ genStoredUser :: Gen (UserClass.StoredUser (TestTag Text () () NoUserExtra))
genStoredUser = do
m <- genMeta
i <- Gen.element @_ @Text ["wef", "asdf", "@", "#", "1"]
u <- genUser
pure $ WithMeta m (WithId i u)
WithMeta m . WithId i <$> genUser

genMeta :: Gen Meta
genMeta =
Expand All @@ -172,7 +171,7 @@ genMeta =
-- lists in the first place
genUser :: Gen (User (TestTag Text () () NoUserExtra))
genUser = do
schemas' <- pure [User20] -- TODO random schemas or?
let schemas' = [User20] -- TODO random schemas or?
userName' <- Gen.text (Range.constant 0 20) Gen.unicode
externalId' <- Gen.maybe $ Gen.text (Range.constant 0 20) Gen.unicode
name' <- Gen.maybe genName
Expand All @@ -185,14 +184,14 @@ genUser = do
locale' <- Gen.maybe $ Gen.text (Range.constant 0 20) Gen.unicode
active' <- Gen.maybe $ (ScimBool <$> Gen.bool)
password' <- Gen.maybe $ Gen.text (Range.constant 0 20) Gen.unicode
emails' <- pure [] -- Gen.list (Range.constant 0 20) genEmail
phoneNumbers' <- pure [] -- Gen.list (Range.constant 0 20) genPhone
ims' <- pure [] -- Gen.list (Range.constant 0 20) genIM
photos' <- pure [] -- Gen.list (Range.constant 0 20) genPhoto
addresses' <- pure [] -- Gen.list (Range.constant 0 20) genAddress
entitlements' <- pure [] -- Gen.list (Range.constant 0 20) (Gen.text (Range.constant 0 20) Gen.unicode)
roles' <- pure [] -- Gen.list (Range.constant 0 20) (Gen.text (Range.constant 0 10) Gen.unicode)
x509Certificates' <- pure [] -- Gen.list (Range.constant 0 20) genCertificate
let emails' = [] -- Gen.list (Range.constant 0 20) genEmail
let phoneNumbers' = [] -- Gen.list (Range.constant 0 20) genPhone
let ims' = [] -- Gen.list (Range.constant 0 20) genIM
let photos' = [] -- Gen.list (Range.constant 0 20) genPhoto
let addresses' = [] -- Gen.list (Range.constant 0 20) genAddress
let entitlements' = [] -- Gen.list (Range.constant 0 20) (Gen.text (Range.constant 0 20) Gen.unicode)
let roles' = [] -- Gen.list (Range.constant 0 20) (Gen.text (Range.constant 0 10) Gen.unicode)
let x509Certificates' = [] -- Gen.list (Range.constant 0 20) genCertificate
pure $
User
{ schemas = schemas',
Expand Down Expand Up @@ -456,7 +455,7 @@ instance Patchable UserExtraTest where
-- | A 'User' with extra fields present.
extendedUser :: UserExtraTest -> User (TestTag Text () () UserExtraTest)
extendedUser e =
(User.empty [User20, CustomSchema "urn:hscim:test"] "sample userName" e)
User.empty [User20, CustomSchema "urn:hscim:test"] "sample userName" e

-- | Encoding of @extendedUser UserExtraEmpty@.
extendedUserEmptyJson :: Value
Expand Down
3 changes: 3 additions & 0 deletions libs/hscim/test/Test/Schema/Util.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE QuasiQuotes #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# HLINT ignore "Use camelCase" #-}

-- This file is part of the Wire Server implementation.
--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE OverloadedLists #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
Expand Down Expand Up @@ -27,7 +25,7 @@ import Wire.API.User.Auth (AccessToken (..), TokenType (Bearer))
testObject_AccessToken_user_1 :: AccessToken
testObject_AccessToken_user_1 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00002525-0000-2bc3-0000-3a8200006f94"))),
{ user = Id (fromJust (UUID.fromString "00002525-0000-2bc3-0000-3a8200006f94")),
access = "{\CAN\243\188\157\141\SOq\240\171\167\184w",
tokenType = Bearer,
expiresIn = 1
Expand All @@ -36,7 +34,7 @@ testObject_AccessToken_user_1 =
testObject_AccessToken_user_2 :: AccessToken
testObject_AccessToken_user_2 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00007ace-0000-630b-0000-718c00000945"))),
{ user = Id (fromJust (UUID.fromString "00007ace-0000-630b-0000-718c00000945")),
access = "o6Q\243\184\187\164\ETB\243\181\156\157",
tokenType = Bearer,
expiresIn = -24
Expand All @@ -45,7 +43,7 @@ testObject_AccessToken_user_2 =
testObject_AccessToken_user_3 :: AccessToken
testObject_AccessToken_user_3 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00004286-0000-22c5-0000-5dba00001818"))),
{ user = Id (fromJust (UUID.fromString "00004286-0000-22c5-0000-5dba00001818")),
access = "\DC3u\240\171\168\183N<E#\244\138\156\176>dWTm\SIi\244\139\166\169",
tokenType = Bearer,
expiresIn = 6
Expand All @@ -54,7 +52,7 @@ testObject_AccessToken_user_3 =
testObject_AccessToken_user_4 :: AccessToken
testObject_AccessToken_user_4 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00005c1d-0000-2e06-0000-278a00002d91"))),
{ user = Id (fromJust (UUID.fromString "00005c1d-0000-2e06-0000-278a00002d91")),
access = "\233\152\185\&0)&9\\\SI\NULO",
tokenType = Bearer,
expiresIn = -9
Expand All @@ -63,7 +61,7 @@ testObject_AccessToken_user_4 =
testObject_AccessToken_user_5 :: AccessToken
testObject_AccessToken_user_5 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00002891-0000-27e1-0000-686000002ba0"))),
{ user = Id (fromJust (UUID.fromString "00002891-0000-27e1-0000-686000002ba0")),
access = "n\227\154\185 {'\FS\240\159\147\150\DC1C*\234\186\142\ESC",
tokenType = Bearer,
expiresIn = 27
Expand All @@ -72,7 +70,7 @@ testObject_AccessToken_user_5 =
testObject_AccessToken_user_6 :: AccessToken
testObject_AccessToken_user_6 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "0000195e-0000-7174-0000-1a5c000030dc"))),
{ user = Id (fromJust (UUID.fromString "0000195e-0000-7174-0000-1a5c000030dc")),
access = "+\231\145\167\&8J\243\176\183\137\SOHw",
tokenType = Bearer,
expiresIn = 2
Expand All @@ -81,7 +79,7 @@ testObject_AccessToken_user_6 =
testObject_AccessToken_user_7 :: AccessToken
testObject_AccessToken_user_7 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "000038d1-0000-3dd4-0000-499a000014ca"))),
{ user = Id (fromJust (UUID.fromString "000038d1-0000-3dd4-0000-499a000014ca")),
access =
"`gS\DEL\DLE\ETXe\243\187\169\134o\243\191\130\131\244\129\152\137\243\178\160\150+Htv\244\130\172\190\EMdh\STX\240\169\169\185\239\130\169",
tokenType = Bearer,
Expand All @@ -91,7 +89,7 @@ testObject_AccessToken_user_7 =
testObject_AccessToken_user_8 :: AccessToken
testObject_AccessToken_user_8 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "000065e0-0000-3b8c-0000-492700007916"))),
{ user = Id (fromJust (UUID.fromString "000065e0-0000-3b8c-0000-492700007916")),
access = "\NULYn\DELC&X9\243\189\191\169_",
tokenType = Bearer,
expiresIn = 27
Expand All @@ -100,7 +98,7 @@ testObject_AccessToken_user_8 =
testObject_AccessToken_user_9 :: AccessToken
testObject_AccessToken_user_9 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "000023d8-0000-406e-0000-3277000079f9"))),
{ user = Id (fromJust (UUID.fromString "000023d8-0000-406e-0000-3277000079f9")),
access = "\244\132\147\179\CAN\b\243\187\136\177\244\141\160\129\CANf\243\179\172\128DDNNR\240\160\183\154`H",
tokenType = Bearer,
expiresIn = 23
Expand All @@ -109,7 +107,7 @@ testObject_AccessToken_user_9 =
testObject_AccessToken_user_10 :: AccessToken
testObject_AccessToken_user_10 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "0000376e-0000-4673-0000-1e1800004b06"))),
{ user = Id (fromJust (UUID.fromString "0000376e-0000-4673-0000-1e1800004b06")),
access = " \243\180\155\169+\244\143\128\190G_\240\161\128\142Xj\NULef\232\159\186.&U]J\240\166\182\187=<hrt3",
tokenType = Bearer,
expiresIn = -20
Expand All @@ -118,7 +116,7 @@ testObject_AccessToken_user_10 =
testObject_AccessToken_user_11 :: AccessToken
testObject_AccessToken_user_11 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "000018c7-0000-4f75-0000-29b0000065fc"))),
{ user = Id (fromJust (UUID.fromString "000018c7-0000-4f75-0000-29b0000065fc")),
access = "pT\240\164\134\146\DC1@\244\140\169\164\DC43",
tokenType = Bearer,
expiresIn = -19
Expand All @@ -127,7 +125,7 @@ testObject_AccessToken_user_11 =
testObject_AccessToken_user_12 :: AccessToken
testObject_AccessToken_user_12 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00000f4f-0000-0499-0000-78b4000029de"))),
{ user = Id (fromJust (UUID.fromString "00000f4f-0000-0499-0000-78b4000029de")),
access = "\ACK\n\244\136\183\166FY\ETXuu\SOH",
tokenType = Bearer,
expiresIn = 25
Expand All @@ -136,7 +134,7 @@ testObject_AccessToken_user_12 =
testObject_AccessToken_user_13 :: AccessToken
testObject_AccessToken_user_13 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00001225-0000-145a-0000-277600007725"))),
{ user = Id (fromJust (UUID.fromString "00001225-0000-145a-0000-277600007725")),
access =
"\244\128\147\170Q\224\176\149\243\186\134\162oV|#Hp-\243\184\189\134js\244\139\171\189\243\176\166\182.E\244\139\145\148\243\184\176\189",
tokenType = Bearer,
Expand All @@ -146,7 +144,7 @@ testObject_AccessToken_user_13 =
testObject_AccessToken_user_14 :: AccessToken
testObject_AccessToken_user_14 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00007469-0000-0eae-0000-1a8400004582"))),
{ user = Id (fromJust (UUID.fromString "00007469-0000-0eae-0000-1a8400004582")),
access = "\243\177\160\147",
tokenType = Bearer,
expiresIn = -12
Expand All @@ -155,7 +153,7 @@ testObject_AccessToken_user_14 =
testObject_AccessToken_user_15 :: AccessToken
testObject_AccessToken_user_15 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "000011e5-0000-29e4-0000-550400003888"))),
{ user = Id (fromJust (UUID.fromString "000011e5-0000-29e4-0000-550400003888")),
access = "\243\177\159\190r",
tokenType = Bearer,
expiresIn = 26
Expand All @@ -164,7 +162,7 @@ testObject_AccessToken_user_15 =
testObject_AccessToken_user_16 :: AccessToken
testObject_AccessToken_user_16 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "0000633c-0000-6653-0000-772e00005669"))),
{ user = Id (fromJust (UUID.fromString "0000633c-0000-6653-0000-772e00005669")),
access = "p\"\244\130\163\145\v-\238\143\147\ETX\b<\240\147\141\128+\SO\DEL\244\131\172\144",
tokenType = Bearer,
expiresIn = 18
Expand All @@ -173,7 +171,7 @@ testObject_AccessToken_user_16 =
testObject_AccessToken_user_17 :: AccessToken
testObject_AccessToken_user_17 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00006032-0000-470b-0000-544b00001c88"))),
{ user = Id (fromJust (UUID.fromString "00006032-0000-470b-0000-544b00001c88")),
access = "\240\167\149\178z}\bRH\ENQ@o\EMm,\240\159\146\156\228\155\169\244\140\181\157]\EOT\FS\rZm,Z",
tokenType = Bearer,
expiresIn = -13
Expand All @@ -182,7 +180,7 @@ testObject_AccessToken_user_17 =
testObject_AccessToken_user_18 :: AccessToken
testObject_AccessToken_user_18 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00006b0d-0000-792a-0000-3fb800003867"))),
{ user = Id (fromJust (UUID.fromString "00006b0d-0000-792a-0000-3fb800003867")),
access =
"\244\129\184\152\\\244\136\157\138\v2!\243\188\172\183\240\174\169\150ZE|3(\CAN=Q\ENQb\DC3[\243\176\144\149\243\188\182\133MW",
tokenType = Bearer,
Expand All @@ -192,7 +190,7 @@ testObject_AccessToken_user_18 =
testObject_AccessToken_user_19 :: AccessToken
testObject_AccessToken_user_19 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00004fc5-0000-08b5-0000-0ad800002c12"))),
{ user = Id (fromJust (UUID.fromString "00004fc5-0000-08b5-0000-0ad800002c12")),
access = "h\a",
tokenType = Bearer,
expiresIn = -16
Expand All @@ -201,7 +199,7 @@ testObject_AccessToken_user_19 =
testObject_AccessToken_user_20 :: AccessToken
testObject_AccessToken_user_20 =
AccessToken
{ user = (Id (fromJust (UUID.fromString "00005c43-0000-6c4c-0000-461200000976"))),
{ user = Id (fromJust (UUID.fromString "00005c43-0000-6c4c-0000-461200000976")),
access = "\243\190\143\130~\240\164\141\143#\t\FS\244\133\141\138 ~_W\244\139\185\159z_\243\179\169\167A",
tokenType = Bearer,
expiresIn = 17
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE OverloadedLists #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
Expand Down
Loading