mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
feat(encryption): Add integration tests for occ commands
Add tests for encrypt-all and decrypt-all. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
2e9964c6fc
commit
a831f2fa8b
2 changed files with 62 additions and 1 deletions
|
|
@ -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 "([^"]*)"$/
|
||||
*/
|
||||
|
|
|
|||
42
build/integration/files_features/encryption.feature
Normal file
42
build/integration/files_features/encryption.feature
Normal file
|
|
@ -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"
|
||||
Loading…
Reference in a new issue