Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/197690
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment bbf5839 Don't fraud-fail on STATUSID 25 b26ca65 Localisation updates from https://translatewiki.net. c5bbe27 Localisation updates from https://translatewiki.net. Change-Id: Ib40a80a689e4205485e2694d0cd1bf68a9443ac3 --- D tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php D tests/Adapter/GlobalCollect/GlobalCollectTest.php D tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse D tests/includes/Responses/globalcollect/SET_PAYMENT_25.testresponse 4 files changed, 0 insertions(+), 704 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/90/197690/1 diff --git a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php deleted file mode 100644 index 01526c8..0000000 --- a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php +++ /dev/null @@ -1,173 +0,0 @@ -<<<<<<< HEAD (877580 Merge branch 'master' into deployment) -======= -<?php - -/** - * Wikimedia Foundation - * - * LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -use Psr\Log\LogLevel; - -/** - * - * @group Fundraising - * @group DonationInterface - * @group GlobalCollect - * @group OrphanSlayer - */ -class DonationInterface_Adapter_GlobalCollect_Orphans_GlobalCollectTest extends DonationInterfaceTestCase { - - /** - * @param $name string The name of the test case - * @param $data array Any parameters read from a dataProvider - * @param $dataName string|int The name or index of the data set - */ - function __construct( $name = null, array $data = array(), $dataName = '' ) { - parent::__construct( $name, $data, $dataName ); - $this->testAdapterClass = 'TestingGlobalCollectOrphanAdapter'; - $this->dummy_utm_data = array ( - 'utm_source' => 'dummy_source', - 'utm_campaign' => 'dummy_campaign', - 'utm_medium' => 'dummy_medium', - 'date' => time(), - ); - } - - public function testConstructor() { - - $options = $this->getDonorTestData(); - $class = $this->testAdapterClass; - - $gateway = $this->getFreshGatewayObject(); - - $this->assertInstanceOf( $class, $gateway ); - - $this->verifyNoLogErrors(); - } - - - public function testBatchOrderID_generate() { - - //no data on construct, generate Order IDs - $gateway = $this->getFreshGatewayObject( null, array ( 'order_id_meta' => array ( 'generate' => TRUE ) ) ); - $this->assertTrue( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Order_id generation may be broken.' ); - $this->assertNotNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed asserting that an absent order id is not left as null, when generating our own' ); - - $data = array_merge( $this->getDonorTestData(), $this->dummy_utm_data ); - $data['order_id'] = '55555'; - - //now, add data and check that we didn't kill the oid. Still generating. - $gateway->loadDataAndReInit( $data, $useDB = false ); - $this->assertEquals( $gateway->getData_Unstaged_Escaped( 'order_id' ), '55555', 'loadDataAndReInit failed to stick OrderID' ); - - $data['order_id'] = '444444'; - $gateway->loadDataAndReInit( $data, $useDB = false ); - $this->assertEquals( $gateway->getData_Unstaged_Escaped( 'order_id' ), '444444', 'loadDataAndReInit failed to stick OrderID' ); - - $this->verifyNoLogErrors(); - } - - public function testBatchOrderID_no_generate() { - - //no data on construct, do not generate Order IDs - $gateway = $this->getFreshGatewayObject( null, array ( 'order_id_meta' => array ( 'generate' => FALSE ) ) ); - $this->assertFalse( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Deferred order_id generation may be broken.' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed asserting that an absent order id is left as null, when not generating our own' ); - - $data = array_merge( $this->getDonorTestData(), $this->dummy_utm_data ); - $data['order_id'] = '66666'; - - //now, add data and check that we didn't kill the oid. Still not generating - $gateway->loadDataAndReInit( $data, $useDB = false ); - $this->assertEquals( $gateway->getData_Unstaged_Escaped( 'order_id' ), '66666', 'loadDataAndReInit failed to stick OrderID' ); - - $data['order_id'] = '777777'; - $gateway->loadDataAndReInit( $data, $useDB = false ); - $this->assertEquals( $gateway->getData_Unstaged_Escaped( 'order_id' ), '777777', 'loadDataAndReInit failed to stick OrderID on second batch item' ); - - $this->verifyNoLogErrors(); - } - - public function testGCFormLoad() { - $init = $this->getDonorTestData( 'US' ); - unset( $init['order_id'] ); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['ffname'] = 'cc-vmad'; - - $assertNodes = array ( - 'cc-mc' => array ( - 'nodename' => 'input' - ), - 'selected-amount' => array ( - 'nodename' => 'span', - 'innerhtml' => '$1.55', - ), - 'state' => array ( - 'nodename' => 'select', - 'selected' => 'CA', - ), - ); - - $this->verifyFormOutput( 'TestingGlobalCollectGateway', $init, $assertNodes, true ); - } - - /** - * Tests to make sure that certain error codes returned from GC will - * trigger order cancellation, even if retryable errors also exist. - * @dataProvider mcNoRetryCodeProvider - */ - public function testNoMastercardFinesForRepeatOnBadCodes( $code ) { - $gateway = $this->getFreshGatewayObject( null, array ( 'order_id_meta' => array ( 'generate' => FALSE ) ) ); - - //Toxic card should not retry, even if there's an order id collision - $init = array_merge( $this->getDonorTestData(), $this->dummy_utm_data ); - $init['ffname'] = 'cc-vmad'; - $init['order_id'] = '55555'; - $init['email'] = 'innoc...@clean.com'; - $gateway->loadDataAndReInit( $init, $useDB = false ); - - $gateway->setDummyGatewayResponseCode( $code ); - $result = $gateway->do_transaction( 'Confirm_CreditCard' ); - $this->assertEquals( 1, count( $gateway->curled ), "Gateway kept trying even with response code $code! MasterCard could fine us a thousand bucks for that!" ); - $this->assertEquals( false, $result['status'], "Error code $code should mean status of do_transaction is false" ); - $this->assertTrue( array_key_exists( 'errors', $result ), 'Orphan adapter needs to see the errors to consider it rectified' ); - $this->assertTrue( array_key_exists('1000001', $result['errors'] ), 'Orphan adapter needs error 1000001 to consider it rectified' ); - $loglines = $this->getLogMatches( LogLevel::INFO, "/Got error code $code, not retrying to avoid MasterCard fines./" ); - $this->assertNotEmpty( $loglines, "GC Error $code is not generating the expected payments log error" ); - } - - /** - * Don't fraud-fail someone for bad CVV if GET_ORDERSTATUS - * comes back with STATUSID 25 and no CVVRESULT - * @group CvvResult - */ - function testConfirmCreditCardStatus25() { - $gateway = $this->getFreshGatewayObject( null, array ( 'order_id_meta' => array ( 'generate' => FALSE ) ) ); - - $init = array_merge( $this->getDonorTestData(), $this->dummy_utm_data ); - $init['ffname'] = 'cc-vmad'; - $init['order_id'] = '55555'; - $init['email'] = 'innoc...@clean.com'; - - $gateway->loadDataAndReInit( $init, $useDB = false ); - $gateway->setDummyGatewayResponseCode( '25' ); - - $gateway->do_transaction( 'Confirm_CreditCard' ); - $action = $gateway->getValidationAction(); - $this->assertEquals( 'process', $action, 'Gateway should not fraud fail on STATUSID 25' ); - } -} ->>>>>>> BRANCH (bbf583 Don't fraud-fail on STATUSID 25) diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTest.php b/tests/Adapter/GlobalCollect/GlobalCollectTest.php deleted file mode 100644 index 36cec99..0000000 --- a/tests/Adapter/GlobalCollect/GlobalCollectTest.php +++ /dev/null @@ -1,465 +0,0 @@ -<<<<<<< HEAD (877580 Merge branch 'master' into deployment) -======= -<?php -/** - * Wikimedia Foundation - * - * LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -use Psr\Log\LogLevel; - -/** - * - * @group Fundraising - * @group DonationInterface - * @group GlobalCollect - */ -class DonationInterface_Adapter_GlobalCollect_GlobalCollectTest extends DonationInterfaceTestCase { - - /** - * @param $name string The name of the test case - * @param $data array Any parameters read from a dataProvider - * @param $dataName string|int The name or index of the data set - */ - function __construct( $name = null, array $data = array(), $dataName = '' ) { - parent::__construct( $name, $data, $dataName ); - $this->testAdapterClass = 'TestingGlobalCollectAdapter'; - } - - function tearDown() { - TestingGlobalCollectAdapter::clearGlobalsCache(); - parent::tearDown(); - } - - /** - * testnormalizeOrderID - * Non-exhaustive integration tests to verify that order_id - * normalization works as expected with different settings and - * conditions in theGlobalCollect adapter - * @covers GatewayAdapter::normalizeOrderID - */ - public function testNormalizeOrderID() { - $init = $this->initial_vars; - unset( $init['order_id'] ); - - //no order_id from anywhere, explicit no generate - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => FALSE ) ) ); - $this->assertFalse( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Deferred order_id generation may be broken.' ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed asserting that an absent order id is left as null, when not generating our own' ); - - //no order_id from anywhere, explicit generate - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => TRUE ) ) ); - $this->assertTrue( $gateway->getOrderIDMeta( 'generate' ), 'The order_id meta generate setting override is not working properly. Self order_id generation may be broken.' ); - $this->assertInternalType( 'numeric', $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Generated order_id is not numeric, which it should be for GlobalCollect' ); - - $_GET['order_id'] = '55555'; - $_SESSION['Donor']['order_id'] = '44444'; - - //conflicting order_id in $GET and $SESSION, default GC generation - $gateway = $this->getFreshGatewayObject( $init ); - $this->assertEquals( '55555', $gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is preferring session data over the $_GET. Session should be secondary.' ); - - //conflicting order_id in $GET and $SESSION, garbage data in $_GET, default GC generation - $_GET['order_id'] = 'nonsense!'; - $gateway = $this->getFreshGatewayObject( $init ); - $this->assertEquals( '44444', $gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is not ignoring nonsensical order_id candidates' ); - - unset( $_GET['order_id'] ); - //order_id in $SESSION, default GC generation - $gateway = $this->getFreshGatewayObject( $init ); - $this->assertEquals( '44444', $gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is not recognizing the session order_id' ); - - $_POST['order_id'] = '33333'; - //conflicting order_id in $_POST and $SESSION, default GC generation - $gateway = $this->getFreshGatewayObject( $init ); - $this->assertEquals( '33333', $gateway->getData_Unstaged_Escaped( 'order_id' ), 'GlobalCollect gateway is preferring session data over the $_POST. Session should be secondary.' ); - - $init['order_id'] = '22222'; - //conflicting order_id in init data, $_POST and $SESSION, explicit GC generation, batch mode - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => TRUE ), 'batch_mode' => TRUE, ) ); - $this->assertEquals( $init['order_id'], $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed asserting that an extrenally provided order id is being honored in batch mode' ); - - //make sure that decimal numbers are rejected by GC. Should be a toss and regen - $init['order_id'] = '2143.0'; - unset( $_POST['order_id'] ); - unset( $_SESSION['Donor']['order_id'] ); - //conflicting order_id in init data, $_POST and $SESSION, explicit GC generation, batch mode - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => TRUE, 'disallow_decimals' => TRUE ), 'batch_mode' => TRUE, ) ); - $this->assertNotEquals( $init['order_id'], $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Failed assering that a decimal order_id was regenerated, when disallow_decimals is true' ); - } - - /** - * Non-exhaustive integration tests to verify that order_id, when in - * self-generation mode, won't regenerate until it is told to. - * @covers GatewayAdapter::normalizeOrderID - * @covers GatewayAdapter::regenerateOrderID - */ - function testStickyGeneratedOrderID() { - $init = $this->initial_vars; - unset( $init['order_id'] ); - - //no order_id from anywhere, explicit generate - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => TRUE ) ) ); - $this->assertNotNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Generated order_id is null. The rest of this test is broken.' ); - $original_order_id = $gateway->getData_Unstaged_Escaped( 'order_id' ); - - $gateway->normalizeOrderID(); - $this->assertEquals( $original_order_id, $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Re-normalized order_id has changed without explicit regeneration.' ); - - //this might look a bit strange, but we need to be able to generate valid order_ids without making them stick to anything. - $gateway->generateOrderID(); - $this->assertEquals( $original_order_id, $gateway->getData_Unstaged_Escaped( 'order_id' ), 'function generateOrderID auto-changed the selected order ID. Not cool.' ); - - $gateway->regenerateOrderID(); - $this->assertNotEquals( $original_order_id, $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Re-normalized order_id has not changed, after explicit regeneration.' ); - } - - /** - * Integration test to verify that order_id can be retrieved from - * performing an INSERT_ORDERWITHPAYMENT. - */ - function testOrderIDRetrieval() { - $init = $this->getDonorTestData(); - unset( $init['order_id'] ); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - - //no order_id from anywhere, explicit generate - $gateway = $this->getFreshGatewayObject( $init, array ( 'order_id_meta' => array ( 'generate' => FALSE ) ) ); - $this->assertNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'Ungenerated order_id is not null. The rest of this test is broken.' ); - - $gateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); - - $this->assertNotNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), 'No order_id was retrieved from INSERT_ORDERWITHPAYMENT' ); - } - - /** - * Just run the GET_ORDERSTATUS transaction and make sure we load the data - */ - function testGetOrderStatus() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['email'] = 'innoc...@safedomain.org'; - - $gateway = $this->getFreshGatewayObject( $init ); - - $gateway->do_transaction( 'GET_ORDERSTATUS' ); - - $data = $gateway->getTransactionData(); - - $this->assertEquals( 'N', $data['CVVRESULT'], 'CVV Result not loaded from XML response' ); - } - - /** - * Don't fraud-fail someone for bad CVV if GET_ORDERSTATUS - * comes back with STATUSID 25 and no CVVRESULT - * @group CvvResult - */ - function testConfirmCreditCardStatus25() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['email'] = 'innoc...@safedomain.org'; - - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( 'CVVRESULT' => 'M' ), false ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( '25' ); - - $gateway->do_transaction( 'Confirm_CreditCard' ); - $action = $gateway->getValidationAction(); - $this->assertEquals( 'process', $action, 'Gateway should not fraud fail on STATUSID 25' ); - } - - /** - * We should skip the API call if we're already suspicious - */ - function testGetOrderStatusSkipsIfFail() { - DonationInterface_FraudFiltersTest::setupFraudMaps(); - - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['email'] = 'swhipl...@wikipedia.org'; //configured as a fraudy domain - - $gateway = $this->getFreshGatewayObject( $init ); - - $gateway->do_transaction( 'GET_ORDERSTATUS' ); - - $data = $gateway->getTransactionData(); - - $this->assertEquals( null, $data['CVVRESULT'], 'preprocess should stop API call if fraud detected' ); - } - - /** - * Ensure the Confirm_CreditCard transaction prefers CVVRESULT from the XML - * over any value from the querystring - */ - function testConfirmCreditCardPrefersXmlCvv() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['email'] = 'innoc...@safedomain.org'; - - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( 'CVVRESULT' => 'M' ), false ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - - $gateway->do_transaction( 'Confirm_CreditCard' ); - - $this->assertEquals( 'N', $gateway->getData_Unstaged_Escaped('cvv_result'), 'CVV Result not taken from XML response' ); - } - - /** - * If querystring and XML have different CVVRESULT, that's awfully fishy - */ - function testConfirmCreditCardFailsOnCvvResultConflict() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['email'] = 'innoc...@safedomain.org'; - - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( 'CVVRESULT' => 'M' ), false ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - - $result = $gateway->do_transaction( 'Confirm_CreditCard' ); - - $this->assertFalse( $result['status'], 'Credit card should fail if querystring and XML have different CVVRESULT' ); - } - - /** - * testDefineVarMap - * - * This is tested with a bank transfer from Spain. - * - * @covers GlobalCollectAdapter::__construct - * @covers GlobalCollectAdapter::defineVarMap - */ - public function testDefineVarMap() { - - $gateway = $this->getFreshGatewayObject( $this->initial_vars ); - - $var_map = array( - 'ORDERID' => 'order_id', - 'AMOUNT' => 'amount', - 'CURRENCYCODE' => 'currency_code', - 'LANGUAGECODE' => 'language', - 'COUNTRYCODE' => 'country', - 'MERCHANTREFERENCE' => 'contribution_tracking_id', - 'RETURNURL' => 'returnto', - 'IPADDRESS' => 'server_ip', - 'ISSUERID' => 'issuer_id', - 'PAYMENTPRODUCTID' => 'payment_product', - 'CVV' => 'cvv', - 'EXPIRYDATE' => 'expiration', - 'CREDITCARDNUMBER' => 'card_num', - 'FIRSTNAME' => 'fname', - 'SURNAME' => 'lname', - 'STREET' => 'street', - 'CITY' => 'city', - 'STATE' => 'state', - 'ZIP' => 'zip', - 'EMAIL' => 'email', - 'ACCOUNTHOLDER' => 'account_holder', - 'ACCOUNTNAME' => 'account_name', - 'ACCOUNTNUMBER' => 'account_number', - 'ADDRESSLINE1E' => 'address_line_1e', - 'ADDRESSLINE2' => 'address_line_2', - 'ADDRESSLINE3' => 'address_line_3', - 'ADDRESSLINE4' => 'address_line_4', - 'ATTEMPTID' => 'attempt_id', - 'AUTHORISATIONID' => 'authorization_id', - 'BANKACCOUNTNUMBER' => 'bank_account_number', - 'BANKAGENZIA' => 'bank_agenzia', - 'BANKCHECKDIGIT' => 'bank_check_digit', - 'BANKCODE' => 'bank_code', - 'BANKFILIALE' => 'bank_filiale', - 'BANKNAME' => 'bank_name', - 'BRANCHCODE' => 'branch_code', - 'COUNTRYCODEBANK' => 'country_code_bank', - 'COUNTRYDESCRIPTION' => 'country_description', - 'CUSTOMERBANKCITY' => 'customer_bank_city', - 'CUSTOMERBANKSTREET' => 'customer_bank_street', - 'CUSTOMERBANKNUMBER' => 'customer_bank_number', - 'CUSTOMERBANKZIP' => 'customer_bank_zip', - 'DATECOLLECT' => 'date_collect', - 'DESCRIPTOR' => 'descriptor', - 'DIRECTDEBITTEXT' => 'direct_debit_text', - 'DOMICILIO' => 'domicilio', - 'EFFORTID' => 'effort_id', - 'IBAN' => 'iban', - 'IPADDRESSCUSTOMER' => 'user_ip', - 'PAYMENTREFERENCE' => 'payment_reference', - 'PROVINCIA' => 'provincia', - 'SPECIALID' => 'special_id', - 'SWIFTCODE' => 'swift_code', - 'TRANSACTIONTYPE' => 'transaction_type', - 'FISCALNUMBER' => 'fiscal_number', - ); - - $this->assertEquals( $var_map, $gateway->getVarMap() ); - } - - public function testLanguageStaging() { - $options = $this->getDonorTestData( 'NO' ); - $options['payment_method'] = 'cc'; - $options['payment_submethod'] = 'visa'; - $gateway = $this->getFreshGatewayObject( $options ); - - $gateway->_stageData(); - - $this->assertEquals( $gateway->_getData_Staged( 'language' ), 'no', "'NO' donor's language was inproperly set. Should be 'no'" ); - } - - /** - * Tests to make sure that certain error codes returned from GC will or - * will not create payments error loglines. - */ - function testCCLogsOnGatewayError() { - $init = $this->getDonorTestData( 'US' ); - unset( $init['order_id'] ); - $init['ffname'] = 'cc-vmad'; - - //this should not throw any payments errors: Just an invalid card. - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( '430285' ); - $gateway->do_transaction( 'GET_ORDERSTATUS' ); - $this->verifyNoLogErrors(); - - //Now test one we want to throw a payments error - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( '21000050' ); - $gateway->do_transaction( 'GET_ORDERSTATUS' ); - $loglines = $this->getLogMatches( LogLevel::ERROR, '/Investigation required!/' ); - $this->assertNotEmpty( $loglines, 'GC Error 21000050 is not generating the expected payments log error' ); - - //Reset logs - $this->testLogger->messages = array(); - - //Most irritating version of 20001000 - They failed to enter an expiration date on GC's form. This should log some specific info, but not an error. - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( '20001000-expiry' ); - $gateway->do_transaction( 'GET_ORDERSTATUS' ); - $this->verifyNoLogErrors(); - $loglines = $this->getLogMatches( LogLevel::INFO, '/processResponse:.*EXPIRYDATE/' ); - $this->assertNotEmpty( $loglines, 'GC Error 20001000-expiry is not generating the expected payments log line' ); - } - - /** - * Tests to make sure that certain error codes returned from GC will - * trigger order cancellation, even if retryable errors also exist. - * @dataProvider mcNoRetryCodeProvider - */ - public function testNoMastercardFinesForRepeatOnBadCodes( $code ) { - $init = $this->getDonorTestData( 'US' ); - unset( $init['order_id'] ); - $init['ffname'] = 'cc-vmad'; - //Make it not look like an orphan - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( - 'CVVRESULT' => 'M', - 'AVSRESULT' => '0' - ), false ) ); - - //Toxic card should not retry, even if there's an order id collision - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( $code ); - $gateway->do_transaction( 'Confirm_CreditCard' ); - $this->assertEquals( 1, count( $gateway->curled ), "Gateway kept trying even with response code $code! MasterCard could fine us a thousand bucks for that!" ); - $this->assertEquals( 1, count( $gateway->limbo_stomps ), "Gateway sent no limbostomps for code $code! Should have sent an antimessage!" ); - $this->assertEquals( true, $gateway->limbo_stomps[0], "Gateway sent wrong stomp message for code $code! Should have sent an antimessage!" ); - } - - /** - * Tests that two API requests don't send the same order ID and merchant - * reference. This was the case when users doubleclicked and we were - * using the last 5 digits of time in seconds as a suffix. We want to see - * what happens when a 2nd request comes in while the 1st is still waiting - * for a CURL response, so here we fake that situation by having CURL throw - * an exception during the 1st response. - */ - public function testNoDupeOrderId( ) { - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( - 'action'=>'donate', - 'amount'=>'3.00', - 'card_type'=>'amex', - 'city'=>'Hollywood', - 'contribution_tracking_id'=>'22901382', - 'country'=>'US', - 'currency_code'=>'USD', - 'emailAdd'=>'faketyf...@gmail.com', - 'fname'=>'Fakety', - 'format'=>'json', - 'gateway'=>'globalcollect', - 'language'=>'en', - 'lname'=>'Fake', - 'payment_method'=>'cc', - 'referrer'=>'http://en.wikipedia.org/wiki/Main_Page', - 'state'=>'MA', - 'street'=>'99 Fake St', - 'utm_campaign'=>'C14_en5C_dec_dsk_FR', - 'utm_medium'=>'sitenotice', - 'utm_source'=>'B14_120921_5C_lg_fnt_sans.no-LP.cc', - 'zip'=>'90210' - ), false ) ); - - $gateway = new TestingGlobalCollectAdapter( array( 'api_request' => 'true' ) ); - $gateway->setDummyGatewayResponseCode( 'Exception' ); - try { - $gateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); - } - catch ( Exception $e ) { - // totally expected this - } - $first = $gateway->curled[0]; - //simulate another request coming in before we get anything back from GC - $anotherGateway = new TestingGlobalCollectAdapter( array( 'api_request' => 'true' ) ); - $anotherGateway->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); - $second = $anotherGateway->curled[0]; - $this->assertFalse( $first == $second, 'Two calls to the api did the same thing'); - } - - /** - * Tests to see that we don't claim we're going to retry when we aren't - * going to. For GC, we really only want to retry on code 300620 - * @dataProvider benignNoRetryCodeProvider - */ - public function testNoClaimRetryOnBoringCodes( $code ) { - $init = $this->getDonorTestData( 'US' ); - unset( $init['order_id'] ); - $init['ffname'] = 'cc-vmad'; - //Make it not look like an orphan - $this->setMwGlobals( 'wgRequest', - new FauxRequest( array( - 'CVVRESULT' => 'M', - 'AVSRESULT' => '0' - ), false ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->setDummyGatewayResponseCode( $code ); - $start_id = $gateway->_getData_Staged( 'order_id' ); - $gateway->do_transaction( 'Confirm_CreditCard' ); - $finish_id = $gateway->_getData_Staged( 'order_id' ); - $loglines = $this->getLogMatches( LogLevel::INFO, '/Repeating transaction on request for vars:/' ); - $this->assertEmpty( $loglines, "Log says we are going to repeat the transaction for code $code, but that is not true" ); - $this->assertEquals( $start_id, $finish_id, "Needlessly regenerated order id for code $code "); - } -} ->>>>>>> BRANCH (bbf583 Don't fraud-fail on STATUSID 25) diff --git a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse b/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse deleted file mode 100644 index 2a37c20..0000000 --- a/tests/includes/Responses/globalcollect/GET_ORDERSTATUS_25.testresponse +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version = "1.0"?> -<XML> - <REQUEST> - <ACTION>GET_ORDERSTATUS</ACTION> - <META> - <MERCHANTID>1234</MERCHANTID> - <IPADDRESS>127.0.0.1</IPADDRESS> - <VERSION>2.0</VERSION> - <REQUESTIPADDRESS>11.22.33.44</REQUESTIPADDRESS> - </META> - <PARAMS> - <ORDER> - <ORDERID>987654321</ORDERID> - </ORDER> - </PARAMS> - <RESPONSE> - <RESULT>OK</RESULT> - <META> - <REQUESTID>1341324</REQUESTID> - <RESPONSEDATETIME>20150310075018</RESPONSEDATETIME> - </META> - <STATUS> - <STATUSDATE>20150310072845</STATUSDATE> - <PAYMENTMETHODID>1</PAYMENTMETHODID> - <MERCHANTREFERENCE>5551212.23560</MERCHANTREFERENCE> - <ATTEMPTID>1</ATTEMPTID> - <PAYMENTREFERENCE>0</PAYMENTREFERENCE> - <AMOUNT>3000</AMOUNT> - <MERCHANTID>1234</MERCHANTID> - <ORDERID>987654321</ORDERID> - <STATUSID>25</STATUSID> - <EFFORTID>1</EFFORTID> - <CURRENCYCODE>SEK</CURRENCYCODE> - <PAYMENTPRODUCTID>1</PAYMENTPRODUCTID> - </STATUS> - </RESPONSE> - </REQUEST> -</XML> diff --git a/tests/includes/Responses/globalcollect/SET_PAYMENT_25.testresponse b/tests/includes/Responses/globalcollect/SET_PAYMENT_25.testresponse deleted file mode 100644 index 617b074..0000000 --- a/tests/includes/Responses/globalcollect/SET_PAYMENT_25.testresponse +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version = "1.0"?> -<XML> - <REQUEST> - <ACTION>SET_PAYMENT</ACTION> - <META> - <MERCHANTID>test</MERCHANTID> - <IPADDRESS>127.0.0.1</IPADDRESS> - <VERSION>1.0</VERSION> - </META> - <PARAMS> - <PAYMENT> - <ORDERID>626113410</ORDERID> - <EFFORTID>2</EFFORTID> - <PAYMENTPRODUCTID>1</PAYMENTPRODUCTID> - <AMOUNT>10101</AMOUNT> - <CURRENCYCODE>EUR</CURRENCYCODE> - <MERCHANTREFERENCE>626113410</MERCHANTREFERENCE> - </PAYMENT> - </PARAMS> - <RESPONSE> - <RESULT>OK</RESULT> - <META> - <REQUESTID>1891851</REQUESTID> - <RESPONSEDATETIME>20140327165513</RESPONSEDATETIME> - </META> - </RESPONSE> - </REQUEST> -</XML> -- To view, visit https://gerrit.wikimedia.org/r/197690 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib40a80a689e4205485e2694d0cd1bf68a9443ac3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits