jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/379691 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment 0091560fb Optionally send more Minfraud parameters 53cb589d7 Don't send empty or '0' address fields to minFraud Change-Id: I23e4086b559f5f0bcd93d4c1b6c0b2d67395a6ba --- D tests/phpunit/FraudFiltersTest.php D tests/phpunit/includes/Responses/minFraud/15points.json 2 files changed, 0 insertions(+), 254 deletions(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/tests/phpunit/FraudFiltersTest.php b/tests/phpunit/FraudFiltersTest.php deleted file mode 100644 index ee076c5..0000000 --- a/tests/phpunit/FraudFiltersTest.php +++ /dev/null @@ -1,237 +0,0 @@ -<<<<<<< HEAD (077501 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 SmashPig\Core\DataStores\QueueWrapper; -use SmashPig\CrmLink\Messages\SourceFields; -use Wikimedia\TestingAccessWrapper; - -/** - * @group Fundraising - * @group DonationInterface - * @group FraudFilters - */ -class DonationInterface_FraudFiltersTest extends DonationInterfaceTestCase { - - /** - * @var PHPUnit_Framework_MockObject_MockObject $requestFactory - */ - protected $requestFactory; - - /** - * @var PHPUnit_Framework_MockObject_MockObject $request - */ - protected $request; - - public function setUp() { - parent::setUp(); - $this->requestFactory = $this->getMockBuilder( - '\MaxMind\WebService\Http\RequestFactory' - )->disableOriginalConstructor()->getMock(); - - $this->request = $this->getMockBuilder( - 'MaxMind\WebService\Http\CurlRequest' - )->disableOriginalConstructor()->getMock(); - - $this->requestFactory->method( 'request' )->willReturn( - $this->request - ); - - $this->setMwGlobals( array( - 'wgDonationInterfaceEnableMinFraud' => true, - 'wgDonationInterfaceMinFraudErrorScore' => 50, - 'wgDonationInterfaceMinFraudClientOptions' => array( - 'host' => '0.0.0.0', - 'httpRequestFactory' => $this->requestFactory - ), - ) ); - } - - /** - * When minFraud gets a blank answer, we should assign points according to - * $wgDonationInterfaceMinFraudErrorScore. - */ - function testMinFraudErrorScore() { - $this->request->method( 'post' )->willReturn( '' ); - $options = $this->getDonorTestData(); - $options['email'] = 'someb...@wikipedia.org'; - $options['payment_method'] = 'cc'; - - $gateway = $this->getFreshGatewayObject( $options ); - - $gateway->runAntifraudFilters(); - - $this->assertEquals( 'reject', $gateway->getValidationAction(), 'Validation action is not as expected' ); - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $this->assertEquals( 107.5, $exposed->risk_score, 'RiskScore is not as expected for failure mode' ); - $message = QueueWrapper::getQueue( 'payments-antifraud' )->pop(); - SourceFields::removeFromMessage( $message ); - $expected = array( - 'validation_action' => 'reject', - 'risk_score' => 107.5, - 'score_breakdown' => array( - 'initial' => 0, - 'getScoreUtmCampaignMap' => 0, - 'getScoreCountryMap' => 20, - 'getScoreUtmSourceMap' => 0, - 'getScoreUtmMediumMap' => 0, - 'getScoreEmailDomainMap' => 37.5, - 'getCVVResult' => 0, - 'getAVSResult' => 0, - 'minfraud_filter' => 50, - ), - 'user_ip' => '127.0.0.1', - 'gateway_txn_id' => false, - 'date' => $message['date'], - 'server' => gethostname(), - 'gateway' => 'globalcollect', - 'contribution_tracking_id' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'order_id' => $gateway->getData_Unstaged_Escaped( 'order_id' ), - 'payment_method' => 'cc', - ); - $this->assertEquals( $expected, $message ); - } - - /** - * Test we correctly add a real score from minFraud - */ - function testMinFraudRealScore() { - $options = $this->getDonorTestData(); - $options['email'] = 'someb...@wikipedia.org'; - $options['payment_method'] = 'cc'; - - $gateway = $this->getFreshGatewayObject( $options ); - - $this->request->expects( $this->once() ) - ->method( 'post' ) - ->with( - '{"billing":{"city":"San Francisco","region":"CA","postal":"94105","country":"US"},' . - '"device":{"ip_address":"127.0.0.1"},' . - '"email":{"address":"daf162af7e894faf3d55a18ec7bfa795","domain":"wikipedia.org"},' . - '"event":{"transaction_id":"' . - $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ) .'"}}' - )->willReturn( [ - 200, 'application/json', file_get_contents( - __DIR__ . '/includes/Responses/minFraud/15points.json' - ) - ] ); - - $gateway->runAntifraudFilters(); - - $this->assertEquals( 'challenge', $gateway->getValidationAction(), 'Validation action is not as expected' ); - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $this->assertEquals( 72.75, $exposed->risk_score, 'RiskScore is not as expected for failure mode' ); - $message = QueueWrapper::getQueue( 'payments-antifraud' )->pop(); - SourceFields::removeFromMessage( $message ); - $expected = array( - 'validation_action' => 'challenge', - 'risk_score' => 72.75, - 'score_breakdown' => array( - 'initial' => 0, - 'getScoreUtmCampaignMap' => 0, - 'getScoreCountryMap' => 20, - 'getScoreUtmSourceMap' => 0, - 'getScoreUtmMediumMap' => 0, - 'getScoreEmailDomainMap' => 37.5, - 'getCVVResult' => 0, - 'getAVSResult' => 0, - 'minfraud_filter' => 15.25, - ), - 'user_ip' => '127.0.0.1', - 'gateway_txn_id' => false, - 'date' => $message['date'], - 'server' => gethostname(), - 'gateway' => 'globalcollect', - 'contribution_tracking_id' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'order_id' => $gateway->getData_Unstaged_Escaped( 'order_id' ), - 'payment_method' => 'cc', - ); - $this->assertEquals( $expected, $message ); - } - - /** - * Make sure we send the right stuff when extra fields are enabled - */ - function testMinFraudExtras() { - $options = $this->getDonorTestData(); - $options['email'] = 'someb...@wikipedia.org'; - $options['payment_method'] = 'cc'; - - $gateway = $this->getFreshGatewayObject( $options ); - - $this->setMwGlobals( [ - 'wgDonationInterfaceMinFraudExtraFields' => [ - 'email', - 'first_name', - 'last_name', - 'street_address', - 'amount', - 'currency' - ] - ] ); - $this->request->expects( $this->once() ) - ->method( 'post' ) - ->with( - '{"billing":{"city":"San Francisco","region":"CA","postal":"94105","country":"US",' . - '"first_name":"Firstname","last_name":"Surname","address":"123 Fake Street"},' . - '"device":{"ip_address":"127.0.0.1"},' . - '"email":{"address":"someb...@wikipedia.org","domain":"wikipedia.org"},' . - '"event":{"transaction_id":"' . - $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . - '"},"order":{"amount":"1.55","currency":"USD"}}' - )->willReturn( [ - 200, 'application/json', file_get_contents( - __DIR__ . '/includes/Responses/minFraud/15points.json' - ) - ] ); - - $gateway->runAntifraudFilters(); - - $this->assertEquals( 'challenge', $gateway->getValidationAction(), 'Validation action is not as expected' ); - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $this->assertEquals( 72.75, $exposed->risk_score, 'RiskScore is not as expected for failure mode' ); - $message = QueueWrapper::getQueue( 'payments-antifraud' )->pop(); - SourceFields::removeFromMessage( $message ); - $expected = array( - 'validation_action' => 'challenge', - 'risk_score' => 72.75, - 'score_breakdown' => array( - 'initial' => 0, - 'getScoreUtmCampaignMap' => 0, - 'getScoreCountryMap' => 20, - 'getScoreUtmSourceMap' => 0, - 'getScoreUtmMediumMap' => 0, - 'getScoreEmailDomainMap' => 37.5, - 'getCVVResult' => 0, - 'getAVSResult' => 0, - 'minfraud_filter' => 15.25, - ), - 'user_ip' => '127.0.0.1', - 'gateway_txn_id' => false, - 'date' => $message['date'], - 'server' => gethostname(), - 'gateway' => 'globalcollect', - 'contribution_tracking_id' => $gateway->getData_Unstaged_Escaped( 'contribution_tracking_id' ), - 'order_id' => $gateway->getData_Unstaged_Escaped( 'order_id' ), - 'payment_method' => 'cc', - ); - $this->assertEquals( $expected, $message ); - } -} ->>>>>>> BRANCH (53cb58 Don't send empty or '0' address fields to minFraud) diff --git a/tests/phpunit/includes/Responses/minFraud/15points.json b/tests/phpunit/includes/Responses/minFraud/15points.json deleted file mode 100644 index 35bc1cb..0000000 --- a/tests/phpunit/includes/Responses/minFraud/15points.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "5bc5d6c2-b2c8-40af-87f4-6d61af86b6ae", - "risk_score": 15.25, - "funds_remaining": 250.00, - "queries_remaining": 500000, - - "ip_address": { - "risk": 15.25 - }, - - "disposition": { - "action": "accept", - "reason": "default" - }, - - "warnings": [] -} -- To view, visit https://gerrit.wikimedia.org/r/379691 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I23e4086b559f5f0bcd93d4c1b6c0b2d67395a6ba Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Mepps <me...@wikimedia.org> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits