def testCustomerInfoDob(self): auth = litleXmlFields.authorization(); auth.reportGroup = 'Planets' auth.orderId = '12344' auth.amount = 106 auth.orderSource = 'ecommerce' card = litleXmlFields.cardType() card.type = 'VI' card.number = '4100000000000002' card.expDate = '1210' auth.card = card customerInfo = litleXmlFields.customerInfo() customerInfo.dob = '1980-04-14' auth.customerInfo = customerInfo comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(auth) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?<dob>1980-04-14</dob>.*?</authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testAuthWithcustomAttributeOneToFive(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' advancedFraudChecksType=litleXmlFields.advancedFraudChecksType() advancedFraudChecksType.customAttribute1='stringlength200' advancedFraudChecksType.customAttribute2='stringlength200' advancedFraudChecksType.customAttribute3='stringlength200' advancedFraudChecksType.customAttribute4='stringlength200' advancedFraudChecksType.customAttribute5='stringlength200' card = litleXmlFields.cardType() card.number = "4100000000000000" card.expDate = "1210" card.type = 'VI' authorization.card = card authorization.advancedFraudChecks=advancedFraudChecksType comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?<card>.*?<number>4100000000000000</number>.*?</card>.*?<advancedFraudChecks.*?<customAttribute4>stringlength200</customAttribute4>.*?</advancedFraudChecks></authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testCustomerInfoDob(self): auth = litleXmlFields.authorization(); auth.reportGroup = 'Planets' auth.orderId = '12344' auth.amount = 106 auth.orderSource = 'ecommerce' auth.id="id" card = litleXmlFields.cardType() card.type = 'VI' card.number = '4100000000000002' card.expDate = '1210' auth.card = card customerInfo = litleXmlFields.customerInfo() customerInfo.dob = '1980-04-14' auth.customerInfo = customerInfo comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(auth) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?<dob>1980-04-14</dob>.*?</authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testAuthWithcustomAttributeOneToFive(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' authorization.id="id" advancedFraudChecksType=litleXmlFields.advancedFraudChecksType() advancedFraudChecksType.customAttribute1='stringlength200' advancedFraudChecksType.customAttribute2='stringlength200' advancedFraudChecksType.customAttribute3='stringlength200' advancedFraudChecksType.customAttribute4='stringlength200' advancedFraudChecksType.customAttribute5='stringlength200' card = litleXmlFields.cardType() card.number = "4100000000000000" card.expDate = "1210" card.type = 'VI' authorization.card = card authorization.advancedFraudChecks=advancedFraudChecksType comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?<card>.*?<number>4100000000000000</number>.*?</card>.*?<advancedFraudChecks.*?<customAttribute4>stringlength200</customAttribute4>.*?</advancedFraudChecks></authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testExtraField(self): auth = litleXmlFields.authorization() auth.orderId = '1234' auth.amount = 106 auth.orderSource = 'ecommerce' auth.extraField = "extra" auth.id="id" card = litleXmlFields.cardType() card.number = "4100000000000000" card.expDate = "1210" card.type = 'VI' auth.card = card comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(auth) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?</orderSource><card>.*?<number>4100000000000000</number>.*?</card>.*?</authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testTrackData(self): authorization = litleXmlFields.authorization() authorization.id = 'AX54321678' authorization.reportGroup = 'RG27' authorization.orderId = '12z58743y1' authorization.amount = 12522 authorization.orderSource = 'retail' billToAddress = litleXmlFields.contact() billToAddress.zip = '95032' authorization.billToAddress = billToAddress card = litleXmlFields.cardType() card.track = "%B40000001^Doe/JohnP^06041...?;40001=0604101064200?" authorization.card = card pos = litleXmlFields.pos() pos.capability = 'magstripe' pos.entryMode = 'completeread' pos.cardholderId = 'signature' authorization.pos = pos litleXml = litleOnlineRequest(self.config) response = litleXml.sendRequest(authorization) assert(response.message == 'Approved')
def auth_fixture(): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 110 authorization.orderSource = 'ecommerce' return authorization
def testAddAuth(self): batchRequest = self.litleBatchFileRequest.createBatch() auth = litleXmlFields.authorization() auth.amount = 25 self.litleBatchFileRequest.tnxToXml = MagicMock(return_value='') batchRequest.addTransaction(auth) assert(batchRequest._batchRequest.authAmount == 25) assert(batchRequest._batchRequest.numAuths == 1) assert(batchRequest.numOfTxn == 1)
def testInvalidEnum(self): auth = litleXmlFields.authorization() auth.orderId = '1234' auth.amount = 106 auth.orderSource = 'ecommerce' auth.extraField = "extra" card = litleXmlFields.cardType() card.number = "4100000000000000" card.expDate = "1210" with self.assertRaises(pyxb.BadTypeValueError): card.type = 'VC' auth.card = card
def testAuthWithSecondaryAmountAndApplePayAndWallet(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' authorization.secondaryAmount = 10 wallet = litleXmlFields.wallet() wallet.walletSourceType = 'MasterPass' wallet.walletSourceTypeId = '12345' applepay = litleXmlFields.applepayType() applepay.data = "4100000000000000" applepay.signature = "yoyo" applepay.version = '9.3' header = litleXmlFields.applepayHeaderType() header.applicationData = 'applicationData' header.ephemeralPublicKey = 'UWIRNRSKSXMXEYEINR' header.publicKeyHash = 'UYTGHJKMNBVFYWUWI' header.transactionId = '1024' applepay.header = header authorization.applepay = applepay authorization.wallet = wallet comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization) comm.http_post.assert_called_once() match_re = RegexMatcher( ".*?<litleOnlineRequest.*?<authorization.*?<applepay>.*?<data>4100000000000000</data>.*?</applepay>.*?<wallet.*?</wallet>.*?</authorization>.*?" ) comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testExtraChoices(self): auth = litleXmlFields.authorization() auth.orderId = '1234' auth.amount = 106 auth.orderSource = 'ecommerce' card = litleXmlFields.cardType() card.number = "4100000000000000" card.expDate = "1210" card.type = 'VI' auth.card = card paypal = litleXmlFields.payPal() paypal.payerId = "1234" paypal.token = "1234" paypal.transactionId = '123456' auth.paypal = paypal litle = litleOnlineRequest(config) with self.assertRaises(Exception): litle.sendRequest(auth)
def testAuthenticationValueMaxlength(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' authorization.secondaryAmount = '10' fraudCheck=litleXmlFields.fraudCheckType() encoded = base64.b64encode('data to be encodedaaaaaaaaaabbbbbbbbbbcc') #generating a base64 encoded data of length 56, expect no exception self.assertEquals(56,len(encoded)) fraudCheck.authenticationValue=encoded authorization.cardholderAuthentication=fraudCheck comm = Communications(config) #create an communication using config comm.http_post = MagicMock() #go deep into mock, some magic happened and http_post was set for com litle = litleOnlineRequest(config) #initial litleonlinerequest litle.setCommunications(comm) #use previous settled comm litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization)
def testAuthenticationValueMaxlength(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' authorization.secondaryAmount = '10' authorization.id="id" fraudCheck=litleXmlFields.fraudCheckType() encoded = base64.b64encode('data to be encodedaaaaaaaaaabbbbbbbbbbcc') #generating a base64 encoded data of length 56, expect no exception self.assertEquals(56,len(encoded)) fraudCheck.authenticationValue=encoded authorization.cardholderAuthentication=fraudCheck comm = Communications(config) #create an communication using config comm.http_post = MagicMock() #go deep into mock, some magic happened and http_post was set for com litle = litleOnlineRequest(config) #initial litleonlinerequest litle.setCommunications(comm) #use previous settled comm litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization)
def testAuthWithSecondaryAmountAndApplePayAndWallet(self): authorization = litleXmlFields.authorization() authorization.orderId = '1234' authorization.amount = 106 authorization.orderSource = 'ecommerce' authorization.secondaryAmount = 10 authorization.id="id" wallet=litleXmlFields.wallet() wallet.walletSourceType='MasterPass' wallet.walletSourceTypeId='12345' applepay = litleXmlFields.applepayType() applepay.data = "4100000000000000" applepay.signature = "yoyo" applepay.version = '9.3' header=litleXmlFields.applepayHeaderType() header.applicationData='applicationData' header.ephemeralPublicKey ='UWIRNRSKSXMXEYEINR' header.publicKeyHash='UYTGHJKMNBVFYWUWI' header.transactionId='1024' applepay.header=header authorization.applepay = applepay authorization.wallet=wallet comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(authorization) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<authorization.*?<applepay>.*?<data>4100000000000000</data>.*?</applepay>.*?<wallet.*?</wallet>.*?</authorization>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)