jenkins-bot has submitted this change and it was merged.
Change subject: Language query params shouldn't be case sensitive
......................................................................
Language query params shouldn't be case sensitive
This lowercases them on the way in, so I've removed a couple other
places we were working around that issue.
Bug: T135255
Change-Id: I5721226d2c044bb1abe0955948fdc696ebf5f8e1
---
M gateway_common/DonationData.php
M gateway_common/DonorLanguage.php
M paypal_gateway/PayPalLocale.php
M tests/Adapter/Adyen/AdyenTest.php
4 files changed, 56 insertions(+), 3 deletions(-)
Approvals:
XenoRyet: Looks good to me, approved
jenkins-bot: Verified
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index 63c64ba..da4d10e 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -642,6 +642,10 @@
$language = $this->getVal( 'language' );
}
+ if ( $language ) {
+ $language = strtolower( $language );
+ }
+
if ( $language == false ||
!WmfFramework::isValidBuiltInLanguageCode( $language ) ) {
$language = WmfFramework::getLanguageCode();
}
diff --git a/gateway_common/DonorLanguage.php b/gateway_common/DonorLanguage.php
index 4efd116..a7aa8af 100644
--- a/gateway_common/DonorLanguage.php
+++ b/gateway_common/DonorLanguage.php
@@ -2,7 +2,7 @@
class DonorLanguage implements StagingHelper {
public function stage( GatewayType $adapter, $normalized, &$stagedData
) {
- $language = strtolower( $normalized['language'] );
+ $language = $normalized['language'];
$adapterLanguages = $adapter->getAvailableLanguages();
if ( !in_array( $language, $adapterLanguages ) ) {
$fallbacks = Language::getFallbacksFor( $language );
diff --git a/paypal_gateway/PayPalLocale.php b/paypal_gateway/PayPalLocale.php
index b359be2..8ba3f9b 100644
--- a/paypal_gateway/PayPalLocale.php
+++ b/paypal_gateway/PayPalLocale.php
@@ -42,8 +42,8 @@
$stagedData['locale'] = $normalized['country'];
}
- $fallbacks = Language::getFallbacksFor( strtolower(
$normalized['language'] ) );
- array_unshift( $fallbacks, strtolower( $normalized['language']
) );
+ $fallbacks = Language::getFallbacksFor( $normalized['language']
);
+ array_unshift( $fallbacks, $normalized['language'] );
foreach ( $fallbacks as $lang ) {
$locale = "{$lang}_{$normalized['country']}";
if ( in_array( $locale, $supported_full_locales ) ) {
diff --git a/tests/Adapter/Adyen/AdyenTest.php
b/tests/Adapter/Adyen/AdyenTest.php
index 8911f62..f0b31b5 100644
--- a/tests/Adapter/Adyen/AdyenTest.php
+++ b/tests/Adapter/Adyen/AdyenTest.php
@@ -100,4 +100,53 @@
$message = $exposed->getStompTransaction();
$this->assertEquals( 57, $message['risk_score'], 'Risk score
was not correctly added to queue message.' );
}
+
+ /**
+ * Make sure language is staged correctly when qs param is uppercase
+ */
+ function testLanguageCaseSensitivity() {
+ $init = $this->getDonorTestData();
+ $init['language'] = 'FR';
+ $gateway = $this->getFreshGatewayObject( $init );
+
+ $gateway->do_transaction( 'donate' );
+ $exposed = TestingAccessWrapper::newFromObject( $gateway );
+ $ret = $exposed->buildRequestParams();
+
+ $expected = array (
+ 'allowedMethods' => 'card',
+ 'billingAddress.street' => $init['street'],
+ 'billingAddress.city' => $init['city'],
+ 'billingAddress.postalCode' => $init['zip'],
+ 'billingAddress.stateOrProvince' => $init['state'],
+ 'billingAddress.country' => $init['country'],
+ 'billingAddressType' => 2,
+ 'card.cardHolderName' => $init['fname'] . ' ' .
$init['lname'],
+ 'currencyCode' => $init['currency_code'],
+ 'merchantAccount' => 'wikitest',
+ 'merchantReference' => $exposed->getData_Staged(
'order_id' ),
+ 'merchantSig' => $exposed->getData_Staged(
'hpp_signature' ),
+ 'paymentAmount' => ($init['amount']) * 100,
+ 'skinCode' => 'testskin',
+ 'shopperLocale' => 'fr',
+ 'shopperEmail' => '[email protected]',
+ 'offset' => '52',
+ );
+
+ //deal with problem keys.
+ //@TODO: Refactor gateway so these are more testable
+ $problems = array (
+ 'sessionValidity',
+ 'shipBeforeDate',
+ );
+
+ foreach ( $problems as $oneproblem ) {
+ if ( isset( $ret[$oneproblem] ) ) {
+ unset( $ret[$oneproblem] );
+ }
+ }
+
+ $this->assertEquals( $expected, $ret, 'Adyen "donate"
transaction not constructing the expected redirect URL' );
+ $this->assertNotNull( $gateway->getData_Unstaged_Escaped(
'order_id' ), "Adyen order_id is null, and we need one for 'merchantReference'"
);
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/288647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5721226d2c044bb1abe0955948fdc696ebf5f8e1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits