mangopay 1.6.3 → 1.7.0
raw patch · 3 files changed
+23/−22 lines, 3 filesdep ~waidep ~warpPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: wai, warp
API changes (from Hackage documentation)
Files
- mangopay.cabal +3/−3
- src/Web/MangoPay/Monad.hs +1/−1
- test/Web/MangoPay/TestUtils.hs +19/−18
mangopay.cabal view
@@ -1,5 +1,5 @@ name: mangopay-version: 1.6.3+version: 1.7.0 cabal-version: >= 1.8 build-type: Simple author: JP Moresmau <jpmoresmau@gmail.com>@@ -108,8 +108,8 @@ , blaze-builder , HTF > 0.9 , HUnit >= 1.2.5- , wai- , warp+ , wai >= 3.0 && < 3.1+ , warp >= 3.0 && < 3.1 if flag(conduit11) build-depends: conduit-extra else
src/Web/MangoPay/Monad.hs view
@@ -40,7 +40,7 @@ #if DEBUG import Data.Conduit.Binary (sinkHandle) import System.IO (stdout)-import Data.Conduit.Util (zipSinks)+import Data.Conduit.Internal (zipSinks) import qualified Data.ByteString.Lazy.Char8 as BSLC import Control.Monad.IO.Class (liftIO) #endif
test/Web/MangoPay/TestUtils.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE RankNTypes,OverloadedStrings,DeriveDataTypeable, ConstraintKinds, FlexibleContexts, PatternGuards #-}+{-# LANGUAGE ConstraintKinds, DeriveDataTypeable, FlexibleContexts,+ OverloadedStrings, PatternGuards, RankNTypes #-} {-# OPTIONS_GHC -F -pgmF htfpp #-} module Web.MangoPay.TestUtils where @@ -20,7 +21,7 @@ import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Resource (ResourceT, runResourceT) -import Data.Text as T (Text, unpack, isPrefixOf) +import Data.Text as T (Text, unpack, isPrefixOf) import Data.List import Data.Typeable import Control.Applicative@@ -65,10 +66,10 @@ -- | the test state we keep over all tests data TestState=TestState {- tsAccessToken :: AccessToken -- ^ the access token if we're logged in- ,tsCredentials :: Credentials -- ^ the credentials- ,tsManager :: H.Manager -- ^ the http manager- ,tsHookEndPoint :: HookEndPoint -- ^ the end point for notifications+ tsAccessToken :: AccessToken -- ^ the access token if we're logged in+ ,tsCredentials :: Credentials -- ^ the credentials+ ,tsManager :: H.Manager -- ^ the http manager+ ,tsHookEndPoint :: HookEndPoint -- ^ the end point for notifications ,tsReceivedEvents :: ReceivedEvents -- ^ the received events } @@ -83,7 +84,7 @@ -- | simple configuration to tell the tests what endpoint to use for notifications data HookEndPoint = HookEndPoint{- hepUrl :: Text+ hepUrl :: Text ,hepPort :: Int } deriving (Show,Read,Eq,Ord,Typeable) @@ -187,8 +188,8 @@ waitForEvent rc fs (del-1) (Just (Right evt),_)-> do -- an event, does it match ok <- testMP $ checkEvent evt- if ok - then + if ok+ then case Data.List.foldl' (match1 evt) ([],False) fs of (_,False)->return $ ExtraEvent evt -- doesn't match (fs2,_)-> waitForEvent rc fs2 del -- matched, either we have more to do or we need to check no unexpected event was found@@ -234,7 +235,7 @@ startHTTPServer p revts= forkIO $ run p app where- app req = do+ app req respond = do when (pathInfo req == ["mphook"]) $ do let mevt=eventFromQueryString $ W.queryString req liftIO $ case mevt of@@ -242,7 +243,7 @@ pushReceivedEvent revts $ Right evt putStrLn $ "Received event:" ++ show evt Nothing->pushReceivedEvent revts $ Left $ UnhandledNotification $ show $ W.queryString req- return $ W.responseBuilder status200 [("Content-Type", "text/plain")] $ copyByteString "noop"+ respond $ W.responseBuilder status200 [("Content-Type", "text/plain")] $ copyByteString "noop" -- | perform the full registration of a card@@ -268,7 +269,7 @@ Just ak <- crAccessKey cr=do ior<-readIORef testState let mgr=tsManager ior- req <-H.parseUrl $ T.unpack url + req <-H.parseUrl $ T.unpack url let b=HT.renderQuery False $ HT.toQuery [ "accessKeyRef" ?+ ak ,"data" ?+ pre@@ -277,13 +278,13 @@ ,"cardCvx" ?+ ciCSC ci] let req'=req {H.method=HT.methodPost , H.requestHeaders=[("content-type","application/x-www-form-urlencoded")]- , H.requestBody=H.RequestBodyBS b} - reg<- runResourceT $ do + , H.requestBody=H.RequestBodyBS b}+ reg<- runResourceT $ do res<-H.http req' mgr H.responseBody res $$+- EL.consume let t=TE.decodeUtf8 $ BS.concat reg- assertBool $ "data=" `T.isPrefixOf` t + assertBool $ "data=" `T.isPrefixOf` t return cr{crRegistrationData=Just t}-unsafeRegisterCard _ _=assertFailure "CardRegistration not ready" - - +unsafeRegisterCard _ _=assertFailure "CardRegistration not ready"++