on master help sign in
README
commitbb7fdefc2a92749bb7946a50eaf371ae5ee91ffe authorMark Wotton <mwotton@gmail.com> dateSun 9 Aug 2020, 11:47 (6 years ago) parentef7915f
5 files changed+86−71
README.md+40 package.yaml+11−2 roboservant.cabal+23−5 src/Roboservant.hs+5−1 stack.yaml+7−63
README.md+40
@@ -24,3 +24,43 @@ roboservant avoids this by using
2424[quickcheck-state-machine](https://github.com/advancedtelematic/quickcheck-state-machine#readme),
2525which models the dynamic state in such a way that we can use results
2626of previous calls.
27+
28+# concept
29+
30+we start with a servant api and a server that fulfills the type.
31+
32+From that api, we should be able to summon up an empty type-indexed store with a key
33+for each response type in the API.
34+
35+We can then look at each callable endpoint, and eliminate any that require values that are
36+empty in the type-indexed store. this allows a generative process where we can extend a sequence
37+of calls indefinitely, by making a call to the concrete server and recording the result in the
38+type-indexed store.
39+
40+## extensions
41+- add some "starter" values to the store
42+ - there may be a JWT that's established outside the servant app, for instance.
43+- `class Extras a where extras :: Gen [a]`
44+ - default implementation `pure []`
45+ - selectively allow some types to create values we haven't seen from the api.
46+ `newtype FirstName = FirstName Text`, say.
47+- break down each response type into its components
48+ - if i have
49+ - `data Foo = FBar Bar | FBaz Baz`
50+ - an endpoint `foo` that returns a `Foo`
51+ - and an endpoint `bar` that takes a `Bar`
52+ - I should be able to call `foo` to get a `Foo`, and if it happens to be an `FBar Bar`, I
53+ should be able to use that `Bar` to call `bar`.
54+
55+## applications
56+- testing
57+ - some properties should always hold (no 500s)
58+ - there may be some other properties that hold contextually
59+ - healthcheck should be 200
60+ - test complex permissions/ownership/delegation logic - should never be able to
61+ get access to something you don't own or haven't been delegated access to.
62+
63+- benchmarking
64+ - we can generate "big-enough" call sequences, then save the database & a sample call for each
65+ endpoint that takes long enough to be a reasonable test.
66+ - from this we can generate tests that a given call on that setup never gets slower.
package.yaml+11−2
@@ -21,9 +21,18 @@ description: Please see the README on GitHub at <https://github.com/gith
2121
2222dependencies:
2323- base >= 4.7 && < 5
24−- servant
25−# - servant-server
24+
25+- QuickCheck
26+- bytestring
27+- http-client
28+- quickcheck-state-machine
29+- servant >= 0.17
30+- servant-client >= 0.17
2631- servant-flatten
32+- servant-server >= 0.17
33+- string-conversions
34+- http-media
35+
2736# test deps
2837- hspec
2938library:
roboservant.cabal+23−5
@@ -4,7 +4,7 @@ cabal-version: 1.12
44--
55-- see: https://github.com/sol/hpack
66--
7−-- hash: f12f192f6c83606ae6175fd14eb83a7860480c38629bf904dbbdf6cfd980ed14
7+-- hash: e066fe1fb50c5d775ba730812d8afb9db9b9d14e08b2c25ca2277a1d7205d852
88
99name: roboservant
1010version: 0.1.0.0
@@ -28,15 +28,25 @@ source-repository head
2828library
2929 exposed-modules:
3030 Roboservant
31+ Roboservant.ContextualGenRequest
32+ Roboservant.StateMachine
3133 other-modules:
3234 Paths_roboservant
3335 hs-source-dirs:
3436 src
3537 build-depends:
36− base >=4.7 && <5
38+ QuickCheck
39+ , base >=4.7 && <5
40+ , bytestring
3741 , hspec
38− , servant
42+ , http-client
43+ , http-media
44+ , quickcheck-state-machine
45+ , servant >=0.17
46+ , servant-client >=0.17
3947 , servant-flatten
48+ , servant-server >=0.17
49+ , string-conversions
4050 default-language: Haskell2010
4151
4252test-suite roboservant-test
@@ -48,9 +58,17 @@ test-suite roboservant-test
4858 test
4959 ghc-options: -threaded -rtsopts -with-rtsopts=-N
5060 build-depends:
51− base >=4.7 && <5
61+ QuickCheck
62+ , base >=4.7 && <5
63+ , bytestring
5264 , hspec
65+ , http-client
66+ , http-media
67+ , quickcheck-state-machine
5368 , roboservant
54− , servant
69+ , servant >=0.17
70+ , servant-client >=0.17
5571 , servant-flatten
72+ , servant-server >=0.17
73+ , string-conversions
5674 default-language: Haskell2010
src/Roboservant.hs+5−1
@@ -13,13 +13,17 @@
1313{-# LANGUAGE TypeFamilies #-}
1414{-# LANGUAGE TypeOperators #-}
1515{-# LANGUAGE UndecidableInstances #-}
16−
16+{-# LANGUAGE FunctionalDependencies #-}
1717module Roboservant where
1818
1919import Control.Applicative
2020import GHC.TypeLits
2121import Servant.API
2222
23+import Roboservant.ContextualGenRequest
24+import Roboservant.StateMachine
25+
26+
2327type family ExtractRespType (path :: *) :: * where
2428 ExtractRespType (_ :> b) = ExtractRespType b
2529 ExtractRespType (Verb (method :: StdMethod) (responseCode :: Nat) (contentTypes :: [*]) (respType :: *)) = respType
stack.yaml+7−63
@@ -1,68 +1,12 @@
1−# This file was automatically generated by 'stack init'
2−#
3−# Some commonly used options have been documented as comments in this file.
4−# For advanced use and comprehensive documentation of the format, please see:
5−# https://docs.haskellstack.org/en/stable/yaml_configuration/
6−
7−# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8−# A snapshot resolver dictates the compiler version and the set of packages
9−# to be used for project dependencies. For example:
10−#
11−# resolver: lts-3.5
12−# resolver: nightly-2015-09-21
13−# resolver: ghc-7.10.2
14−#
15−# The location of a snapshot can be provided as a file or url. Stack assumes
16−# a snapshot provided as a file might change, whereas a url resource does not.
17−#
18−# resolver: ./custom-snapshot.yaml
19−# resolver: https://example.com/snapshots/2018-01-01.yaml
201resolver: lts-15.15
21−
22−# User packages to be built.
23−# Various formats can be used as shown in the example below.
24−#
25−# packages:
26−# - some-directory
27−# - https://example.com/foo/bar/baz-0.0.2.tar.gz
28−# subdirs:
29−# - auto-update
30−# - wai
312packages:
323- .
33−# Dependency packages to be pulled from upstream that are not in the resolver.
34−# These entries can reference officially published versions as well as
35−# forks / in-progress versions pinned to a git hash. For example:
36−#
37−# extra-deps:
38−# - acme-missiles-0.3
39−# - git: https://github.com/commercialhaskell/stack.git
40−# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
41−#
4+
425extra-deps:
436- servant-flatten-0.2@sha256:276896f7c5cdec5b8f8493f6205fded0cc602d050b58fdb09a6d7c85c3bb0837,1234
44−
45−
46−# Override default flag values for local packages and extra-deps
47−# flags: {}
48−
49−# Extra package databases containing global packages
50−# extra-package-dbs: []
51−
52−# Control whether we use the GHC we find on the path
53−# system-ghc: true
54−#
55−# Require a specific version of stack, using version ranges
56−# require-stack-version: -any # Default
57−# require-stack-version: ">=2.1"
58−#
59−# Override the architecture used by stack, especially useful on Windows
60−# arch: i386
61−# arch: x86_64
62−#
63−# Extra directories used by stack for building
64−# extra-include-dirs: [/path/to/dir]
65−# extra-lib-dirs: [/path/to/dir]
66−#
67−# Allow a newer minor version of GHC than the snapshot specifies
68−# compiler-check: newer-minor
7+- quickcheck-state-machine-0.7.0@sha256:4fc4467380e35b88aab72c278856aacebbf95688059d8ad70eb82fe048df476b,4958
8+- markov-chain-usage-model-0.0.0@sha256:1afa95faeb9213c4d960a669190078b41b89169462b8edd910472980671ba8c0,2112
9+- servant-0.17
10+- servant-client-0.17
11+- servant-client-core-0.17
12+- servant-server-0.17