From 7b802c8fdb5aa1400297e3143b41b12c85a67287 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 28 Sep 2022 12:59:32 -0500 Subject: [PATCH 1/4] Avoid `and` operator, use `&&` --- src/Shared/RfcMatches.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/RfcMatches.php b/src/Shared/RfcMatches.php index 9bb03c2..abdab1a 100644 --- a/src/Shared/RfcMatches.php +++ b/src/Shared/RfcMatches.php @@ -30,7 +30,7 @@ public static function create(RfcMatch ...$items): self $map = []; foreach ($items as $item) { $key = $item->getValue(); - if (! $item->isEmpty() and ! isset($map[$key])) { + if (! $item->isEmpty() && ! isset($map[$key])) { $map[$item->getValue()] = $item; } } From 6beaa28e8ddb3ec5f12ddb8fa1a6dcfe197177a9 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 28 Sep 2022 12:59:04 -0500 Subject: [PATCH 2/4] Test ServiceType value object --- .../ConsumeCfdiServicesUsingFakeFielTest.php | 13 +++++++ ...meRetencionesServicesUsingFakeFielTest.php | 13 +++++++ tests/Unit/Shared/ServiceTypeTest.php | 37 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 tests/Unit/Shared/ServiceTypeTest.php diff --git a/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php b/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php index 054562f..4dff080 100644 --- a/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php +++ b/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php @@ -4,6 +4,7 @@ namespace PhpCfdi\SatWsDescargaMasiva\Tests\Integration; +use LogicException; use PhpCfdi\SatWsDescargaMasiva\Services\Query\QueryParameters; use PhpCfdi\SatWsDescargaMasiva\Shared\ComplementoCfdi; use PhpCfdi\SatWsDescargaMasiva\Shared\DateTimePeriod; @@ -14,6 +15,7 @@ use PhpCfdi\SatWsDescargaMasiva\Shared\RfcMatch; use PhpCfdi\SatWsDescargaMasiva\Shared\RfcOnBehalf; use PhpCfdi\SatWsDescargaMasiva\Shared\ServiceEndpoints; +use PhpCfdi\SatWsDescargaMasiva\Shared\ServiceType; use PhpCfdi\SatWsDescargaMasiva\Shared\Uuid; final class ConsumeCfdiServicesUsingFakeFielTest extends ConsumeServiceTestCase @@ -46,4 +48,15 @@ public function testQueryChangeAllParameters(): void 'Expected to receive a 305 - Certificado Inválido from SAT since FIEL is for testing' ); } + + public function testServiceEndpointsDifferentThanQueryEndpointsThrowsError(): void + { + $service = $this->createService(); + + $otherServiceType = ServiceType::retenciones(); + $parameters = QueryParameters::create()->withServiceType($otherServiceType); + + $this->expectException(LogicException::class); + $service->query($parameters); + } } diff --git a/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php b/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php index cd0198a..6cd1119 100644 --- a/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php +++ b/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php @@ -4,6 +4,7 @@ namespace PhpCfdi\SatWsDescargaMasiva\Tests\Integration; +use LogicException; use PhpCfdi\SatWsDescargaMasiva\Services\Query\QueryParameters; use PhpCfdi\SatWsDescargaMasiva\Shared\ComplementoRetenciones; use PhpCfdi\SatWsDescargaMasiva\Shared\DateTimePeriod; @@ -13,6 +14,7 @@ use PhpCfdi\SatWsDescargaMasiva\Shared\RfcMatch; use PhpCfdi\SatWsDescargaMasiva\Shared\RfcOnBehalf; use PhpCfdi\SatWsDescargaMasiva\Shared\ServiceEndpoints; +use PhpCfdi\SatWsDescargaMasiva\Shared\ServiceType; use PhpCfdi\SatWsDescargaMasiva\Shared\Uuid; /** @@ -47,4 +49,15 @@ public function testQueryChangeAllParameters(): void 'Expected to receive a 305 - Certificado Inválido from SAT since FIEL is for testing' ); } + + public function testServiceEndpointsDifferentThanQueryEndpointsThrowsError(): void + { + $service = $this->createService(); + + $otherServiceType = ServiceType::cfdi(); + $parameters = QueryParameters::create()->withServiceType($otherServiceType); + + $this->expectException(LogicException::class); + $service->query($parameters); + } } diff --git a/tests/Unit/Shared/ServiceTypeTest.php b/tests/Unit/Shared/ServiceTypeTest.php new file mode 100644 index 0000000..eeda14a --- /dev/null +++ b/tests/Unit/Shared/ServiceTypeTest.php @@ -0,0 +1,37 @@ +assertTrue($firstCfdi->equalTo($firstCfdi)); + $this->assertTrue($firstCfdi->equalTo(ServiceType::cfdi())); + $this->assertFalse($firstCfdi->equalTo(ServiceType::retenciones())); + } + + /** @return array */ + public function providerServiceTypes(): array + { + return [ + 'cfdi' => [ServiceType::cfdi()], + 'retenciones' => [ServiceType::retenciones()], + ]; + } + + /** @dataProvider providerServiceTypes */ + public function testJsonEncode(ServiceType $serviceType): void + { + $json = json_encode($serviceType); + $expected = json_encode($serviceType->value()); + $this->assertSame($expected, $json); + } +} From 91fce419714185724b68e143c57f27b5a1a26186 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 28 Sep 2022 18:35:51 -0500 Subject: [PATCH 3/4] Improve testing and code coverage --- .../Internal/FilteredPackageReader.php | 9 +-- .../Internal/ThirdPartiesExtractorTest.php | 77 +++++++++++++++++++ .../FielRequestBuilder/FielTest.php | 16 ++++ 3 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 tests/Unit/PackageReader/Internal/ThirdPartiesExtractorTest.php diff --git a/src/PackageReader/Internal/FilteredPackageReader.php b/src/PackageReader/Internal/FilteredPackageReader.php index 548674a..a1613a1 100644 --- a/src/PackageReader/Internal/FilteredPackageReader.php +++ b/src/PackageReader/Internal/FilteredPackageReader.php @@ -57,18 +57,19 @@ public static function createFromFile(string $filename): self return new self($filename, $archive); } - /** @inheritDoc */ + /** + * @inheritDoc + * @codeCoverageIgnore Unable to produce code coverage for error handling + */ public static function createFromContents(string $content): self { // create temp file try { $tmpfile = tempnam(sys_get_temp_dir(), ''); } catch (Throwable $exception) { - /** @codeCoverageIgnore */ throw CreateTemporaryZipFileException::create('Cannot create a temporary file', $exception); } if (false === $tmpfile) { - /** @codeCoverageIgnore */ throw CreateTemporaryZipFileException::create('Cannot not create a temporary file'); } @@ -76,11 +77,9 @@ public static function createFromContents(string $content): self try { $write = file_put_contents($tmpfile, $content); } catch (Throwable $exception) { - /** @codeCoverageIgnore */ throw CreateTemporaryZipFileException::create('Cannot store contents on temporary file', $exception); } if (false === $write) { - /** @codeCoverageIgnore */ throw CreateTemporaryZipFileException::create('Cannot store contents on temporary file'); } diff --git a/tests/Unit/PackageReader/Internal/ThirdPartiesExtractorTest.php b/tests/Unit/PackageReader/Internal/ThirdPartiesExtractorTest.php new file mode 100644 index 0000000..847d99e --- /dev/null +++ b/tests/Unit/PackageReader/Internal/ThirdPartiesExtractorTest.php @@ -0,0 +1,77 @@ + [ + 'RfcACuentaTerceros' => 'AAAA010101AAA', + 'NombreACuentaTerceros' => 'Registro de ejemplo 1', + ], + '00000000-AAAA-BBBB-1111-000000000002' => [ + 'RfcACuentaTerceros' => 'AAAA010102AAA', + 'NombreACuentaTerceros' => 'Registro de ejemplo 2', + ], + '00000000-AAAA-BBBB-1111-000000000003' => [ + 'RfcACuentaTerceros' => 'AAAA010103AAA', + 'NombreACuentaTerceros' => 'Registro de ejemplo 3', + ], + ]; + $extractor = new ThirdPartiesExtractor(new CsvReader(new ArrayIterator($source))); + $this->assertSame($expected, iterator_to_array($extractor->eachRecord())); + } + + public function testEmptyUuidIsIgnored(): void + { + $source = [ + ['Uuid', 'RfcACuentaTerceros', 'NombreACuentaTerceros'], + ['', 'AAAA010101AAA', 'Registro de ejemplo 1'], + ]; + $expected = []; + $extractor = new ThirdPartiesExtractor(new CsvReader(new ArrayIterator($source))); + $this->assertSame($expected, iterator_to_array($extractor->eachRecord())); + } + + public function testCreateFromPackageReaderNotFilteredPackageReader(): void + { + $packageReader = $this->createMock(PackageReaderInterface::class); + $this->expectException(LogicException::class); + $this->expectExceptionMessage('PackageReader parameter must be a FilteredPackageReader'); + ThirdPartiesExtractor::createFromPackageReader($packageReader); + } + + public function testCreateFromPackageReaderRestoreFilter(): void + { + $packageReader = FilteredPackageReader::createFromFile($this->filePath('zip/metadata.zip')); + $filter = new NullFileFilter(); + $packageReader->setFilter($filter); + + ThirdPartiesExtractor::createFromPackageReader($packageReader); + + $this->assertSame( + $filter, + $packageReader->getFilter(), + 'FilteredPackageReader filter must not change after call createFromPackageReader' + ); + } +} diff --git a/tests/Unit/RequestBuilder/FielRequestBuilder/FielTest.php b/tests/Unit/RequestBuilder/FielRequestBuilder/FielTest.php index 1bf9e0e..7b0efc4 100644 --- a/tests/Unit/RequestBuilder/FielRequestBuilder/FielTest.php +++ b/tests/Unit/RequestBuilder/FielRequestBuilder/FielTest.php @@ -5,6 +5,10 @@ namespace PhpCfdi\SatWsDescargaMasiva\Tests\Unit\RequestBuilder\FielRequestBuilder; use Exception; +use PhpCfdi\Credentials\Certificate; +use PhpCfdi\Credentials\Credential; +use PhpCfdi\Credentials\Internal\SatTypeEnum; +use PhpCfdi\Credentials\PrivateKey; use PhpCfdi\SatWsDescargaMasiva\RequestBuilder\FielRequestBuilder\Fiel; use PhpCfdi\SatWsDescargaMasiva\Tests\TestCase; @@ -51,4 +55,16 @@ public function testIsNotValidUsingCsd(): void ); $this->assertFalse($fiel->isValid()); } + + public function testIsNotValidExpiredCertificate(): void + { + $certificate = $this->createMock(Certificate::class); + $certificate->method('satType')->willReturn(SatTypeEnum::fiel()); + $certificate->method('validOn')->willReturn(false); + $privateKey = $this->createMock(PrivateKey::class); + $privateKey->method('belongsTo')->willReturn(true); + $credential = new Credential($certificate, $privateKey); + $fiel = new Fiel($credential); + $this->assertFalse($fiel->isValid()); + } } From 6d497759b43538dc18d953283b1a49cc9426e22e Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 30 Sep 2022 17:18:07 -0500 Subject: [PATCH 4/4] Fix query by uuid --- README.md | 19 ++++- docs/CHANGELOG.md | 14 ++++ docs/problema-filtros-no-aplicados.md | 11 ++- .../FielRequestBuilder/FielRequestBuilder.php | 73 +++++++++++-------- .../ConsumeCfdiServicesUsingFakeFielTest.php | 17 ++++- ...meRetencionesServicesUsingFakeFielTest.php | 19 ++++- .../FielRequestBuilderTest.php | 24 +++++- ...ed.xml => request-received-by-filters.xml} | 10 ++- .../_files/query/request-received-by-uuid.xml | 33 +++++++++ 9 files changed, 175 insertions(+), 45 deletions(-) rename tests/_files/query/{request-received.xml => request-received-by-filters.xml} (86%) create mode 100644 tests/_files/query/request-received-by-uuid.xml diff --git a/README.md b/README.md index 259f80f..1b58855 100644 --- a/README.md +++ b/README.md @@ -272,7 +272,7 @@ Puede que los cambios del ejemplo no sean lógicos, es solo para ilustrar cómo - Filtrando por únicamente documentos vigentes (excluye cancelados). - Filtrando por el RFC a cuenta de terceros `XXX01010199A`. - Filtrando por el RFC contraparte `MAG041126GT8`. Como se solicitan recibidos, entonces son los emidos por ese RFC. -- Filtrando por el UUID `96623061-61fe-49de-b298-c7156476aa8b` +- Filtrando por el UUID `96623061-61fe-49de-b298-c7156476aa8b`. ```php withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) +; +``` + ### Verificar una consulta La verificación depende de que la consulta haya sido aceptada. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b13595e..a4f437e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,20 @@ que nombraremos así: ` Breaking . Feature . Fix `, donde: **Importante:** Las reglas de SEMVER no aplican si estás usando una rama (por ejemplo `main-dev`) o estás usando una versión cero (por ejemplo `0.18.4`). +## Versión 0.5.2 2022-09-30 + +#### Consulta por UUID + +Gracias a la solicitud de cambios en [`luisiturrios1/python-cfdiclient#42`](https://github.com/luisiturrios1/python-cfdiclient/pull/42) +por `@alan196`, hemos podido verificar que la documentación del servicio con respecto a la consulta por UUID está incorrecta. + +- El campo no se llama `UUID`, se llama `Folio`. +- El campo `RfcSolicitante` no se debe omitir. +- El campo `TipoSolicitud` no se debe omitir. +- Los demás campos no deben existir. + +Por lo tanto, se han hecho las correcciones necesarias para hacer la consulta por `UUID`. + ## Versión 0.5.1 2022-09-28 ### Se corrigen XML mal formados diff --git a/docs/problema-filtros-no-aplicados.md b/docs/problema-filtros-no-aplicados.md index 3f3e7c6..7d8dc93 100644 --- a/docs/problema-filtros-no-aplicados.md +++ b/docs/problema-filtros-no-aplicados.md @@ -19,17 +19,24 @@ En esta versión se agregan nuevos filtros, permitiendo hacer solicitudes más e Los siguientes filtros no están funcionando en la consulta de CFDI Regulares: -- Filtro por UUID. - Filtro de documentos cancelados cuando se solicita un paquete de documentos XML. El filtro funciona correctamente para paquetes de Metadata. Los siguientes filtros no están funcionando en la consulta de CFDI de retenciones e información de pagos: - Filtro por complemento. -- Filtro por UUID. ## Actualizaciones +### 2022-09-30 + +Hemos notado que la documentación del SAT en relación con la consulta por UUID está incorrecta: + +- El campo no se llama `UUID`, se llama `Folio`. +- El campo `RfcSolicitante` se debe especificar. +- El campo `TipoSolicitud` se debe especificar. +- Los demás campos no deben existir. + ### 2022-03-04 El SAT actualiza el servicio a la versión 1.2, no resuelve las solicitudes ingresadas. diff --git a/src/RequestBuilder/FielRequestBuilder/FielRequestBuilder.php b/src/RequestBuilder/FielRequestBuilder/FielRequestBuilder.php index 2680038..d6877e6 100644 --- a/src/RequestBuilder/FielRequestBuilder/FielRequestBuilder.php +++ b/src/RequestBuilder/FielRequestBuilder/FielRequestBuilder.php @@ -74,34 +74,57 @@ public function authorization(DateTime $created, DateTime $expires, string $secu public function query(QueryParameters $queryParameters): string { - // normalize input - $start = $queryParameters->getPeriod()->getStart()->format('Y-m-d\TH:i:s'); - $end = $queryParameters->getPeriod()->getEnd()->format('Y-m-d\TH:i:s'); + $queryByUuid = ! $queryParameters->getUuid()->isEmpty(); + $xmlRfcReceived = ''; $requestType = $queryParameters->getRequestType()->getQueryAttributeValue($queryParameters->getServiceType()); $rfcSigner = mb_strtoupper($this->getFiel()->getRfc()); - if ($queryParameters->getDownloadType()->isIssued()) { - // issued documents, counterparts are receivers - $rfcIssuer = $rfcSigner; - $rfcReceivers = $queryParameters->getRfcMatches(); - } else { - // received documents, counterpart is issuer - $rfcIssuer = $queryParameters->getRfcMatches()->getFirst()->getValue(); - $rfcReceivers = RfcMatches::createFromValues($rfcSigner); - } - $solicitudAttributes = array_filter( - [ - 'RfcSolicitante' => $rfcSigner, + $solicitudAttributes = [ + 'RfcSolicitante' => $rfcSigner, + 'TipoSolicitud' => $requestType, + ]; + + if ($queryByUuid) { + $solicitudAttributes = $solicitudAttributes + [ + 'Folio' => $queryParameters->getUuid()->getValue(), + ]; + } else { + $start = $queryParameters->getPeriod()->getStart()->format('Y-m-d\TH:i:s'); + $end = $queryParameters->getPeriod()->getEnd()->format('Y-m-d\TH:i:s'); + if ($queryParameters->getDownloadType()->isIssued()) { + // issued documents, counterparts are receivers + $rfcIssuer = $rfcSigner; + $rfcReceivers = $queryParameters->getRfcMatches(); + } else { + // received documents, counterpart is issuer + $rfcIssuer = $queryParameters->getRfcMatches()->getFirst()->getValue(); + $rfcReceivers = RfcMatches::createFromValues($rfcSigner); + } + $solicitudAttributes = $solicitudAttributes + [ 'FechaInicial' => $start, 'FechaFinal' => $end, - 'TipoSolicitud' => $requestType, 'RfcEmisor' => $rfcIssuer, 'TipoComprobante' => $queryParameters->getDocumentType()->value(), 'EstadoComprobante' => $queryParameters->getDocumentStatus()->value(), - 'UUID' => $queryParameters->getUuid()->getValue(), 'RfcACuentaTerceros' => $queryParameters->getRfcOnBehalf()->getValue(), 'Complemento' => $queryParameters->getComplement()->value(), - ], + ]; + if (! $rfcReceivers->isEmpty()) { + $xmlRfcReceived = implode('', array_map( + function (RfcMatch $rfcMatch): string { + return sprintf( + '%s', + $this->parseXml($rfcMatch->getValue()) + ); + }, + iterator_to_array($rfcReceivers) + )); + $xmlRfcReceived = "{$xmlRfcReceived}"; + } + } + + $solicitudAttributes = array_filter( + $solicitudAttributes, static function (string $value): bool { return '' !== $value; } @@ -116,20 +139,6 @@ function (string $name, string $value): string { $solicitudAttributes, )); - $xmlRfcReceived = ''; - if (! $rfcReceivers->isEmpty()) { - $xmlRfcReceived = implode('', array_map( - function (RfcMatch $rfcMatch): string { - return sprintf( - '%s', - $this->parseXml($rfcMatch->getValue()) - ); - }, - iterator_to_array($rfcReceivers) - )); - $xmlRfcReceived = "{$xmlRfcReceived}"; - } - $toDigestXml = << diff --git a/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php b/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php index 4dff080..369e241 100644 --- a/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php +++ b/tests/Integration/ConsumeCfdiServicesUsingFakeFielTest.php @@ -36,7 +36,6 @@ public function testQueryChangeAllParameters(): void ->withDocumentType(DocumentType::nomina()) ->withComplement(ComplementoCfdi::nomina12()) ->withDocumentStatus(DocumentStatus::active()) - ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) ->withRfcOnBehalf(RfcOnBehalf::create('XXX01010199A')) ->withRfcMatch(RfcMatch::create('AAA010101AAA')) ; @@ -49,6 +48,22 @@ public function testQueryChangeAllParameters(): void ); } + public function testQueryUuid(): void + { + $service = $this->createService(); + + $parameters = QueryParameters::create() + ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) + ; + + $result = $service->query($parameters); + $this->assertSame( + 305, + $result->getStatus()->getCode(), + 'Expected to receive a 305 - Certificado Inválido from SAT since FIEL is for testing' + ); + } + public function testServiceEndpointsDifferentThanQueryEndpointsThrowsError(): void { $service = $this->createService(); diff --git a/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php b/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php index 6cd1119..7a1c0d9 100644 --- a/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php +++ b/tests/Integration/ConsumeRetencionesServicesUsingFakeFielTest.php @@ -27,7 +27,7 @@ protected function getServiceEndpoints(): ServiceEndpoints return ServiceEndpoints::retenciones(); } - public function testQueryChangeAllParameters(): void + public function testQueryChangeFilters(): void { $service = $this->createService(); @@ -37,7 +37,6 @@ public function testQueryChangeAllParameters(): void ->withRequestType(RequestType::xml()) ->withComplement(ComplementoRetenciones::undefined()) ->withDocumentStatus(DocumentStatus::active()) - ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) ->withRfcOnBehalf(RfcOnBehalf::create('XXX01010199A')) ->withRfcMatch(RfcMatch::create('AAA010101AAA')) ; @@ -50,6 +49,22 @@ public function testQueryChangeAllParameters(): void ); } + public function testQueryByUuid(): void + { + $service = $this->createService(); + + $parameters = QueryParameters::create() + ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) + ; + + $result = $service->query($parameters); + $this->assertSame( + 305, + $result->getStatus()->getCode(), + 'Expected to receive a 305 - Certificado Inválido from SAT since FIEL is for testing' + ); + } + public function testServiceEndpointsDifferentThanQueryEndpointsThrowsError(): void { $service = $this->createService(); diff --git a/tests/Unit/RequestBuilder/FielRequestBuilder/FielRequestBuilderTest.php b/tests/Unit/RequestBuilder/FielRequestBuilder/FielRequestBuilderTest.php index 2c5ea3c..65c429b 100644 --- a/tests/Unit/RequestBuilder/FielRequestBuilder/FielRequestBuilderTest.php +++ b/tests/Unit/RequestBuilder/FielRequestBuilder/FielRequestBuilderTest.php @@ -91,7 +91,7 @@ private function extractSecurityTokenFromXml(string $requestBody): string return $matches['id'] ?? ''; } - public function testQueryReceived(): void + public function testQueryReceivedByFilters(): void { $requestBuilder = $this->createFielRequestBuilderUsingTestingFiles(); $parameters = QueryParameters::create() @@ -102,14 +102,32 @@ public function testQueryReceived(): void ->withDocumentType(DocumentType::nomina()) ->withComplement(ComplementoCfdi::nomina12()) ->withDocumentStatus(DocumentStatus::active()) - ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) ->withRfcOnBehalf(RfcOnBehalf::create('XXX01010199A')) ->withRfcMatch(RfcMatch::create('AAA010101AAA')) ; $requestBody = $requestBuilder->query($parameters); $this->assertSame( - $this->xmlFormat(Helpers::nospaces($this->fileContents('query/request-received.xml'))), + $this->xmlFormat(Helpers::nospaces($this->fileContents('query/request-received-by-filters.xml'))), + $this->xmlFormat($requestBody) + ); + + $xmlSecVerification = (new EnvelopSignatureVerifier()) + ->verify($requestBody, 'http://DescargaMasivaTerceros.sat.gob.mx', 'SolicitaDescarga'); + $this->assertTrue($xmlSecVerification, 'The signature cannot be verified using XMLSecLibs'); + } + + public function testQueryReceivedByUuid(): void + { + $requestBuilder = $this->createFielRequestBuilderUsingTestingFiles(); + $parameters = QueryParameters::create() + ->withServiceType(ServiceType::cfdi()) + ->withUuid(Uuid::create('96623061-61fe-49de-b298-c7156476aa8b')) + ; + $requestBody = $requestBuilder->query($parameters); + + $this->assertSame( + $this->xmlFormat(Helpers::nospaces($this->fileContents('query/request-received-by-uuid.xml'))), $this->xmlFormat($requestBody) ); diff --git a/tests/_files/query/request-received.xml b/tests/_files/query/request-received-by-filters.xml similarity index 86% rename from tests/_files/query/request-received.xml rename to tests/_files/query/request-received-by-filters.xml index b12ac5b..ed6be76 100644 --- a/tests/_files/query/request-received.xml +++ b/tests/_files/query/request-received-by-filters.xml @@ -3,8 +3,10 @@ - - EKU9003173C9 + + + EKU9003173C9 + @@ -14,10 +16,10 @@ - lvCqCw1nWeW7biQuSsjD2KltrQ4= + urJ4pg32vV2oozJcBBKRcxoAydo= - KSTQj+KcLjZEw2iLt2YZn/KB7b96ciHZLci9cHAKl/uGkt7XpQnV1X18ZX9spZZZvlkQyH/gDoEgtMA0yb1oO6ACO66hnfQTaY6b3luhIKrIN9VOdBus6ymrKNhj4mI+ev+HIn1jX1vH8KuVm0lcQ87via8RoOulyvR7lmbuSGILJsshGheofV+eibBdqWe8ukGYYu/iXE9xp+NmI2ltNYizn8fM3wV7F7H51WoJL0lokapcnRk3AeQAbwWw9Yh1dCsb1CqhyRQp6D9fOHpPbQSdhdpdHn774DbH/sqG658Hvx343WrwjDzotLPLVKfGnSTcihDSka6nqXb+EGc4UQ== + U0+zQI1YH5DGtlULhm01lGwoBd1vdbIv/myz/gPshujerNvRzzw9mhGCCq8E7BMsLKefbl4TTOOkL5wvFqczzcKrHS8lFTkw7073CIPVrUyhbajCaqDGRtTvHx84xpi83vknZJhuOu+Pl6gyNIu/g4/MSFtSZ9CKqIu62VBAuepGggY2jsceyMIqNhtLOuR9yGSPR2kTABypkIjvyK9NqM/JivCmHV3FXv6280eHcf40gAtHpTw++ERSRuhW/rkimyJrHLIeMvZpfT9JpORsUCbUHmdEOQae0zXHp0mcGV0woWiRKSBcA2yogl+rrqLc1cbsX5I6jfYTdaegcoe0eQ== diff --git a/tests/_files/query/request-received-by-uuid.xml b/tests/_files/query/request-received-by-uuid.xml new file mode 100644 index 0000000..d39bad1 --- /dev/null +++ b/tests/_files/query/request-received-by-uuid.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + A0teWlShxOD/65O111KTBA+TOSk= + + + d0KaOIjhmXRKuSmbqP/tFoyEqBiNwab5rd8L9mCnjg0TxtbRgJz9+5I7LP0JwJiVWlzcPFoOwth68vSmFqr+hEtvpYlYPmUrPMMiheIv+6D28DLErBlZSRmnXuu3EJuI7D29JAMB2MYML8N8n8Y/NOLGhO3qQIJDAa8AjQCIxgokipU9iZsHtDcHcHZOocCFMWNOBTDLdd8TOsi6HNgWEDeUL18nJ7W1QOamQAU3fmKSPF3I37pISu/MHExPayqDZEaDkbKl0u9j8GGSlFyOreLjvkyfZWj9azlu/jyMIy/DwlEeIviPrccc/nnDQ1T3wYrB2QNeSeP7Xb8QCOx+ug== + + + + CN=AC UAT,O=SERVICIO DE ADMINISTRACION TRIBUTARIA,OU=SAT-IES Authority,emailAddress=oscar.martinez@sat.gob.mx,street=3ra cerrada de cadiz,postalCode=06370,C=MX,ST=CIUDAD DE MEXICO,L=COYOACAN,x500UniqueIdentifier=2.5.4.45,unstructuredName=responsable: ACDMA-SAT + 292233162870206001759766198444326234574038511927 + + MIIGBDCCA+ygAwIBAgIUMzAwMDEwMDAwMD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