mangopay-1.9.5.1: Bindings to the MangoPay API

Safe HaskellNone

Web.MangoPay.TestUtils

Contents

Synopsis

Initialization

withMangoPayTestUtilsSource

Arguments

:: IO a

Action to run while being able to use functions from this module.

-> IO a 

Creates and initializes the MangoPay infrastructure needed to use the test helpers from this module. Tears down the server at the end.

You may want to use ensureNoEvents at the end of your action before tearing down the server.

This module uses global, shared state. You have to wrap your entire test suite with this function, and you can't use withMangoPayTests more than once.

Reads two files from the current directory:

  • client.test.conf (can be generated by mangopay-passphrase).
  • hook.test.conf, json file containing object with Url and Port fields. The first is the URL used to access this server's root, while the second is the port this server should listen to.

withMangoPayTestUtils'Source

Arguments

:: (Credentials -> Manager -> IO a)

Action to run while being able to use functions from this module.

-> IO a 

Same as withMangoPayTestUtils, but also gives more information about the environment to the action.

Test helpers

testMP :: (AccessToken -> MangoPayT (LoggingT (ResourceT IO)) b) -> IO bSource

Test MangoPay API call, logging in with the client credentials. Expects a file called client.test.conf containing the JSON of client credentials in the current directory.

testEventTypes :: [EventType] -> IO (Maybe Text) -> AssertionSource

Run the given test, then check that we've received events of the given types which reference resource id returned by the test.

testEventTypes' :: [EventType] -> IO (Maybe Text) -> IO (Maybe Text)Source

Same as testEventTypes, but also return the resource id.

Credit card registration

unsafeFullRegistration :: MPUsableMonad m => AnyUserId -> Currency -> CardInfo -> AccessToken -> MangoPayT m CardRegistrationSource

Perform the full registration of a card.

This function is UNSAFE, because if you use this, YOU handle the user's credit card details so you need to be PCI compliant!

unsafeRegisterCard :: CardInfo -> CardRegistration -> IO CardRegistrationSource

Register a card with the registration URL.

This function is UNSAFE, because if you use this, YOU handle the user's credit card details so you need to be PCI compliant!

XXX This is not working anymore.

Tear down

ensureNoEvents :: Int -> AssertionSource

Wait for the given number of seconds and check if any MangoPay event has arrived. Fails if so. Use this function at the end of your test run to ensure that you're aware of every MangoPay event.