Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/124043
Change subject: Clean up minfraud handling in tests
......................................................................
Clean up minfraud handling in tests
Change-Id: Ie9cde9ec2d84ce8b7d30321726cc304fc4063c2e
---
M extras/custom_filters/filters/minfraud/ccfd/HTTPBase.php
M extras/custom_filters/filters/minfraud/minfraud.body.php
M tests/Adapter/GatewayAdapterTestCase.php
M tests/DonationInterfaceTestCase.php
M tests/FormChooserTestCase.php
M tests/FraudFiltersTestCase.php
M tests/includes/test_gateway/test.adapter.php
7 files changed, 19 insertions(+), 20 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/43/124043/1
diff --git a/extras/custom_filters/filters/minfraud/ccfd/HTTPBase.php
b/extras/custom_filters/filters/minfraud/ccfd/HTTPBase.php
index ebbfcff..9e40b22 100644
--- a/extras/custom_filters/filters/minfraud/ccfd/HTTPBase.php
+++ b/extras/custom_filters/filters/minfraud/ccfd/HTTPBase.php
@@ -67,6 +67,10 @@
//this function queries the servers
function query() {
+ if ( $this->gateway_adapter->getGlobal( 'Test' ) ) {
+ return 0;
+ }
+
//query every server in the list
if (!$this->useDNS){
$ipstr = $this->readIpAddressFromCache();
diff --git a/extras/custom_filters/filters/minfraud/minfraud.body.php
b/extras/custom_filters/filters/minfraud/minfraud.body.php
index c13772c..3dbe9ef 100644
--- a/extras/custom_filters/filters/minfraud/minfraud.body.php
+++ b/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -261,6 +261,10 @@
$this->health_check();
try {
+ if ( !isset( $this->minfraudResponse['riskScore'] ) ) {
+ throw new MWException( "No response at all from
minfraud." );
+ }
+
$this->cfo->addRiskScore(
$this->minfraudResponse['riskScore'], 'minfraud_filter' );
}
catch( MWException $ex){
@@ -344,6 +348,9 @@
$this->get_ccfd()->input( $minfraud_query );
$this->get_ccfd()->query();
$this->minfraudResponse = $this->get_ccfd()->output();
+ if ( !$this->minfraudResponse ) {
+ $this->minfraudResponse = array();
+ }
}
/**
diff --git a/tests/Adapter/GatewayAdapterTestCase.php
b/tests/Adapter/GatewayAdapterTestCase.php
index bfa0ecf..ab6a845 100644
--- a/tests/Adapter/GatewayAdapterTestCase.php
+++ b/tests/Adapter/GatewayAdapterTestCase.php
@@ -42,8 +42,8 @@
public function __construct() {
global $wgDonationInterfaceAllowedHtmlForms;
- global $wgGlobalCollectGatewayTest;
- $wgGlobalCollectGatewayTest = true;
+ global $wgDonationInterfaceTest;
+ $wgDonationInterfaceTest = true;
parent::__construct();
$wgDonationInterfaceAllowedHtmlForms['testytest'] = array (
diff --git a/tests/DonationInterfaceTestCase.php
b/tests/DonationInterfaceTestCase.php
index 90ed125..c5f96f0 100644
--- a/tests/DonationInterfaceTestCase.php
+++ b/tests/DonationInterfaceTestCase.php
@@ -86,9 +86,9 @@
*/
public function buildRequestXmlForGlobalCollect( $optionsForTestData,
$options ) {
- global $wgGlobalCollectGatewayTest;
+ global $wgDonationInterfaceTest;
- $wgGlobalCollectGatewayTest = true;
+ $wgDonationInterfaceTest = true;
$this->gatewayAdapter = $this->getFreshGatewayObject( $options
);
diff --git a/tests/FormChooserTestCase.php b/tests/FormChooserTestCase.php
index 953ecc0..2b591c8 100644
--- a/tests/FormChooserTestCase.php
+++ b/tests/FormChooserTestCase.php
@@ -101,7 +101,6 @@
'payment_methods' => array ( 'paypal' => 'ALL' ),
);
-
$wgDonationInterfaceAllowedHtmlForms = array_merge(
$wgDonationInterfaceAllowedHtmlForms, $moreForms );
$wgDonationInterfaceFormDirs = $form_dirs;
}
diff --git a/tests/FraudFiltersTestCase.php b/tests/FraudFiltersTestCase.php
index 5bb7f04..df496a3 100644
--- a/tests/FraudFiltersTestCase.php
+++ b/tests/FraudFiltersTestCase.php
@@ -54,10 +54,10 @@
);
$wgDonationInterfaceCustomFiltersRefRules = array (
- '/donate\-error/i' => 5,
+ '/donate-error/i' => 5,
);
- $wgDonationInterfaceCustomFiltersSrcRules = array (
'/wikimedia.org/i' => 80 );
+ $wgDonationInterfaceCustomFiltersSrcRules = array (
'/wikimedia\.org/i' => 80 );
$wgDonationInterfaceCustomFiltersFunctions = array (
'getScoreCountryMap' => 50,
@@ -80,7 +80,7 @@
);
$wgDonationInterfaceUtmCampaignMap = array (
- '/^(C14\_)/' => 14,
+ '/^(C14_)/' => 14,
'/^(spontaneous)/' => 5
);
$wgDonationInterfaceUtmSourceMap = array (
diff --git a/tests/includes/test_gateway/test.adapter.php
b/tests/includes/test_gateway/test.adapter.php
index d699e99..7d0ab86 100644
--- a/tests/includes/test_gateway/test.adapter.php
+++ b/tests/includes/test_gateway/test.adapter.php
@@ -19,6 +19,7 @@
/**
* TestingGlobalCollectAdapter
*
+ * TODO: Add dependency injection to the base class so we don't have to repeat
code here.
*/
class TestingGlobalCollectAdapter extends GlobalCollectAdapter {
public $testlog = array ( );
@@ -105,9 +106,6 @@
//@TODO: That minfraud jerk needs its own isolated tests.
function runAntifraudHooks() {
- //grabbing the output buffer to prevent minfraud being stupid
from ruining my test.
- ob_start();
-
//now screw around with the batch settings to trick the fraud
filters into triggering
$is_batch = $this->isBatchProcessor();
$this->batch = true;
@@ -115,7 +113,6 @@
parent::runAntifraudHooks();
$this->batch = $is_batch;
- ob_end_clean();
}
public function getRiskScore() {
@@ -314,9 +311,6 @@
//@TODO: That minfraud jerk needs its own isolated tests.
function runAntifraudHooks() {
- //grabbing the output buffer to prevent minfraud being stupid
from ruining my test.
- ob_start();
-
//now screw around with the batch settings to trick the fraud
filters into triggering
$is_batch = $this->isBatchProcessor();
$this->batch = true;
@@ -324,7 +318,6 @@
parent::runAntifraudHooks();
$this->batch = $is_batch;
- ob_end_clean();
}
public function _getData_Staged() {
@@ -413,9 +406,6 @@
//@TODO: That minfraud jerk needs its own isolated tests.
function runAntifraudHooks() {
- //grabbing the output buffer to prevent minfraud being stupid
from ruining my test.
- ob_start();
-
//now screw around with the batch settings to trick the fraud
filters into triggering
$is_batch = $this->isBatchProcessor();
$this->batch = true;
@@ -423,7 +413,6 @@
parent::runAntifraudHooks();
$this->batch = $is_batch;
- ob_end_clean();
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/124043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9cde9ec2d84ce8b7d30321726cc304fc4063c2e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits