 wp-pay-gateways    /
                    buckaroo
                      wp-pay-gateways    /
                    buckaroo
                
                            | 1 | <?php | ||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\Buckaroo; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * Title: Buckaroo signature test. | ||
| 7 | * Description: | ||
| 8 | * Copyright: 2005-2019 Pronamic | ||
| 9 | * Company: Pronamic | ||
| 10 | * | ||
| 11 | * @link http://pronamic.nl/wp-content/uploads/2013/04/BPE-3.0-Gateway-HTML.1.02.pdf | ||
| 12 | * @author Remco Tolsma | ||
| 13 | * @version 2.0.0 | ||
| 14 | */ | ||
| 15 | class SignatureTest extends \WP_UnitTestCase { | ||
| 16 | /** | ||
| 17 | * Test get signature. | ||
| 18 | * | ||
| 19 | * @dataProvider provider_case_mix | ||
| 20 | */ | ||
| 21 | 	public function test_get_signature( $data ) { | ||
| 22 | $signature = Security::get_signature( $data ); | ||
| 0 ignored issues–
                            show | |||
| 23 | |||
| 24 | $this->assertEquals( '84e9802d60d727ade4a845c43033051d5758ce25', $signature ); | ||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Test signature filter. | ||
| 29 | * | ||
| 30 | * @dataProvider provider_case_mix | ||
| 31 | */ | ||
| 32 | 	public function test_signature_filter( $data ) { | ||
| 33 | $data = Security::filter_data( $data ); | ||
| 34 | |||
| 35 | $this->assertArrayNotHasKey( 'random_1234567890', $data ); | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Test create signature. | ||
| 40 | * | ||
| 41 | * @dataProvider provider | ||
| 42 | */ | ||
| 43 | 	public function test_create_signature( $data ) { | ||
| 44 | $secret_key = '29E9BEB3F3428B2BCAA678DEC489A86A'; | ||
| 45 | |||
| 46 | $data = Util::urldecode( $data ); | ||
| 47 | |||
| 48 | $signature = Security::get_signature( $data ); | ||
| 0 ignored issues–
                            show Are you sure the assignment to  $signatureis correct asPronamic\WordPress\Pay\G...y::get_signature($data)targetingPronamic\WordPress\Pay\G...curity::get_signature()seems to always return null.This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
    function getObject()
    {
        return null;
    }
}
$a = new A();
$object = $a->getObject();
The method  The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.  Loading history... | |||
| 49 | |||
| 50 | $signature_check = Security::create_signature( $data, $secret_key, true ); | ||
| 51 | |||
| 52 | $this->assertEquals( $signature, $signature_check ); | ||
| 53 | } | ||
| 54 | |||
| 55 | 	public function provider() { | ||
| 56 | $data = array( | ||
| 57 | 'BRQ_AMOUNT' => '50.00', | ||
| 58 | 'BRQ_CURRENCY' => 'EUR', | ||
| 59 | 'BRQ_CUSTOMER_NAME' => 'J.+de+Tèster', | ||
| 60 | 'BRQ_INVOICENUMBER' => '1234567890', | ||
| 61 | 'BRQ_PAYMENT' => 'F978A56A36D04217BD93157E2B14A578', | ||
| 62 | 'BRQ_PAYMENT_METHOD' => 'ideal', | ||
| 63 | 'BRQ_SERVICE_IDEAL_CONSUMERBIC' => 'RABONL2U', | ||
| 64 | 'BRQ_SERVICE_IDEAL_CONSUMERIBAN' => 'NL44RABO0123456789', | ||
| 65 | 'BRQ_SERVICE_IDEAL_CONSUMERISSUER' => 'Rabobank', | ||
| 66 | 'BRQ_SERVICE_IDEAL_CONSUMERNAME' => 'J.+de+Tèster', | ||
| 67 | 'BRQ_STATUSCODE' => '190', | ||
| 68 | 'BRQ_STATUSCODE_DETAIL' => 'S001', | ||
| 69 | 'BRQ_STATUSMESSAGE' => 'Payment+successfully+processed', | ||
| 70 | 'BRQ_TEST' => 'true', | ||
| 71 | 'BRQ_TIMESTAMP' => '2014-01-01+12:00:00', | ||
| 72 | 'BRQ_TRANSACTIONS' => '098F6BCD4621D373CADE4E832627B4F6', | ||
| 73 | 'BRQ_WEBSITEKEY' => 'fpK0odPM3A', | ||
| 74 | 'BRQ_SIGNATURE' => '84e9802d60d727ade4a845c43033051d5758ce25', | ||
| 75 | ); | ||
| 76 | |||
| 77 | return array( | ||
| 78 | array( $data ), | ||
| 79 | ); | ||
| 80 | } | ||
| 81 | |||
| 82 | 	public function provider_case_mix() { | ||
| 83 | $data_mixcase = array( | ||
| 84 | 'Brq_amount' => '55.00', | ||
| 85 | 'Brq_currency' => 'EUR', | ||
| 86 | 'Brq_customer_name' => 'J.+de+Tèster', | ||
| 87 | 'Brq_invoicenumber' => '1389773524', | ||
| 88 | 'Brq_payment' => 'F978A56A36D04217BD93157E2B14A578', | ||
| 89 | 'Brq_payment_method' => 'ideal', | ||
| 90 | 'Brq_service_ideal_consumerbic' => 'RABONL2U', | ||
| 91 | 'Brq_service_ideal_consumeriban' => 'NL44RABO0123456789', | ||
| 92 | 'Brq_service_ideal_consumerissuer' => 'Rabobank', | ||
| 93 | 'Brq_service_ideal_consumername' => 'J.+de+Tèster', | ||
| 94 | 'Brq_statuscode' => '190', | ||
| 95 | 'Brq_statuscode_detail' => 'S001', | ||
| 96 | 'Brq_statusmessage' => 'Payment+successfully+processed', | ||
| 97 | 'Brq_test' => 'true', | ||
| 98 | 'Brq_timestamp' => '2014-01-01+12:00:00', | ||
| 99 | 'Brq_transactions' => '098F6BCD4621D373CADE4E832627B4F6', | ||
| 100 | 'Brq_websitekey' => 'fpK0odPM3A', | ||
| 101 | 'Brq_signature' => '84e9802d60d727ade4a845c43033051d5758ce25', | ||
| 102 | 'random_1234567890' => 'random_1234567890', | ||
| 103 | ); | ||
| 104 | |||
| 105 | $data_uppercase = array_change_key_case( $data_mixcase, CASE_UPPER ); | ||
| 106 | $data_lowercase = array_change_key_case( $data_mixcase, CASE_LOWER ); | ||
| 107 | |||
| 108 | return array( | ||
| 109 | array( $data_mixcase ), | ||
| 110 | array( $data_uppercase ), | ||
| 111 | array( $data_lowercase ), | ||
| 112 | ); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | 
 
                                
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.