-
Notifications
You must be signed in to change notification settings - Fork 334
hscim client #1699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
hscim client #1699
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4a6517c
Improve roundtrip generator.
fisx 1a3f194
Extend module exports.
fisx 6f6429e
Missing FromJSON instances.
fisx 77d6538
Client routes.
fisx 7f4cf25
CHANGELOG
fisx 892efab
golden tests.
fisx 5da66dc
use generic where appropriate.
fisx 14a064f
Merge branch 'develop' into hscim-client
fisx e0b3c96
applicative hedgehog generators.
fisx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| {-# LANGUAGE QuasiQuotes #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# LANGUAGE TypeApplications #-} | ||
| {-# LANGUAGE ViewPatterns #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2020 Wire Swiss GmbH <opensource@wire.com> | ||
|
fisx marked this conversation as resolved.
|
||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Test.Schema.MetaSchemaSpec | ||
| ( spec, | ||
| ) | ||
| where | ||
|
|
||
| import Data.Aeson | ||
| import Data.Text (Text) | ||
| import HaskellWorks.Hspec.Hedgehog (require) | ||
| import Hedgehog | ||
| import qualified Hedgehog.Gen as Gen | ||
| import qualified Hedgehog.Range as Range | ||
| import Network.URI.Static (uri) | ||
| import Test.Hspec | ||
| import Web.Scim.Capabilities.MetaSchema | ||
| import Web.Scim.Schema.AuthenticationScheme | ||
| import Web.Scim.Schema.Common (ScimBool (ScimBool), URI (..)) | ||
| import Web.Scim.Schema.Schema (Schema (..)) | ||
| import Prelude hiding (filter) | ||
|
|
||
| prop_roundtrip :: (ToJSON a, FromJSON a, Show a, Eq a) => Gen a -> Property | ||
| prop_roundtrip gen = property $ do | ||
| config <- forAll gen | ||
| tripping config toJSON fromJSON | ||
|
|
||
| spec :: Spec | ||
| spec = do | ||
| describe "MetaSchema" $ do | ||
| it "`Supported ()` roundtrips" $ do | ||
| require (prop_roundtrip (genSupported (pure ()))) | ||
| it "`BulkConfig` roundtrips" $ do | ||
| require (prop_roundtrip genBulkConfig) | ||
| it "`FilterConfig` roundtrips" $ do | ||
| require (prop_roundtrip genFilterConfig) | ||
| it "`AuthenticationSchemeEncoding` roundtrips" $ do | ||
| require (prop_roundtrip genAuthenticationSchemeEncoding) | ||
| it "`Configuration` roundtrips" $ do | ||
| require (prop_roundtrip genConfiguration) | ||
|
|
||
| genConfiguration :: Gen Configuration | ||
| genConfiguration = do | ||
| documentationUri <- Gen.maybe genUri | ||
| schemas <- pure [User20] | ||
| patch <- genSupported (pure ()) | ||
| bulk <- genSupported genBulkConfig | ||
| filter <- genSupported genFilterConfig | ||
| changePassword <- genSupported (pure ()) | ||
| sort <- genSupported (pure ()) | ||
| etag <- genSupported (pure ()) | ||
| authenticationSchemes <- Gen.list (Range.linear 0 100) genAuthenticationSchemeEncoding | ||
| pure Configuration {..} | ||
|
fisx marked this conversation as resolved.
Outdated
|
||
|
|
||
| genBulkConfig :: Gen BulkConfig | ||
| genBulkConfig = do | ||
| maxOperations <- Gen.int (Range.linear 0 100) | ||
| maxPayloadSize <- Gen.int (Range.linear 0 100) | ||
| pure BulkConfig {..} | ||
|
|
||
| genFilterConfig :: Gen FilterConfig | ||
| genFilterConfig = do | ||
| maxResults <- Gen.int (Range.linear 0 100) | ||
| pure FilterConfig {..} | ||
|
|
||
| genAuthenticationSchemeEncoding :: Gen AuthenticationSchemeEncoding | ||
| genAuthenticationSchemeEncoding = do | ||
| typ <- genSimpleText | ||
| name <- genSimpleText | ||
| description <- genSimpleText | ||
| specUri <- Gen.maybe genUri | ||
| documentationUri <- Gen.maybe genUri | ||
| pure AuthenticationSchemeEncoding {..} | ||
|
|
||
| genSupported :: forall a. Gen a -> Gen (Supported a) | ||
| genSupported gen = do | ||
| supported :: ScimBool <- ScimBool <$> Gen.bool | ||
| subConfig :: a <- gen | ||
| pure Supported {..} | ||
|
|
||
| genUri :: Gen URI | ||
| genUri = Gen.element [URI [uri|https://example.com|], URI [uri|gopher://glab.io|], URI [uri|ssh://nothing/blorg|]] | ||
|
|
||
| genSimpleText :: Gen Text | ||
| genSimpleText = Gen.element ["one", "green", "sharp"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.