Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate with success when signer account was deleted #4331

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Service/FileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ private function loadLibreSignSigners(): void {
}
$signers = $this->signRequestMapper->getByFileId($this->file->getId());
foreach ($signers as $signer) {
$identifyMethods = $this->identifyMethodService->getIdentifyMethodsFromSignRequestId($signer->getId());
$identifyMethods = $this->identifyMethodService
->setIsRequest(false)
->getIdentifyMethodsFromSignRequestId($signer->getId());
if (!empty($this->fileData->signers)) {
$found = array_filter($this->fileData->signers, function ($found) use ($identifyMethods) {
if (!isset($found['uid'])) {
Expand Down
8 changes: 7 additions & 1 deletion lib/Service/IdentifyMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class IdentifyMethodService {
self::IDENTIFY_PASSWORD,
self::IDENTIFY_CLICK_TO_SIGN,
];
private bool $isRequest = true;
private ?IdentifyMethod $currentIdentifyMethod = null;
private array $identifyMethodsSettings = [];
/**
Expand All @@ -51,6 +52,11 @@ public function __construct(
) {
}

public function setIsRequest(bool $isRequest): self {
$this->isRequest = $isRequest;
return $this;
}

public function getInstanceOfIdentifyMethod(string $name, ?string $identifyValue = null): IIdentifyMethod {
if ($identifyValue && isset($this->identifyMethods[$name])) {
foreach ($this->identifyMethods[$name] as $identifyMethod) {
Expand All @@ -67,7 +73,7 @@ public function getInstanceOfIdentifyMethod(string $name, ?string $identifyValue
$entity->setIdentifierValue($identifyValue);
$entity->setMandatory($this->isMandatoryMethod($name) ? 1 : 0);
}
if ($identifyValue) {
if ($identifyValue && $this->isRequest) {
$identifyMethod->validateToRequest();
}

Expand Down
31 changes: 31 additions & 0 deletions tests/integration/features/file/validate.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Feature: validate
Scenario: Sign with account, delete the account and validate
Given as user "admin"
And run the command "libresign:install --use-local-cert --java" with result code 0
And run the command "libresign:install --use-local-cert --jsignpdf" with result code 0
And run the command "libresign:install --use-local-cert --pdftk" with result code 0
And run the command "libresign:configure:openssl --cn test" with result code 0
And sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods"
| value | (string)[{"name":"account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":true}}}] |
And user "signer1" exists
When sending "post" to ocs "/apps/libresign/api/v1/request-signature"
| file | {"url":"<BASE_URL>/apps/libresign/develop/pdf"} |
| users | [{"identify":{"account":"signer1"}}] |
| name | Document Name |
Then the response should have a status code 200
And as user "signer1"
And sending "get" to ocs "/apps/libresign/api/v1/file/list"
Then the response should be a JSON array with the following mandatory values
| key | value |
| (jq).ocs.data.data[0].name | Document Name |
And fetch field "(SIGN_URL)ocs.data.data.0.url" from prevous JSON response
And fetch field "(SIGN_UUID)ocs.data.data.0.signers.0.sign_uuid" from prevous JSON response
And fetch field "(FILE_UUID)ocs.data.data.0.uuid" from prevous JSON response
When sending "post" to ocs "/apps/libresign/api/v1/sign/uuid/<SIGN_UUID>"
| key | value |
| method | clickToSign |
Then the response should have a status code 200
When run the command "user:delete signer1" with result code 0
And as user ""
And sending "get" to ocs "/apps/libresign/api/v1/file/validate/uuid/<FILE_UUID>"
Then the response should have a status code 200
Loading