Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Apr 2, 2015
1 parent c5b21af commit 4684a4c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 4 additions & 0 deletions wai-extra/ChangeLog.md
@@ -1,3 +1,7 @@
## 3.0.6

* Add Cookie Handling to Network.Wai.Test [#356](https://github.com/yesodweb/wai/pull/356)

## 3.0.5

* add functions to extract authentication data from Authorization header [#352](add functions to extract authentication data from Authorization header #352)
Expand Down
27 changes: 25 additions & 2 deletions wai-extra/Network/Wai/Test.hs
Expand Up @@ -63,25 +63,39 @@ import Data.Time.Clock (getCurrentTime)

type Session = ReaderT Application (ST.StateT ClientState IO)

-- |
--
-- Since 3.0.6
type ClientCookies = Map ByteString Cookie.SetCookie

data ClientState = ClientState
{ clientCookies :: ClientCookies
}

-- |
--
-- Since 3.0.6
getClientCookies :: Session ClientCookies
getClientCookies = clientCookies <$> lift ST.get

-- |
--
-- Since 3.0.6
modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session ()
modifyClientCookies f =
lift (ST.modify (\cs -> cs { clientCookies = f $ clientCookies cs }))

-- |
--
-- Since 3.0.6
setClientCookie :: Cookie.SetCookie -> Session ()
setClientCookie c =
modifyClientCookies
(Map.union
(Map.singleton (Cookie.setCookieName c) c))
(Map.insert (Cookie.setCookieName c) c)

-- |
--
-- Since 3.0.6
deleteClientCookie :: ByteString -> Session ()
deleteClientCookie cookieName =
modifyClientCookies
Expand Down Expand Up @@ -280,16 +294,25 @@ assertNoHeader header SResponse{simpleHeaders = h} =
, show s
]

-- |
--
-- Since 3.0.6
assertClientCookieExists :: String -> ByteString -> Session ()
assertClientCookieExists s cookieName = do
cookies <- getClientCookies
assertBool s $ Map.member cookieName cookies

-- |
--
-- Since 3.0.6
assertNoClientCookieExists :: String -> ByteString -> Session ()
assertNoClientCookieExists s cookieName = do
cookies <- getClientCookies
assertBool s $ not $ Map.member cookieName cookies

-- |
--
-- Since 3.0.6
assertClientCookieValue :: String -> ByteString -> ByteString -> Session ()
assertClientCookieValue s cookieName cookieValue = do
cookies <- getClientCookies
Expand Down
2 changes: 1 addition & 1 deletion wai-extra/wai-extra.cabal
@@ -1,5 +1,5 @@
Name: wai-extra
Version: 3.0.5
Version: 3.0.6
Synopsis: Provides some basic WAI handlers and middleware.
description:
Provides basic WAI handler and middleware functionality:
Expand Down

0 comments on commit 4684a4c

Please sign in to comment.