diff --git a/build/integration/features/bootstrap/CommandLine.php b/build/integration/features/bootstrap/CommandLine.php index 118da8a82cf..105874ad9e5 100644 --- a/build/integration/features/bootstrap/CommandLine.php +++ b/build/integration/features/bootstrap/CommandLine.php @@ -26,7 +26,7 @@ trait CommandLine { * @param []string $args OCC command, the part behind "occ". For example: "files:transfer-ownership" * @return int exit code */ - public function runOcc($args = []) { + public function runOcc($args = [], string $inputString = '') { $args = array_map(function ($arg) { return escapeshellarg($arg); }, $args); @@ -39,6 +39,10 @@ trait CommandLine { 2 => ['pipe', 'w'], ]; $process = proc_open('php console.php ' . $args, $descriptor, $pipes, $this->ocPath); + if ($inputString !== '') { + fwrite($pipes[0], $inputString . "\n"); + fclose($pipes[0]); + } $this->lastStdOut = stream_get_contents($pipes[1]); $this->lastStdErr = stream_get_contents($pipes[2]); $this->lastCode = proc_close($process); @@ -58,6 +62,14 @@ trait CommandLine { $this->runOcc($args); } + /** + * @Given /^invoking occ with "([^"]*)" with input "([^"]+)"$/ + */ + public function invokingTheCommandWith($cmd, $inputString) { + $args = explode(' ', $cmd); + $this->runOcc($args, $inputString); + } + /** * Find exception texts in stderr */ @@ -126,6 +138,13 @@ trait CommandLine { Assert::assertStringContainsString($text, $this->lastStdOut, 'The command did not output the expected text on stdout'); } + /** + * @Then /^the command output does not contain the text "([^"]*)"$/ + */ + public function theCommandOutputDoesNotContainTheText($text) { + Assert::assertStringNotContainsString($text, $this->lastStdOut, 'The command did output the not expected text on stdout'); + } + /** * @Then /^the command error output contains the text "([^"]*)"$/ */ diff --git a/build/integration/files_features/encryption.feature b/build/integration/files_features/encryption.feature new file mode 100644 index 00000000000..d961f152671 --- /dev/null +++ b/build/integration/files_features/encryption.feature @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +Feature: encryption + + Scenario: encryption tests + # Setup encryption + Given using new dav path + And user "user0" exists + And User "user0" uploads file with content "BLABLABLA" to "/non-encrypted.txt" + And invoking occ with "app:enable encryption" + And the command was successful + And invoking occ with "encryption:enable" + And the command was successful + And As an "user0" + And User "user0" uploads file with content "BLABLABLA" to "/encrypted.txt" + # Check both encrypted and non-encrypted files can be read + When Downloading file "/encrypted.txt" with range "bytes=0-8" + Then Downloaded content should be "BLABLABLA" + When Downloading file "/non-encrypted.txt" with range "bytes=0-8" + Then Downloaded content should be "BLABLABLA" + When invoking occ with "info:file user0/files/encrypted.txt" + And the command was successful + Then the command output contains the text "server-side encrypted: yes" + When invoking occ with "info:file user0/files/non-encrypted.txt" + And the command was successful + Then the command output does not contain the text "server-side encrypted: yes" + # Run encryption:encrypt-all and checks that non-encrypted file gets encrypted + When invoking occ with "encryption:encrypt-all" with input "y" + And the command was successful + And invoking occ with "info:file user0/files/non-encrypted.txt" + And the command was successful + Then the command output contains the text "server-side encrypted: yes" + And Downloading file "/non-encrypted.txt" with range "bytes=0-8" + And Downloaded content should be "BLABLABLA" + # Run encryption:decrypt-all and checks that files gets decrypted + When invoking occ with "encryption:decrypt-all" with input "y" + And the command was successful + And invoking occ with "info:file user0/files/non-encrypted.txt" + And the command was successful + Then the command output does not contain the text "server-side encrypted: yes" + And Downloading file "/non-encrypted.txt" with range "bytes=0-8" + And Downloaded content should be "BLABLABLA"