Skip to content

Commit

Permalink
[#540] renamed blacklist to blocklist
Browse files Browse the repository at this point in the history
  • Loading branch information
bjendres committed Nov 28, 2020
1 parent 0e18dca commit 5d7a1af
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
20 changes: 10 additions & 10 deletions CRM/Sepa/Logic/Verification.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public static function formatBIC($bic, $type = 'SEPA') {
* @return NULL if given IBAN is valid, localized error message otherwise
*/
public static function verifyIBAN($iban, $type = 'SEPA') {
// first: check if blacklisted (#540)
if (self::isIbanBlacklisted($iban)) {
return E::ts("IBAN is blacklisted");
// first: check if blocklisted (#540)
if (self::isIbanBlocklisted($iban)) {
return E::ts("IBAN is blocklisted");
}

switch ($type) {
Expand Down Expand Up @@ -106,26 +106,26 @@ public static function verifyIBAN($iban, $type = 'SEPA') {
}

/**
* Check if this IBAN is blacklisted
* Check if this IBAN is blocklisted
*
* @param $iban string IBAN to check
* @return boolean
*/
public static function isIbanBlacklisted($iban) {
static $blacklist = NULL;
if ($blacklist === NULL) {
public static function isIbanBlocklisted($iban) {
static $blocklist = NULL;
if ($blocklist === NULL) {
// we have to check whether the group exists first, getOptionValuesAssocArrayFromName doesn't do that
$blacklist = [];
$blocklist = [];
$query = civicrm_api3('OptionValue', 'get', [
'option_group_id' => 'iban_blacklist',
'option.limit' => 0,
'return' => 'value'
]);
foreach ($query['values'] as $value) {
$blacklist[$value['value']] = 1;
$blocklist[$value['value']] = 1;
}
}
return isset($blacklist[$iban]);
return isset($blocklist[$iban]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Sepa/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function upgrade_1501() {
* @throws Exception
*/
public function upgrade_1502() {
$this->ctx->log->info('Adding IBAN Blacklist');
$this->ctx->log->info('Adding IBAN Blocklist');
$customData = new CRM_Sepa_CustomData('org.project60.sepa');
$customData->syncOptionGroup(E::path('resources/iban_blacklist_option_group.json'));
return TRUE;
Expand Down
Binary file modified l10n/de_DE/LC_MESSAGES/sepa.mo
Binary file not shown.
18 changes: 6 additions & 12 deletions l10n/de_DE/LC_MESSAGES/sepa.po
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,8 @@ msgid "Incomplete Donation"
msgstr "Unvollständige Zuwendung"

#: CRM/Sepa/Logic/Verification.php
msgid "IBAN is blacklisted"
msgstr "IBAN ist auf der schwarzen Liste"
msgid "IBAN is blocklisted"
msgstr "IBAN ist auf der Blockliste"

#: CRM/Sepa/Logic/Verification.php
#: templates/CRM/Admin/Form/Setting/SepaSettings.tpl
Expand Down Expand Up @@ -3244,10 +3244,8 @@ msgid "The mandate is not in the transaction group anymore but should be."
msgstr ""

#: tests/phpunit/CRM/Sepa/MandateTerminationTest.php
#, fuzzy
#| msgid "This is not a correct BIC."
msgid "The end date is not correct."
msgstr "Das ist keine gültige BIC."
msgstr "Das Enddatum ist nicht korrekt"

#: tests/phpunit/CRM/Sepa/MandateTerminationTest.php
msgid "The mandate has been incorrectly regrouped."
Expand Down Expand Up @@ -3360,16 +3358,12 @@ msgid "Nonexistent BIC detection fails!"
msgstr ""

#: tests/phpunit/CRM/Sepa/VerifyBicTest.php
#, fuzzy
#| msgid "Incorrect date format"
msgid "Incorrect BIC detection fails!"
msgstr "Falsches Datumsformat."
msgstr ""

#: tests/phpunit/CRM/Sepa/VerifyIbanTest.php
#, fuzzy
#| msgid "Incorrect date format"
msgid "Incorrect IBAN detection fails!"
msgstr "Falsches Datumsformat."
msgstr ""

#: tests/phpunit/CRM/Sepa/VerifyIbanTest.php
msgid "Incorrect bank code detection fails!"
Expand All @@ -3388,7 +3382,7 @@ msgid "Incorrect char in IBAN detection fails!"
msgstr ""

#: tests/phpunit/CRM/Sepa/VerifyIbanTest.php
msgid "Blacklistet IBAN should fail but did not!"
msgid "Blocklistet IBAN should fail but did not!"
msgstr ""

#~ msgid "Hide BIC in PP"
Expand Down
4 changes: 2 additions & 2 deletions l10n/org.project60.sepa.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ msgid "Incomplete Donation"
msgstr ""

#: CRM/Sepa/Logic/Verification.php
msgid "IBAN is blacklisted"
msgid "IBAN is blocklisted"
msgstr ""

#: CRM/Sepa/Logic/Verification.php
Expand Down Expand Up @@ -3136,5 +3136,5 @@ msgid "Incorrect char in IBAN detection fails!"
msgstr ""

#: tests/phpunit/CRM/Sepa/VerifyIbanTest.php
msgid "Blacklistet IBAN should fail but did not!"
msgid "Blocklistet IBAN should fail but did not!"
msgstr ""
4 changes: 2 additions & 2 deletions resources/iban_blacklist_option_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"_lookup": ["name"],
"_translate": ["title"],
"name": "iban_blacklist",
"title": "IBAN Blacklist",
"title": "IBAN Blocklist",
"is_reserved": 0,
"is_enabled": 1,
"is_locked": 0,
"_values": [
{
"_lookup": ["value"],
"_translate": ["label"],
"label": "Blacklist Example",
"label": "Blocklist Example",
"value": "DE27100777770209299700"
}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TODO: more complex batching scenarios
| V02 | PASS | creditor_type=PSP | Validate BICs | Creating mandates with various valid/invalid BICs, assert that all creations pass |
| V03 | PASS | default | Validate IBANs | Creating mandates with various valid/invalid IBANs, assert that with invalid ones the creation causes an error |
| V04 | PASS | creditor_type=PSP | Validate IBANs | Creating mandates with various valid/invalid IBANs, assert that all creations pass |
| V05 | PASS | default | Validate Blacklist | Add some example IBANs to the black list, assert that creation with those IBANs fail, while other (valid) IBANs pass |
| V05 | PASS | default | Validate Blocklist | Add some example IBANs to the block list, assert that creation with those IBANs fail, while other (valid) IBANs pass |


## Generated Files
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Sepa/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ protected function setSepaConfiguration(string $key, $value): void


/**
* Add an IBAN to the blacklist.
* Add an IBAN to the blocklist.
* @param string $iban The IBAN.
*/
protected function addIbanToBlacklist(string $iban): void
protected function addIbanToBlocklist(string $iban): void
{
$existsAlready = $this->callAPISuccessGetCount(
'OptionValue',
Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/CRM/Sepa/VerifyIbanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ public function testPspCreatorAcceptsIncorrectIban()
}

/**
* Test that an IBAN put on the blacklist will fail.
* Test that an IBAN put on the blocklist will fail.
* @see Case_ID V05
*/
public function testBlacklistedIbanFails()
public function testBlocklistedIbanFails()
{
$this->addIbanToBlacklist(self::TEST_IBAN);
$this->addIbanToBlocklist(self::TEST_IBAN);

// should be using $this->assertException but there's something off here
try {
Expand All @@ -185,22 +185,22 @@ public function testBlacklistedIbanFails()
'iban' => self::TEST_IBAN,
]
);
$this->fail(E::ts('Blacklistet IBAN should fail but did not!'));
$this->fail(E::ts('Blocklistet IBAN should fail but did not!'));
} catch (Exception $ex) {
// this is expected
}
}

/**
* This will test if a valid IBAN works when there is another IBAN on the blacklist. \
* NOTE: In the default settings of the Sepa extension there is a test entry on the blacklist, \
* This will test if a valid IBAN works when there is another IBAN on the blocklist. \
* NOTE: In the default settings of the Sepa extension there is a test entry on the blocklist, \
* so technically this is not necessary as testValidIban does the same; but this \
* test will go sure in the case someone removes the default test entry.
* @see Case_ID V05
*/
public function testValidIbanWhenOtherIbanIsBlacklisted()
public function testValidIbanWhenOtherIbanIsBlocklisted()
{
$this->addIbanToBlacklist(self::TEST_IBAN_2);
$this->addIbanToBlocklist(self::TEST_IBAN_2);

$this->createMandate(
[
Expand Down

0 comments on commit 5d7a1af

Please sign in to comment.