diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a115af..d9c4660 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,10 +20,12 @@ jobs: include: - operating-system: "ubuntu-latest" php-version: "8.1" + - operating-system: "ubuntu-latest" + php-version: "8.2" fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" @@ -44,10 +46,12 @@ jobs: include: - operating-system: "ubuntu-latest" php-version: "8.1" + - operating-system: "ubuntu-latest" + php-version: "8.2" fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" @@ -74,10 +78,12 @@ jobs: include: - operating-system: "ubuntu-latest" php-version: "8.1" + - operating-system: "ubuntu-latest" + php-version: "8.2" fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php-version }}" @@ -97,6 +103,7 @@ jobs: - name: PHPUnit uses: php-actions/phpunit@v3 env: + XDEBUG_MODE: coverage FO_ID_DS: '${{ secrets.FO_ID_DS }}' FO_LOGIN_USER: '${{ secrets.FO_LOGIN_USER }}' FO_PASSWORD_USER: '${{ secrets.FO_PASSWORD_USER }}' @@ -115,3 +122,4 @@ jobs: configuration: phpunit.xml php_version: "${{ matrix.php-version }}" php_extensions: "${{ env.extensions }}" + version: "10.2" diff --git a/.gitignore b/.gitignore index 37e4b2b..0116c57 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ composer.lock vendor .phpunit.result.cache +.phpunit.cache tests/_data/test.p12 tests/_reports -.data \ No newline at end of file +.data diff --git a/Dockerfile b/Dockerfile index cceda6b..87040e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,4 +31,4 @@ RUN apt-get -y --no-install-recommends update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* /var/cache/apt/lists COPY --from=builder /var/www . -COPY . ./ \ No newline at end of file +COPY . ./ diff --git a/composer.json b/composer.json index bbed712..a16a4c6 100644 --- a/composer.json +++ b/composer.json @@ -28,13 +28,13 @@ } ], "require": { - "php": "^8.1", + "php": ">=8.1", "ext-curl": "*", "ext-dom": "*", "ext-mbstring": "*", "ext-openssl": "*", "ext-xml": "*", - "symfony/validator": "^6.3", + "symfony/validator": "^6.0", "tomas-kulhanek/serializer": "^2.0" }, "autoload": { @@ -57,7 +57,7 @@ "nyholm/psr7": "^1.4", "php-http/httplug": "^2.2", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.2", "rector/rector": "^0.17.7", "symfony/http-client": "5.4.*|6.*", "symplify/easy-coding-standard": "^12.0" diff --git a/docker-compose.yml b/docker-compose.yml index ee13448..b4a4884 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,4 @@ services: context: . target: development volumes: - - ./:/var/www \ No newline at end of file + - ./:/var/www diff --git a/phpunit.xml b/phpunit.xml index 3117bcb..e70dc1a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,14 @@ - - - - - ./src - - - - - - - - - ./tests/ - - - - \ No newline at end of file + + + + + tests + + + + + + src + + + diff --git a/rector.php b/rector.php index 41b1a67..bb0a2a0 100644 --- a/rector.php +++ b/rector.php @@ -10,7 +10,7 @@ ]); // Define what rule sets will be applied - $containerConfigurator->import(LevelSetList::UP_TO_PHP_81); + $containerConfigurator->import(LevelSetList::UP_TO_PHP_80); $containerConfigurator->phpstanConfig( __DIR__ . '/phpstan.neon'); $containerConfigurator->skip([ diff --git a/src/Account.php b/src/Account.php index f9a5087..e650de5 100644 --- a/src/Account.php +++ b/src/Account.php @@ -8,10 +8,10 @@ class Account { - final public const LOGIN_NAME_PASSWORD = 'password'; - final public const LOGIN_SPIS_CERT = 'cert'; - final public const LOGIN_CERT_LOGIN_NAME_PASSWORD = 'certPassword'; - final public const LOGIN_HOSTED_SPIS = 'hosted'; + public const LOGIN_NAME_PASSWORD = 'password'; + public const LOGIN_SPIS_CERT = 'cert'; + public const LOGIN_CERT_LOGIN_NAME_PASSWORD = 'certPassword'; + public const LOGIN_HOSTED_SPIS = 'hosted'; private ?string $loginName = null; diff --git a/src/Connector.php b/src/Connector.php index 4ffabc3..b94af53 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -52,9 +52,9 @@ class Connector { - private readonly ClientProviderInterface $provider; + private ClientProviderInterface $provider; - private readonly SerializerInterface $serializer; + private SerializerInterface $serializer; public function __construct(SerializerInterface $serializer, ClientProviderInterface $provider) { @@ -131,7 +131,7 @@ public function authenticateMessage(Account $account, AuthenticateMessage $input { return $this->send($account, EndpointProvider::OPERATIONS, $input, DTO\Response\AuthenticateMessage::class); } - + public function getUserInfoFromLogin(Account $account): GetUserInfoFromLogin { return $this->send($account, EndpointProvider::ACCESS, (new DTO\Request\GetUserInfoFromLogin()), GetUserInfoFromLogin::class); diff --git a/src/DTO/Envelope.php b/src/DTO/Envelope.php index 4409402..18b9421 100644 --- a/src/DTO/Envelope.php +++ b/src/DTO/Envelope.php @@ -9,7 +9,7 @@ #[Serializer\XmlRoot(name: 'p:dmEnvelope')] #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] -#[Serializer\AccessorOrder(custom: ['senderOrgUnit', 'senderOrgUnitNum', 'annotation', 'recipientRefNumber', 'senderRefNumber', 'recipientIdent', 'senderIdent', 'legalTitleLaw', 'legalTitleYear', 'legalTitleSect', 'legalTitlePar', 'legalTitlePoint', 'personalDelivery', 'allowSubstDelivery', 'ovm', 'publishOwnId'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['senderOrgUnit', 'senderOrgUnitNum', 'annotation', 'recipientRefNumber', 'senderRefNumber', 'recipientIdent', 'senderIdent', 'legalTitleLaw', 'legalTitleYear', 'legalTitleSect', 'legalTitlePar', 'legalTitlePoint', 'personalDelivery', 'allowSubstDelivery', 'ovm', 'publishOwnId'])] class Envelope { use DataMessageEnvelopeSub; diff --git a/src/DTO/Request/CreateMessage.php b/src/DTO/Request/CreateMessage.php index 9f08c50..2c1ce23 100644 --- a/src/DTO/Request/CreateMessage.php +++ b/src/DTO/Request/CreateMessage.php @@ -13,7 +13,7 @@ #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] #[Serializer\XmlRoot(name: 'p:CreateMultipleMessage', namespace: 'http://isds.czechpoint.cz/v20')] -#[Serializer\AccessorOrder(custom: ['recipients', 'envelope', 'files'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['recipients', 'envelope', 'files'])] class CreateMessage implements IRequest { use GetMainFile; @@ -50,17 +50,11 @@ class CreateMessage implements IRequest #[Assert\Valid()] protected array $recipients = []; - /** - * @return Envelope - */ public function getEnvelope(): Envelope { return $this->envelope; } - /** - * @return CreateMessage - */ public function setEnvelope(Envelope $envelope): CreateMessage { $this->envelope = $envelope; @@ -77,7 +71,6 @@ public function getFiles(): array /** * @param File[] $files - * @return CreateMessage */ public function setFiles(array $files): CreateMessage { diff --git a/src/DTO/Request/DataBoxCreditInfo.php b/src/DTO/Request/DataBoxCreditInfo.php index b9f5649..b81ecb0 100644 --- a/src/DTO/Request/DataBoxCreditInfo.php +++ b/src/DTO/Request/DataBoxCreditInfo.php @@ -10,7 +10,7 @@ #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] #[Serializer\XmlRoot(name: 'p:DataBoxCreditInfo', namespace: 'http://isds.czechpoint.cz/v20')] -#[Serializer\AccessorOrder(custom: ['dataBoxId', 'fromDate', 'toDate'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['dataBoxId', 'fromDate', 'toDate'])] class DataBoxCreditInfo implements IRequest { use DataBoxId; @@ -18,12 +18,12 @@ class DataBoxCreditInfo implements IRequest #[Serializer\Type("DateTimeImmutable<'Y-m-d'>")] #[Serializer\XmlElement(cdata: false)] #[Serializer\SerializedName('p:ciFromDate')] - private readonly DateTimeImmutable $fromDate; + private DateTimeImmutable $fromDate; #[Serializer\Type("DateTimeImmutable<'Y-m-d'>")] #[Serializer\XmlElement(cdata: false)] #[Serializer\SerializedName('p:ciTodate')] - private readonly DateTimeImmutable $toDate; + private DateTimeImmutable $toDate; public function __construct(DateTimeImmutable $fromDate, DateTimeImmutable $toDate) { diff --git a/src/DTO/Request/GetDataBoxActivityStatus.php b/src/DTO/Request/GetDataBoxActivityStatus.php index b3c8d5e..eb203d1 100644 --- a/src/DTO/Request/GetDataBoxActivityStatus.php +++ b/src/DTO/Request/GetDataBoxActivityStatus.php @@ -10,7 +10,7 @@ #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] #[Serializer\XmlRoot(name: 'p:GetDataBoxActivityStatus', namespace: 'http://isds.czechpoint.cz/v20')] -#[Serializer\AccessorOrder(custom: ['dataBoxId', 'from', 'to'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['dataBoxId', 'from', 'to'])] class GetDataBoxActivityStatus implements IRequest { use DataBoxId; diff --git a/src/DTO/Response/CreateMessage.php b/src/DTO/Response/CreateMessage.php index ae1d4d2..dde3ffa 100644 --- a/src/DTO/Response/CreateMessage.php +++ b/src/DTO/Response/CreateMessage.php @@ -11,7 +11,7 @@ #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] #[Serializer\XmlRoot(name: 'p:CreateMultipleMessageResponse', namespace: 'http://isds.czechpoint.cz/v20')] -#[Serializer\AccessorOrder(custom: ['messageStatus', 'status'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['messageStatus', 'status'])] class CreateMessage extends IResponse { use DataMessageStatus; diff --git a/src/DTO/Response/FindPersonalDataBox.php b/src/DTO/Response/FindPersonalDataBox.php index 0cc280f..613996a 100644 --- a/src/DTO/Response/FindPersonalDataBox.php +++ b/src/DTO/Response/FindPersonalDataBox.php @@ -27,7 +27,7 @@ class FindPersonalDataBox extends IResponse new Assert\Type(type: PersonalOwnerInfo::class) ])] #[Assert\Valid()] - protected $record; + protected array $record = []; /** * @return PersonalOwnerInfo[] diff --git a/src/DTO/Response/GetMessageStateChanges.php b/src/DTO/Response/GetMessageStateChanges.php index d0a6baa..119b08e 100644 --- a/src/DTO/Response/GetMessageStateChanges.php +++ b/src/DTO/Response/GetMessageStateChanges.php @@ -22,7 +22,7 @@ class GetMessageStateChanges extends IResponse #[Serializer\XmlList(entry: 'dmRecord', inline: false)] #[Serializer\SerializedName('p:dmRecords')] #[Assert\All([ - new Assert\Type(type: StateChangeRecord::class) + new Assert\Type(StateChangeRecord::class) ])] #[Assert\Valid()] protected array $record = []; diff --git a/src/DTO/Response/SignedSentMessageDownload.php b/src/DTO/Response/SignedSentMessageDownload.php index e9afd43..c519340 100644 --- a/src/DTO/Response/SignedSentMessageDownload.php +++ b/src/DTO/Response/SignedSentMessageDownload.php @@ -10,7 +10,7 @@ #[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')] #[Serializer\XmlRoot(name: 'p:SignedSentMessageDownloadResponse', namespace: 'http://isds.czechpoint.cz/v20')] -#[Serializer\AccessorOrder(custom: ['signature', 'status'])] +#[Serializer\AccessorOrder(order: 'custom', custom: ['signature', 'status'])] class SignedSentMessageDownload extends IResponse { use DataMessageStatus; diff --git a/src/Provider/EndpointProvider.php b/src/Provider/EndpointProvider.php index af5ddf4..bfa7297 100644 --- a/src/Provider/EndpointProvider.php +++ b/src/Provider/EndpointProvider.php @@ -9,11 +9,11 @@ class EndpointProvider { - final public const OPERATIONS = 0; - final public const INFO = 1; - final public const SEARCH = 2; - final public const SUPPLEMENTARY = 3; - final public const ACCESS = 5; + public const OPERATIONS = 0; + public const INFO = 1; + public const SEARCH = 2; + public const SUPPLEMENTARY = 3; + public const ACCESS = 5; private function getServiceDomain(bool $isProduction): string { diff --git a/src/Provider/GuzzleClientProvider.php b/src/Provider/GuzzleClientProvider.php index 1415310..9131c8c 100644 --- a/src/Provider/GuzzleClientProvider.php +++ b/src/Provider/GuzzleClientProvider.php @@ -16,8 +16,8 @@ class GuzzleClientProvider implements ClientProviderInterface { - private readonly Client $client; - private readonly EndpointProvider $endpointProvider; + private Client $client; + private EndpointProvider $endpointProvider; public static function create(): self { diff --git a/src/Provider/SymfonyClientProvider.php b/src/Provider/SymfonyClientProvider.php index ec494b7..95e7dd2 100644 --- a/src/Provider/SymfonyClientProvider.php +++ b/src/Provider/SymfonyClientProvider.php @@ -16,8 +16,8 @@ class SymfonyClientProvider implements ClientProviderInterface { - private readonly HttpClientInterface $client; - private readonly EndpointProvider $endpointProvider; + private HttpClientInterface $client; + private EndpointProvider $endpointProvider; public static function create(): self diff --git a/src/Traits/DataMessageStatus.php b/src/Traits/DataMessageStatus.php index a1e628c..7f218ae 100644 --- a/src/Traits/DataMessageStatus.php +++ b/src/Traits/DataMessageStatus.php @@ -5,6 +5,7 @@ namespace TomasKulhanek\CzechDataBox\Traits; use JMS\Serializer\Annotation as Serializer; +use Symfony\Component\Validator\Constraints as Assert; use TomasKulhanek\CzechDataBox\DTO\Response\IResponseStatus; trait DataMessageStatus @@ -12,6 +13,7 @@ trait DataMessageStatus #[Serializer\Type(\TomasKulhanek\CzechDataBox\DTO\DataMessageStatus::class)] #[Serializer\SerializedName('p:dmStatus')] #[Serializer\XmlElement(cdata: false)] + #[Assert\Valid()] protected IResponseStatus $status; public function getStatus(): IResponseStatus diff --git a/src/Utils/BinarySuffix.php b/src/Utils/BinarySuffix.php index 6ab2347..5cb2e74 100644 --- a/src/Utils/BinarySuffix.php +++ b/src/Utils/BinarySuffix.php @@ -8,9 +8,9 @@ class BinarySuffix { - final public const CONVERT_THRESHOLD = 1024; + public const CONVERT_THRESHOLD = 1024; - private readonly int $number; + private int $number; /** * @var array diff --git a/src/Utils/DataBoxStatus.php b/src/Utils/DataBoxStatus.php index fe1f8da..9a5b416 100644 --- a/src/Utils/DataBoxStatus.php +++ b/src/Utils/DataBoxStatus.php @@ -8,56 +8,56 @@ class DataBoxStatus { - final public const GENERAL = 'GENERAL'; - final public const ADDRESS = 'ADDRESS'; - final public const ICO = 'ICO'; - final public const DBID = 'DBID'; - final public const ALL = 'ALL'; - final public const OVM = 'OVM'; - final public const OVM_MAIN = 'OVM_MAIN'; - final public const OVM_REQ = 'OVM_REQ'; - final public const OVM_NOTAR = 'OVM_NOTAR'; - final public const OVM_EXEKUT = 'OVM_EXEKUT'; - final public const OVM_FO = 'OVM_FO'; - final public const OVM_PFO = 'OVM_PFO'; - final public const OVM_PO = 'OVM_PO'; - final public const PO = 'PO'; - final public const PO_ZAK = 'PO_ZAK'; - final public const PO_REQ = 'PO_REQ'; - final public const PFO = 'PFO'; - final public const PFO_ADVOK = 'PFO_ADVOK'; - final public const PFO_INSSPR = 'PFO_INSSPR'; - final public const PFO_DANPOR = 'PFO_DANPOR'; - final public const PFO_AUDITOR = 'PFO_AUDITOR'; - final public const FO = 'FO'; + public const GENERAL = 'GENERAL'; + public const ADDRESS = 'ADDRESS'; + public const ICO = 'ICO'; + public const DBID = 'DBID'; + public const ALL = 'ALL'; + public const OVM = 'OVM'; + public const OVM_MAIN = 'OVM_MAIN'; + public const OVM_REQ = 'OVM_REQ'; + public const OVM_NOTAR = 'OVM_NOTAR'; + public const OVM_EXEKUT = 'OVM_EXEKUT'; + public const OVM_FO = 'OVM_FO'; + public const OVM_PFO = 'OVM_PFO'; + public const OVM_PO = 'OVM_PO'; + public const PO = 'PO'; + public const PO_ZAK = 'PO_ZAK'; + public const PO_REQ = 'PO_REQ'; + public const PFO = 'PFO'; + public const PFO_ADVOK = 'PFO_ADVOK'; + public const PFO_INSSPR = 'PFO_INSSPR'; + public const PFO_DANPOR = 'PFO_DANPOR'; + public const PFO_AUDITOR = 'PFO_AUDITOR'; + public const FO = 'FO'; - final public const TYPE_GENERAL = 'GENERAL'; - final public const TYPE_ADDRESS = 'ADDRESS'; - final public const TYPE_ICO = 'ICO'; - final public const TYPE_DBID = 'DBID'; - final public const SCOPE_ALL = 'ALL'; - final public const SCOPE_OVM = 'OVM'; - final public const SCOPE_OVM_MAIN = 'OVM_MAIN'; - final public const SCOPE_OVM_REQ = 'OVM_REQ'; - final public const SCOPE_OVM_NOTAR = 'OVM_NOTAR'; - final public const SCOPE_OVM_EXEKUT = 'OVM_EXEKUT'; - final public const SCOPE_OVM_FO = 'OVM_FO'; - final public const SCOPE_OVM_PFO = 'OVM_PFO'; - final public const SCOPE_OVM_PO = 'OVM_PO'; - final public const SCOPE_PO = 'PO'; - final public const SCOPE_PO_ZAK = 'PO_ZAK'; - final public const SCOPE_PO_REQ = 'PO_REQ'; - final public const SCOPE_PFO = 'PFO'; - final public const SCOPE_PFO_ADVOK = 'PFO_ADVOK'; - final public const SCOPE_PFO_INSSPR = 'PFO_INSSPR'; - final public const SCOPE_PFO_DANPOR = 'PFO_DANPOR'; - final public const SCOPE_PFO_AUDITOR = 'PFO_AUDITOR'; - final public const SCOPE_FO = 'FO'; + public const TYPE_GENERAL = 'GENERAL'; + public const TYPE_ADDRESS = 'ADDRESS'; + public const TYPE_ICO = 'ICO'; + public const TYPE_DBID = 'DBID'; + public const SCOPE_ALL = 'ALL'; + public const SCOPE_OVM = 'OVM'; + public const SCOPE_OVM_MAIN = 'OVM_MAIN'; + public const SCOPE_OVM_REQ = 'OVM_REQ'; + public const SCOPE_OVM_NOTAR = 'OVM_NOTAR'; + public const SCOPE_OVM_EXEKUT = 'OVM_EXEKUT'; + public const SCOPE_OVM_FO = 'OVM_FO'; + public const SCOPE_OVM_PFO = 'OVM_PFO'; + public const SCOPE_OVM_PO = 'OVM_PO'; + public const SCOPE_PO = 'PO'; + public const SCOPE_PO_ZAK = 'PO_ZAK'; + public const SCOPE_PO_REQ = 'PO_REQ'; + public const SCOPE_PFO = 'PFO'; + public const SCOPE_PFO_ADVOK = 'PFO_ADVOK'; + public const SCOPE_PFO_INSSPR = 'PFO_INSSPR'; + public const SCOPE_PFO_DANPOR = 'PFO_DANPOR'; + public const SCOPE_PFO_AUDITOR = 'PFO_AUDITOR'; + public const SCOPE_FO = 'FO'; - final public const PDZ_K = 'K'; - final public const PDZ_O = 'O'; - final public const PDZ_G = 'G'; - final public const PDZ_E = 'E'; + public const PDZ_K = 'K'; + public const PDZ_O = 'O'; + public const PDZ_G = 'G'; + public const PDZ_E = 'E'; /** * @return array diff --git a/src/Utils/MessageStatus.php b/src/Utils/MessageStatus.php index 3e40a49..10d64c3 100644 --- a/src/Utils/MessageStatus.php +++ b/src/Utils/MessageStatus.php @@ -8,17 +8,17 @@ class MessageStatus { - final public const FILTER_ALL = -1; - final public const FILTER_SUBMITTED = 1; - final public const FILTER_STAMPED = 2; - final public const FILTER_ANTIVIRUS_FAILED = 3; - final public const FILTER_DELIVERED = 4; - final public const FILTER_DELIVERED_AFTER_TIME = 5; - final public const FILTER_DELIVERED_BY_LOGIN = 6; - final public const FILTER_READ = 7; - final public const FILTER_UNDELIVERED = 8; - final public const FILTER_DELETED = 9; - final public const FILTER_IN_VAULT = 10; + public const FILTER_ALL = -1; + public const FILTER_SUBMITTED = 1; + public const FILTER_STAMPED = 2; + public const FILTER_ANTIVIRUS_FAILED = 3; + public const FILTER_DELIVERED = 4; + public const FILTER_DELIVERED_AFTER_TIME = 5; + public const FILTER_DELIVERED_BY_LOGIN = 6; + public const FILTER_READ = 7; + public const FILTER_UNDELIVERED = 8; + public const FILTER_DELETED = 9; + public const FILTER_IN_VAULT = 10; public static function getDecEntryForStatus(int ...$statuses): float { diff --git a/tests/Integration/AccountTrait.php b/tests/Integration/AccountTrait.php index 436fa1b..29ab748 100644 --- a/tests/Integration/AccountTrait.php +++ b/tests/Integration/AccountTrait.php @@ -14,9 +14,9 @@ protected function createPFOAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_NAME_PASSWORD); - $account->setLoginName(getenv('PFO_LOGIN_USER')); - $account->setPassword(getenv('PFO_PASSWORD_USER')); - $account->setDataBoxId(getenv('PFO_ID_DS')); + $account->setLoginName((string) getenv('PFO_LOGIN_USER')); + $account->setPassword((string) getenv('PFO_PASSWORD_USER')); + $account->setDataBoxId((string) getenv('PFO_ID_DS')); return $account; } @@ -25,12 +25,12 @@ protected function createPFOCertAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_HOSTED_SPIS); - $account->setPublicKey(file_get_contents(__DIR__ . '/../../.data/cert.crt')); - $account->setPrivateKey(file_get_contents(__DIR__ . '/../../.data/cert.pem')); - $account->setLoginName(getenv('PFO_LOGIN_USER')); - $account->setPassword(getenv('PFO_PASSWORD_USER')); - $account->setPrivateKeyPassPhrase(getenv('CERT_PASSPHRASE')); - $account->setDataBoxId(getenv('PFO_ID_DS')); + $account->setPublicKey((string) file_get_contents(__DIR__ . '/../../.data/cert.crt')); + $account->setPrivateKey((string) file_get_contents(__DIR__ . '/../../.data/cert.pem')); + $account->setLoginName((string) getenv('PFO_LOGIN_USER')); + $account->setPassword((string) getenv('PFO_PASSWORD_USER')); + $account->setPrivateKeyPassPhrase((string) getenv('CERT_PASSPHRASE')); + $account->setDataBoxId((string) getenv('PFO_ID_DS')); return $account; } @@ -39,9 +39,9 @@ protected function createFOAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_NAME_PASSWORD); - $account->setLoginName(getenv('FO_LOGIN_USER')); - $account->setPassword(getenv('FO_PASSWORD_USER')); - $account->setDataBoxId(getenv('FO_ID_DS')); + $account->setLoginName((string) getenv('FO_LOGIN_USER')); + $account->setPassword((string) getenv('FO_PASSWORD_USER')); + $account->setDataBoxId((string) getenv('FO_ID_DS')); return $account; } @@ -50,12 +50,12 @@ protected function createFOCertAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_HOSTED_SPIS); - $account->setPublicKey(file_get_contents(__DIR__ . '/../../.data/cert.crt')); - $account->setPrivateKey(file_get_contents(__DIR__ . '/../../.data/cert.pem')); - $account->setLoginName(getenv('FO_LOGIN_USER')); - $account->setPassword(getenv('FO_PASSWORD_USER')); - $account->setPrivateKeyPassPhrase(getenv('CERT_PASSPHRASE')); - $account->setDataBoxId(getenv('FO_ID_DS')); + $account->setPublicKey((string) file_get_contents(__DIR__ . '/../../.data/cert.crt')); + $account->setPrivateKey((string) file_get_contents(__DIR__ . '/../../.data/cert.pem')); + $account->setLoginName((string) getenv('FO_LOGIN_USER')); + $account->setPassword((string) getenv('FO_PASSWORD_USER')); + $account->setPrivateKeyPassPhrase((string) getenv('CERT_PASSPHRASE')); + $account->setDataBoxId((string) getenv('FO_ID_DS')); return $account; } @@ -64,12 +64,12 @@ protected function createOvmCertAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_HOSTED_SPIS); - $account->setPublicKey(file_get_contents(__DIR__ . '/../../.data/cert.crt')); - $account->setPrivateKey(file_get_contents(__DIR__ . '/../../.data/cert.pem')); - $account->setLoginName(getenv('OVM_LOGIN_USER')); - $account->setPassword(getenv('OVM_PASSWORD_USER')); - $account->setPrivateKeyPassPhrase(getenv('CERT_PASSPHRASE')); - $account->setDataBoxId(getenv('OVM_ID_DS')); + $account->setPublicKey((string) file_get_contents(__DIR__ . '/../../.data/cert.crt')); + $account->setPrivateKey((string) file_get_contents(__DIR__ . '/../../.data/cert.pem')); + $account->setLoginName((string) getenv('OVM_LOGIN_USER')); + $account->setPassword((string) getenv('OVM_PASSWORD_USER')); + $account->setPrivateKeyPassPhrase((string) getenv('CERT_PASSPHRASE')); + $account->setDataBoxId((string) getenv('OVM_ID_DS')); return $account; } @@ -78,9 +78,9 @@ protected function createOVMAccount(): Account $account = new \TomasKulhanek\CzechDataBox\Account(); $account->setProduction((bool) getenv('IS_PRODUCTION')); $account->setLoginType($account::LOGIN_NAME_PASSWORD); - $account->setLoginName(getenv('OVM_LOGIN_USER')); - $account->setPassword(getenv('OVM_PASSWORD_USER')); - $account->setDataBoxId(getenv('OVM_ID_DS')); + $account->setLoginName((string) getenv('OVM_LOGIN_USER')); + $account->setPassword((string) getenv('OVM_PASSWORD_USER')); + $account->setDataBoxId((string) getenv('OVM_ID_DS')); return $account; } } diff --git a/tests/Integration/DataMessageTest.php b/tests/Integration/DataMessageTest.php index 481591b..50ce7e9 100644 --- a/tests/Integration/DataMessageTest.php +++ b/tests/Integration/DataMessageTest.php @@ -37,6 +37,7 @@ public function testVerifyMessage(): void public function testCreateMessage(): void { + self::assertTrue($this->createOVMAccount()->getDataBoxId() !== null); $newMessageEnvelope = $this->getNewMessageEnvelope(); $recipient = new DTO\Recipient(); $recipient->setDataBoxId($this->createOVMAccount()->getDataBoxId()); @@ -71,6 +72,7 @@ public function testMessageDownload(): void $response = $client->messageDownload($ovmAccount, $request); self::assertTrue($response->getStatus()->isOk(), $response->getStatus()->getMessage()); + self::assertTrue($response->getReturnedMessage() !== null); self::assertSame($ovmAccount->getDataBoxId(), $response->getReturnedMessage()->getDataMessage()->getRecipientId()); } diff --git a/tests/Integration/GuzzleProviderTest.php b/tests/Integration/GuzzleProviderTest.php index b800edc..74b1ae1 100644 --- a/tests/Integration/GuzzleProviderTest.php +++ b/tests/Integration/GuzzleProviderTest.php @@ -13,7 +13,7 @@ class GuzzleProviderTest extends TestCase use AccountTrait; use ConnectorTrait; - public function testLoginAndPassword() + public function testLoginAndPassword(): void { $account = $this->createFOAccount(); @@ -23,7 +23,7 @@ public function testLoginAndPassword() self::assertTrue($response->getStatus()->isOk()); } - public function testHspis() + public function testHspis(): void { $account = $this->createFOCertAccount(); @@ -33,7 +33,7 @@ public function testHspis() self::assertTrue($response->getStatus()->isOk()); } - public function testLoginAndPasswordAndCert() + public function testLoginAndPasswordAndCert(): void { $account = $this->createOvmCertAccount(); $account->setLoginType(Account::LOGIN_CERT_LOGIN_NAME_PASSWORD); @@ -44,7 +44,7 @@ public function testLoginAndPasswordAndCert() self::assertTrue($response->getStatus()->isOk()); } - public function testSpisCert() + public function testSpisCert(): void { $account = $this->createOvmCertAccount(); $account->setLoginType(Account::LOGIN_SPIS_CERT); diff --git a/tests/Integration/SymfonyProviderTest.php b/tests/Integration/SymfonyProviderTest.php index 6e53dfe..e16c1af 100644 --- a/tests/Integration/SymfonyProviderTest.php +++ b/tests/Integration/SymfonyProviderTest.php @@ -13,7 +13,7 @@ class SymfonyProviderTest extends TestCase use AccountTrait; use ConnectorTrait; - public function testLoginAndPassword() + public function testLoginAndPassword(): void { $account = $this->createFOAccount(); @@ -23,7 +23,7 @@ public function testLoginAndPassword() self::assertTrue($response->getStatus()->isOk()); } - public function testHspis() + public function testHspis(): void { $account = $this->createFOCertAccount(); @@ -33,7 +33,7 @@ public function testHspis() self::assertTrue($response->getStatus()->isOk()); } - public function testLoginAndPasswordAndCert() + public function testLoginAndPasswordAndCert(): void { $account = $this->createOvmCertAccount(); $account->setLoginType(Account::LOGIN_CERT_LOGIN_NAME_PASSWORD); @@ -44,7 +44,7 @@ public function testLoginAndPasswordAndCert() self::assertTrue($response->getStatus()->isOk()); } - public function testSpisCert() + public function testSpisCert(): void { $account = $this->createOvmCertAccount(); $account->setLoginType(Account::LOGIN_SPIS_CERT); diff --git a/tests/Unit/GeneratePkcs.php b/tests/Unit/GeneratePkcs.php index 1aead75..ba15fee 100644 --- a/tests/Unit/GeneratePkcs.php +++ b/tests/Unit/GeneratePkcs.php @@ -9,7 +9,7 @@ trait GeneratePkcs { private function generateP12Certificate(string $passPhrase): string { - $Info = [ + $dn = [ "countryName" => "CZ", "stateOrProvinceName" => "Prague", "localityName" => "Prague", @@ -19,13 +19,16 @@ private function generateP12Certificate(string $passPhrase): string "emailAddress" => "jsem+tests@tomaskulhanek.cz", ]; - $Private_Key = null; - $Unsigned_Cert = openssl_csr_new($Info, $Private_Key); + $privateKey = openssl_pkey_new([ + "private_key_bits" => 2048, + "private_key_type" => OPENSSL_KEYTYPE_RSA, + ]); + $csr = openssl_csr_new($dn, $privateKey, ['digest_alg' => 'sha256']); - $Signed_Cert = openssl_csr_sign($Unsigned_Cert, null, $Private_Key, 365); + $x509 = openssl_csr_sign($csr, null, $privateKey, 365, ['digest_alg' => 'sha256']); $certFilePath = __DIR__ . "/../_data/test.p12"; - openssl_pkcs12_export_to_file($Signed_Cert, $certFilePath, $Private_Key, $passPhrase); + openssl_pkcs12_export_to_file($x509, $certFilePath, $privateKey, $passPhrase); return file_get_contents($certFilePath); } }