refactor(integration): resolver credenciales mediante instancias
Resuelve primero la instancia del cliente y luego la del tipo de sitio cuando existe contexto de tenant. Adapta SMTP y Telepagos, con tokens identificados por instancia y version de credenciales. Separa la edicion de instancias de sus asociaciones y conserva el guardado por cliente creando una instancia nueva. Impide eliminar instancias en uso y adapta las pruebas existentes, incluida la herencia SMTP.
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Tests\Feature\Integration;
|
||||
|
||||
use App\Domains\Attachable\Enums\AttachmentType;
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Integration\Models\ClientIntegration;
|
||||
use App\Domains\Integration\Models\Integration;
|
||||
use App\Domains\Integration\Services\TelepagosIntegrationService;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
@@ -15,10 +14,12 @@ use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\Concerns\CreatesIntegrationInstances;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IntegrationServiceTest extends TestCase
|
||||
{
|
||||
use CreatesIntegrationInstances;
|
||||
use RefreshDatabase;
|
||||
|
||||
private Tenant $tenant;
|
||||
@@ -110,7 +111,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -139,7 +140,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -198,7 +199,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -242,7 +243,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -272,7 +273,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -323,7 +324,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -375,7 +376,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -427,7 +428,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -480,7 +481,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -541,7 +542,7 @@ class IntegrationServiceTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
ClientIntegration::create([
|
||||
$this->createClientIntegration([
|
||||
'client_id' => $this->tenant->client_id,
|
||||
'integration_code' => 'telepagos_homo',
|
||||
'integration_data' => [
|
||||
@@ -566,7 +567,7 @@ class IntegrationServiceTest extends TestCase
|
||||
Log::shouldReceive('error')
|
||||
->once()
|
||||
->with('Telepagos get cash-in details failed: Cashin no encontrado', \Mockery::on(function ($context) {
|
||||
return $context['cashin_id'] === 6351
|
||||
return $context['cashin_id'] === '6351'
|
||||
&& $context['response_status'] === 404
|
||||
&& $context['response_body'] === ['status' => 'error', 'message' => 'Cashin no encontrado'];
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user