From 982216355fb5404a648854a3b9c4c40e3f1716e5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 23 Jul 2021 19:38:30 +1000 Subject: [PATCH 1/4] MInor fixes --- app/Jobs/Mail/NinjaMailerJob.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index e77379786c..e0a78a829d 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -112,6 +112,10 @@ class NinjaMailerJob implements ShouldQueue } catch (\Exception $e) { + // if($e instanceof GuzzleHttp\Exception\ClientException){ + + // } + nlog("error failed with {$e->getMessage()}"); if($this->nmo->entity) From c0610462475a941f8e969568213ef94f4b699a84 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 24 Jul 2021 10:03:12 +1000 Subject: [PATCH 2/4] Change default row_format from compressed to dynamic --- config/database.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/database.php b/config/database.php index 30f3f2d5d1..18bf7497f2 100644 --- a/config/database.php +++ b/config/database.php @@ -46,7 +46,7 @@ return [ 'prefix' => '', 'prefix_indexes' => true, 'strict' => env('DB_STRICT', false), - // 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', + // 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', ], 'sqlite' => [ @@ -93,7 +93,7 @@ return [ 'prefix' => '', 'prefix_indexes' => true, 'strict' => env('DB_STRICT', false), - 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', // 'options' => array( // PDO::ATTR_EMULATE_PREPARES => true // ), @@ -111,7 +111,7 @@ return [ 'prefix' => '', 'prefix_indexes' => true, 'strict' => env('DB_STRICT', false), - 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', // 'options' => array( // PDO::ATTR_EMULATE_PREPARES => true // ), @@ -129,7 +129,7 @@ return [ 'prefix' => '', 'prefix_indexes' => true, 'strict' => env('DB_STRICT', false), - 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', // 'options' => array( // PDO::ATTR_EMULATE_PREPARES => true // ), @@ -147,7 +147,7 @@ return [ 'prefix' => '', 'prefix_indexes' => true, 'strict' => env('DB_STRICT', false), - 'engine' => 'InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8', + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', // 'options' => array( // PDO::ATTR_EMULATE_PREPARES => true // ), From b5a8c60db5b149a943656e23b6844f9323bee287 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 24 Jul 2021 10:25:48 +1000 Subject: [PATCH 3/4] Improve Company Gateway validation --- .../StoreCompanyGatewayRequest.php | 7 ++-- tests/Feature/CompanyGatewayApiTest.php | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php index 8b4a9109e2..cfb39c4488 100644 --- a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php @@ -34,7 +34,7 @@ class StoreCompanyGatewayRequest extends Request public function rules() { $rules = [ - 'gateway_key' => 'required', + 'gateway_key' => 'required|alpha_num', 'fees_and_limits' => new ValidCompanyGatewayFeesAndLimitsRule(), ]; @@ -45,9 +45,8 @@ class StoreCompanyGatewayRequest extends Request { $input = $this->all(); - $gateway = Gateway::where('key', $input['gateway_key'])->first(); - - if($gateway); + + if($gateway = Gateway::where('key', $input['gateway_key'])->first()) { $default_gateway_fields = json_decode($gateway->fields); diff --git a/tests/Feature/CompanyGatewayApiTest.php b/tests/Feature/CompanyGatewayApiTest.php index 33f7bd55e4..4896a3837c 100644 --- a/tests/Feature/CompanyGatewayApiTest.php +++ b/tests/Feature/CompanyGatewayApiTest.php @@ -45,6 +45,43 @@ class CompanyGatewayApiTest extends TestCase Model::reguard(); } + public function testCompanyGatewayEndPointsWithIncorrectFields() + { + $data = [ + 'config' => 'random config', + 'gateway_key' => '', + ]; + + /* POST */ + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/company_gateways', $data); + + $response->assertStatus(302); + + } + + + public function testCompanyGatewayEndPointsWithInvalidFields() + { + $data = [ + 'config' => 'random config', + 'gateway_key' => '$#%^&*(', + ]; + + /* POST */ + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/company_gateways', $data); + + $response->assertStatus(302); + + } + + + public function testCompanyGatewayEndPoints() { $data = [ From 56e925f40f744f6c944c5f2f83604bf1aeda6b21 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 24 Jul 2021 11:05:00 +1000 Subject: [PATCH 4/4] fixes for company gateyway validation --- app/Mail/TemplateEmail.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 6c9a9217a0..511930eea9 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -107,7 +107,10 @@ class TemplateEmail extends Mailable $message->invitation = $this->invitation; }); - //hosted | plan check here + /*TODO insert another check here for whether the attachment exists */ + nlog($this->build_email->getAttachments()); + + foreach ($this->build_email->getAttachments() as $file) { if(is_string($file))