From e41228a1151998a0f4f8c826603e59674916e31c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 18 Oct 2023 15:54:55 +1100 Subject: [PATCH] Fixes for null/not set client contact passwords --- app/Http/Requests/Request.php | 2 +- tests/Feature/ClientTest.php | 28 ++++++++++++++++++++++++++++ tests/Feature/InvoiceEmailTest.php | 10 +++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 2fb9a589e0..8d7eb2acd0 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -180,7 +180,7 @@ class Request extends FormRequest } //Filter the client contact password - if it is sent with ***** we should ignore it! - if (isset($contact['password'])) { + if (isset($contact['password']) && is_string($contact['password'])) { if (strlen($contact['password']) == 0) { $input['contacts'][$key]['password'] = ''; } else { diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 0244a3e822..89b49d945c 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -65,6 +65,34 @@ class ClientTest extends TestCase $this->makeTestData(); } + public function testStoreClientFixes() + { + $data = [ + "contacts" => [ + [ + "email" => "tenda@gmail.com", + "first_name" => "Tenda", + "is_primary" => True, + "last_name" => "Bavuma", + "password" => null, + "send_email" => True + ], + ], + "country_id" => "356", + "display_name" => "Tenda Bavuma", + "name" => "Tenda Bavuma", + "shipping_country_id" => "356", + ]; + + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients', $data); + + $response->assertStatus(200); + } + public function testClientMergeContactDrop() { diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php index 89ef93a1d3..23ba032360 100644 --- a/tests/Feature/InvoiceEmailTest.php +++ b/tests/Feature/InvoiceEmailTest.php @@ -33,7 +33,7 @@ class InvoiceEmailTest extends TestCase use GeneratesCounter; public $faker; - + protected function setUp() :void { parent::setUp(); @@ -50,6 +50,14 @@ class InvoiceEmailTest extends TestCase } + public function testInvalidEmailParsing() + { + $email = 'illegal@example.com'; + + $this->assertTrue(strpos($email, '@example.com') !== false); + } + + public function testClientEmailHistory() { $system_log = new SystemLog();