diff --git a/tests/integration/features/account/create_to_sign.feature b/tests/integration/features/account/create_to_sign.feature index fae836ed59..ff4a0f47fd 100644 --- a/tests/integration/features/account/create_to_sign.feature +++ b/tests/integration/features/account/create_to_sign.feature @@ -1,7 +1,7 @@ Feature: account/create_to_sign Background: Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + 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":"email","enabled":true,"mandatory":true,"can_create_account":true}] | And my inbox is empty @@ -14,8 +14,8 @@ Feature: account/create_to_sign Scenario: Try to create with invalid data Given as user "" - And run the command "user:delete signer1@domain.test" - And run the command "user:delete signer1" + And run the command "user:delete signer1@domain.test" with result code 0 + And run the command "user:delete signer1" with result code 0 And I open the latest email to "signer1@domain.test" with subject "LibreSign: There is a file for you to sign" And I fetch the signer UUID from opened email And follow the link on opened email @@ -36,7 +36,7 @@ Feature: account/create_to_sign Scenario: Create with valid data Given as user "" - And run the command "user:delete signer1@domain.test" + And run the command "user:delete signer1@domain.test" with result code 0 And I open the latest email to "signer1@domain.test" with subject "LibreSign: There is a file for you to sign" And I fetch the signer UUID from opened email And follow the link on opened email diff --git a/tests/integration/features/account/signature.feature b/tests/integration/features/account/signature.feature index d80172c8ea..f76ca5a969 100644 --- a/tests/integration/features/account/signature.feature +++ b/tests/integration/features/account/signature.feature @@ -14,8 +14,8 @@ Feature: account/signature Scenario: Create root certificate with CFSSL engine using API Given as user "admin" - And run the command "config:app:set libresign certificate_engine --value cfssl" - And run the command "libresign:install --cfssl" + And run the command "config:app:set libresign certificate_engine --value cfssl" with result code 0 + And run the command "libresign:install --cfssl" with result code 0 And sending "post" to ocs "/apps/libresign/api/v1/admin/certificate/cfssl" | rootCert | {"commonName":"Common Name","names":{"C":{"id":"C","value":"BR"},"ST":{"id":"ST","value":"State of Company"},"L":{"id":"L","value":"City name"},"O":{"id":"O","value":"Organization"},"OU":{"id":"OU","value":"Organizational Unit"}}} | And the response should have a status code 200 @@ -31,9 +31,9 @@ Feature: account/signature Given user "signer1" exists And set the email of user "signer1" to "signer@domain.test" And as user "signer1" - And run the command "config:app:set libresign certificate_engine --value cfssl" - And run the command "libresign:install --cfssl" - And run the command "libresign:configure:cfssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" + And run the command "config:app:set libresign certificate_engine --value cfssl" with result code 0 + And run the command "libresign:install --cfssl" with result code 0 + And run the command "libresign:configure:cfssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" with result code 0 And sending "post" to ocs "/apps/libresign/api/v1/account/signature" | signPassword | password | And the response should have a status code 200 @@ -56,7 +56,7 @@ Feature: account/signature Given user "signer1" exists And set the email of user "signer1" to "signer@domain.test" And as user "signer1" - And run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" + And run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" with result code 0 And sending "post" to ocs "/apps/libresign/api/v1/account/signature" | signPassword | password | And the response should have a status code 200 @@ -76,7 +76,7 @@ Feature: account/signature | (jq).extensions | (jq).subjectKeyIdentifier != "" | Scenario: Upload PFX file with error - Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" + Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" with result code 0 And user "signer1" exists And as user "signer1" When sending "post" to ocs "/apps/libresign/api/v1/account/pfx" @@ -86,7 +86,7 @@ Feature: account/signature | message | No certificate file provided | Scenario: Change pfx password with success - Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" + Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" with result code 0 And user "signer1" exists And as user "signer1" And sending "post" to ocs "/apps/libresign/api/v1/account/signature" @@ -108,7 +108,7 @@ Feature: account/signature | message | New password to sign documents has been created | Scenario: Delete pfx password with success - Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" + Given run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name" with result code 0 And user "signer1" exists And as user "signer1" And sending "post" to ocs "/apps/libresign/api/v1/account/signature" diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 986b6a003d..d38eb4e3b1 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -36,9 +36,9 @@ public static function BeforeScenario(): void { } /** - * @When /^run the command "(?P(?:[^"]|\\")*)"$/ + * @When /^run the command "(?P(?:[^"]|\\")*)"$/ with result code 0 */ - public static function runCommand($command): void { + public static function runCommand(string $command): array { $console = realpath(__DIR__ . '/../../../../../../console.php'); $owner = posix_getpwuid(fileowner($console)); $fullCommand = 'php ' . $console . ' ' . $command; @@ -46,7 +46,19 @@ public static function runCommand($command): void { $fullCommand = 'runuser -u ' . $owner['name'] . ' -- ' . $fullCommand; } $fullCommand .= ' 2>&1'; - exec($fullCommand, $output); + exec($fullCommand, $output, $resultCode); + return [ + 'output' => $output, + 'resultCode' => $resultCode, + ]; + } + + /** + * @When /^run the command "(?P(?:[^"]|\\")*)" with result code (\d+)$/ with result code 0 + */ + public static function runCommandWithResultCode(string $command, int $resultCode = 0): void { + $return = self::runCommand($command); + Assert::assertEquals($resultCode, $return['resultCode']); } public function setOpenedEmailStorage(OpenedEmailStorage $storage): void { diff --git a/tests/integration/features/identify-account/search.feature b/tests/integration/features/identify-account/search.feature index 06bde6b01b..6513e9550b 100644 --- a/tests/integration/features/identify-account/search.feature +++ b/tests/integration/features/identify-account/search.feature @@ -33,9 +33,9 @@ Feature: search Given as user "admin" And sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods" | value | (string)[{"name":"email","enabled":true}] | - And run the command "group:add request_signature" - And run the command "group:adduser request_signature search-signer1" - And run the command "config:app:set libresign groups_request_sign --type=array --value=[\"request_signature\"]" + And run the command "group:add request_signature" with result code 0 + And run the command "group:adduser request_signature search-signer1" with result code 0 + And run the command "config:app:set libresign groups_request_sign --type=array --value=[\"request_signature\"]" with result code 0 Given as user "search-signer1" And set the email of user "search-signer1" to "my@email.tld" And set the display name of user "search-signer1" to "My Name" @@ -44,8 +44,8 @@ Feature: search And the response should be a JSON array with the following mandatory values | key | value | | ocs | {"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":[]} | - And run the command "group:delete request_signature" - And run the command "config:app:delete libresign groups_request_sign" + And run the command "group:delete request_signature" with result code 0 + And run the command "config:app:delete libresign groups_request_sign" with result code 0 And set the display name of user "search-signer1" to "search-signer1-displayname" Scenario: Search account by herself with permission to identify by account diff --git a/tests/integration/features/page/index.feature b/tests/integration/features/page/index.feature index 4adde26695..e12fe2f521 100644 --- a/tests/integration/features/page/index.feature +++ b/tests/integration/features/page/index.feature @@ -1,6 +1,6 @@ Feature: page/sign_identify_default Background: Make setup ok - Given run the command "config:app:set libresign authkey --value dummy" + Given run the command "config:app:set libresign authkey --value dummy" with result code 0 Scenario: Open sign file with all data valid Given as user "admin" diff --git a/tests/integration/features/page/sign_identify_account.feature b/tests/integration/features/page/sign_identify_account.feature index cb3b1ac044..6fd4efeacc 100644 --- a/tests/integration/features/page/sign_identify_account.feature +++ b/tests/integration/features/page/sign_identify_account.feature @@ -1,6 +1,6 @@ Feature: page/sign_identify_account Background: Make setup ok - Given run the command "config:app:set libresign authkey --value dummy" + Given run the command "config:app:set libresign authkey --value dummy" with result code 0 Scenario: Open sign file with invalid account data Given user "signer1" exists diff --git a/tests/integration/features/page/validate.feature b/tests/integration/features/page/validate.feature index f6301ba380..744c9a09fb 100644 --- a/tests/integration/features/page/validate.feature +++ b/tests/integration/features/page/validate.feature @@ -1,6 +1,6 @@ Feature: page/validate Background: Make setup ok - Given run the command "config:app:set libresign authkey --value dummy" + Given run the command "config:app:set libresign authkey --value dummy" with result code 0 Scenario: Unauthenticated user can see sign page Given as user "admin" diff --git a/tests/integration/features/sign/request.feature b/tests/integration/features/sign/request.feature index 0656a6142c..29ab65abe2 100644 --- a/tests/integration/features/sign/request.feature +++ b/tests/integration/features/sign/request.feature @@ -2,7 +2,7 @@ Feature: request-signature Scenario: Get error when try to request to sign isn't manager Given user "signer1" exists And as user "signer1" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"base64":""} | | users | [{"identify":{"account":"signer1"}}] | @@ -15,7 +15,7 @@ Feature: request-signature Scenario: Get error when try to request to sign without file name Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"invalid":""} | | users | [{"identify":{"account":"signer1"}}] | @@ -28,7 +28,7 @@ Feature: request-signature Scenario: Request to sign with error using different authenticated account Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And set the email of user "signer1" to "signer1@domain.test" And reset notifications of user "signer1" And sending "post" to ocs "/apps/libresign/api/v1/request-signature" @@ -50,7 +50,7 @@ Feature: request-signature Scenario: Request to sign with error when the user is not authenticated Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And reset notifications of user "signer1" And my inbox is empty And sending "post" to ocs "/apps/libresign/api/v1/request-signature" @@ -71,7 +71,7 @@ Feature: request-signature Scenario: Request to sign with error when the authenticated user have an email different of signer Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And reset notifications of user "signer1" And set the email of user "signer1" to "signer1@domain.test" And my inbox is empty @@ -96,8 +96,8 @@ Feature: request-signature Scenario: Request to sign with error when the link was expired Given as user "admin" And my inbox is empty - And run the command "libresign:configure:openssl --cn test" - And run the command "config:app:set libresign maximum_validity --value 1" + And run the command "libresign:configure:openssl --cn test" with result code 0 + And run the command "config:app:set libresign maximum_validity --value 1" with result code 0 When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"url":"/apps/libresign/develop/pdf"} | | users | [{"identify":{"email":"signer2@domain.test"}}] | @@ -118,7 +118,7 @@ Feature: request-signature Scenario: Request to sign with success when is necessary to renew the link Given as user "admin" And my inbox is empty - And run the command "libresign:configure:openssl --cn test" + 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":"email","enabled":true,"mandatory":true,"can_create_account":false}] | And sending "post" to ocs "/apps/libresign/api/v1/request-signature" @@ -130,8 +130,8 @@ Feature: request-signature And I open the latest email to "signer2@domain.test" with subject "LibreSign: There is a file for you to sign" And I fetch the signer UUID from opened email And as user "" - And run the command "config:app:set libresign maximum_validity --value 300" - And run the command "config:app:set libresign renewal_interval --value 1" + And run the command "config:app:set libresign maximum_validity --value 300" with result code 0 + And run the command "config:app:set libresign renewal_interval --value 1" with result code 0 Given wait for 2 second When sending "get" to "/apps/libresign/p/sign/" Then the response should have a status code 422 @@ -152,7 +152,7 @@ Feature: request-signature # setting the renewal interval to 2 and making 3 requests, one by second, # the 3rd don't will fail because on each valid request, the renewal # interval is renewed. - And run the command "config:app:set libresign renewal_interval --value 2" + And run the command "config:app:set libresign renewal_interval --value 2" with result code 0 Given wait for 1 second When sending "get" to "/apps/libresign/p/sign/" And the response should have a status code 200 @@ -182,7 +182,7 @@ Feature: request-signature Scenario: Request to sign with success using account as identifier Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And set the email of user "signer1" to "signer1@domain.test" And reset notifications of user "signer1" And my inbox is empty @@ -203,7 +203,7 @@ Feature: request-signature Scenario: Request to sign with error using account as identifier with invalid email Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"url":"/apps/libresign/develop/pdf"} | | users | [{"identify":{"account":"invaliddomain.test"}}] | @@ -215,7 +215,7 @@ Feature: request-signature Scenario: Request to sign with error using email as account identifier Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"url":"/apps/libresign/develop/pdf"} | | users | [{"identify":{"account":"signer3@domain.test"}}] | @@ -227,7 +227,7 @@ Feature: request-signature Scenario: Request to sign with success using email as identifier and URL as file Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And my inbox is empty When sending "post" to ocs "/apps/libresign/api/v1/request-signature" | file | {"url":"/apps/libresign/develop/pdf"} | @@ -240,7 +240,7 @@ Feature: request-signature Scenario: Request to sign with success using account as identifier and URL as file Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And set the email of user "signer1" to "signer1@domain.test" And reset notifications of user "signer1" And my inbox is empty @@ -258,7 +258,7 @@ Feature: request-signature Scenario: Request to sign with success using email as identifier Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And set the email of user "signer1" to "signer1@domain.test" And my inbox is empty When sending "post" to ocs "/apps/libresign/api/v1/request-signature" @@ -271,7 +271,7 @@ Feature: request-signature Scenario: Request to sign using email as identifier and when is necessary to use visible elements Given as user "admin" - And run the command "libresign:configure:openssl --cn test" + 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":"email","enabled":true,"mandatory":true,"can_create_account":false}] | And I send a file to be signed @@ -299,7 +299,7 @@ Feature: request-signature Scenario: Request to sign with success using multiple users Given as user "admin" And user "signer1" exists - And run the command "libresign:configure:openssl --cn test" + And run the command "libresign:configure:openssl --cn test" with result code 0 And set the email of user "signer1" to "signer1@domain.test" And my inbox is empty When sending "post" to ocs "/apps/libresign/api/v1/request-signature" @@ -316,7 +316,7 @@ Feature: request-signature And I open the latest email to "signer1@domain.test" with subject "LibreSign: There is a file for you to sign" Scenario: CRUD of identify methods - Given run the command "libresign:configure:openssl --cn test" + Given run the command "libresign:configure:openssl --cn test" with result code 0 And user "signer1" exists And as user "admin" When I send a file to be signed