Merge branch 'fixSymphonyRequestEmptyStrings' into develop

This commit is contained in:
Vincent BRIDIER 2022-03-22 11:29:13 +01:00
commit 708baaa59d
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
2 changed files with 35 additions and 1 deletions

View file

@ -253,11 +253,17 @@ class Service extends Model
*/
public function authenticateApi(Request $request): bool
{
// ! Hack to prevent Laravel to cast empty strings to null or the opposite.
// ! If cannot decode json user legacy all() method.
$data = \json_decode($request->getContent(), true);
$data = (\is_array($data) and \json_last_error() === \JSON_ERROR_NONE) ?
array_replace_recursive($request->all(), $data) : $request->all();
$calculatedHash = Helper::signRequest(
$this->bearer_pwd,
$request->getUri(),
$request->getMethod(),
$request->all()
$data
);
// ! Très important hash_equals https://fr.wikipedia.org/wiki/Attaque_temporelle

View file

@ -118,6 +118,34 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
$this->assertTrue($arcadiaOrderMail->send($customer));
}
/**
* Send arcadia order default game (empty string does not convert to null).
*
* @return void
*/
public function testArcadiaSendOrderGameNullString()
{
$api = new CrmApiV2();
$customer = $api->getCustomerOrNew(static::$info->hashcode);
$arcadiaOrderMail = new ArcadiaMailGame([
'email' => 'toto@gmail.com',
'firstname' => 'Jean',
'lastname' => 'Pouet',
'phone' => '0678142536',
'address' => '30 rue des totots',
'address2' => null,
'city' => 'Le Mans',
'postcode' => '72000',
'operation' => 12,
'order_date' => '2022/03/17 11:24:55',
'support_code' => 16,
'label_type_support' => 'Gain du lot : Lot ',
'code_unique' => '11N311A1',
'code_on_pack' => '12345678'
]);
$this->assertTrue($arcadiaOrderMail->send($customer));
}
/**
* Test arcadia game mail can serialize to json
*