wai-extra-3.1.18: Provides some basic WAI handlers and middleware.

Safe Haskell | None
Language | Haskell2010

Network.Wai.Test

Contents

- Session
- Client Cookies
- Requests
- Assertions

Synopsis

- type Session = ReaderT Application (StateT ClientState IO)
- runSession :: Session a -> Application -> IO a
- withSession :: Application -> Session a -> IO a
- type ClientCookies = Map ByteString SetCookie
- getClientCookies :: Session ClientCookies
- modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session ()
- setClientCookie :: SetCookie -> Session ()
- deleteClientCookie :: ByteString -> Session ()
- request :: Request -> Session SResponse
- srequest :: SRequest -> Session SResponse
- data SRequest = SRequest {
  - simpleRequest :: Request
  - simpleRequestBody :: ByteString
  }
- data SResponse = SResponse {
  - simpleStatus :: Status
  - simpleHeaders :: ResponseHeaders
  - simpleBody :: ByteString
  }
- defaultRequest :: Request
- setPath :: Request -> ByteString -> Request
- setRawPathInfo :: Request -> ByteString -> Request
- assertStatus :: HasCallStack => Int -> SResponse -> Session ()
- assertContentType :: HasCallStack => ByteString -> SResponse -> Session ()
- assertBody :: HasCallStack => ByteString -> SResponse -> Session ()
- assertBodyContains :: HasCallStack => ByteString -> SResponse -> Session ()
- assertHeader :: HasCallStack => CI ByteString -> ByteString -> SResponse -> Session ()
- assertNoHeader :: HasCallStack => CI ByteString -> SResponse -> Session ()
- assertClientCookieExists :: HasCallStack => String -> ByteString -> Session ()
- assertNoClientCookieExists :: HasCallStack => String -> ByteString -> Session ()
- assertClientCookieValue :: HasCallStack => String -> ByteString -> ByteString -> Session ()

# Session

type Session = ReaderT Application (StateT ClientState IO) Source #

runSession :: Session a -> Application -> IO a Source #

See also: `runSessionWith`.

withSession :: Application -> Session a -> IO a Source #

Synonym for 'flip runSession'

# Client Cookies

type ClientCookies = Map ByteString SetCookie Source #

Since 3.0.6

getClientCookies :: Session ClientCookies Source #

Since 3.0.6

modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session () Source #

Since 3.0.6

setClientCookie :: SetCookie -> Session () Source #

Since 3.0.6

deleteClientCookie :: ByteString -> Session () Source #

Since 3.0.6

# Requests

request :: Request -> Session SResponse Source #

srequest :: SRequest -> Session SResponse Source #

Similar to `request`, but allows setting the request body as a plain `ByteString`.

data SRequest Source #

Constructors

SRequest |

Fields

- simpleRequest :: Request
- simpleRequestBody :: ByteString

  Request body that will override the one set in `simpleRequest`.

  This is usually simpler than setting the body as a stateful IO-action in `simpleRequest`.

data SResponse Source #

Constructors

SResponse |

Fields

- simpleStatus :: Status
- simpleHeaders :: ResponseHeaders
- simpleBody :: ByteString

#### Instances

Instances details

Show SResponse Source # |
Instance details Defined in Network.Wai.Test Methods showsPrec :: Int -> SResponse -> ShowS Source # show :: SResponse -> String Source # showList :: [SResponse] -> ShowS Source #
Eq SResponse Source # |
Instance details Defined in Network.Wai.Test Methods (==) :: SResponse -> SResponse -> Bool Source # (/=) :: SResponse -> SResponse -> Bool Source #

defaultRequest :: Request Source #

A default, blank request.

Since: wai-2.0.0

setPath :: Request -> ByteString -> Request Source #

Set whole path (request path + query string).

setRawPathInfo :: Request -> ByteString -> Request Source #

# Assertions

assertStatus :: HasCallStack => Int -> SResponse -> Session () Source #

assertContentType :: HasCallStack => ByteString -> SResponse -> Session () Source #

assertBody :: HasCallStack => ByteString -> SResponse -> Session () Source #

assertBodyContains :: HasCallStack => ByteString -> SResponse -> Session () Source #

assertHeader :: HasCallStack => CI ByteString -> ByteString -> SResponse -> Session () Source #

assertNoHeader :: HasCallStack => CI ByteString -> SResponse -> Session () Source #

assertClientCookieExists :: HasCallStack => String -> ByteString -> Session () Source #

Since 3.0.6

assertNoClientCookieExists :: HasCallStack => String -> ByteString -> Session () Source #

Since 3.0.6

assertClientCookieValue :: HasCallStack => String -> ByteString -> ByteString -> Session () Source #

Since 3.0.6