Skip to content

Commit

Permalink
Updated occ commands with maintenance commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Oct 21, 2021
1 parent 6d21642 commit 1bcb8e4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ config = {
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": [
"php occ maintenance:singleuser --on",
"php occ encryption:enable",
"php occ encryption:select-encryption-type masterkey --yes",
"php occ encryption:encrypt-all --yes",
"php occ encryption:status",
"php occ maintenance:singleuser --off",
],
}],
"extraCommandsBeforeTestRun": [
Expand Down
16 changes: 12 additions & 4 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,19 +756,27 @@ public function theAdministratorHasDecryptedEverything():void {
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @When the administrator disables encryption using the occ command
*
* @return void
* @throws Exception
*/
public function theAdministratorDisablesEncryptionUsingTheOccCommand():void {
$this->invokingTheCommand("encryption:disable");
}

/**
* @When the administrator runs encryption decrypt all using the occ command
*
* @return void
*/
public function theAdministratorRunsEncryptionDecryptAllUsingTheOccCommand():void {
\system("./occ maintenance:singleuser --on");
\system("./occ encryption:decrypt-all -c yes", $status);

$this->featureContext->setResultOfOccCommand(["code" => $status, "stdOut" => null, "stdErr" => null]);
if ($status !== 0) {
// if the above command fails make sure to turn off maintenance mode
\system("./occ maintenance:mode --off");
}
\system("./occ maintenance:singleuser --off");
}

/**
Expand Down
32 changes: 14 additions & 18 deletions tests/acceptance/features/cliEncryption/encryption.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ Feature: encryption command
I want to encrypt-decrypt my data
So that users' resources are protected

# Background:
# Given the administrator has invoked occ command "encryption:enable"
# And the administrator has selected master key encryption type using the occ command


Scenario: view current encryption status
When the administrator invokes occ command "encryption:status"
Expand All @@ -28,6 +24,18 @@ Feature: encryption command
And the command output should contain the text "Current key storage root: default storage location (data/)"


Scenario: it should be possible to disable encryption after decrypting all of the encrypted files
Given the administrator has uploaded file with content "uploaded content" to "/lorem.txt"
And the administrator has decrypted everything
When the administrator disables encryption using the occ command
Then the command should have been successful
And the command output should contain the text "Cleaned up config"
And the command output should contain the text "Encryption disabled"
When the administrator invokes occ command "encryption:status"
Then the command should have been successful
And the command output should contain the text "enabled: false"


Scenario: data file contents should be encrypted
Given user "Alice" has been created with default attributes and without skeleton files
When user "Alice" uploads file with content "file to upload" to "/fileToUpload.txt" using the WebDAV API
Expand All @@ -42,23 +50,11 @@ Feature: encryption command

Scenario: it should not be possible to disable encryption without decrypting encrypted uploaded files
Given the administrator has uploaded file with content "uploaded content" to "/lorem.txt"
When the administrator invokes occ command "encryption:disable"
When the administrator disables encryption using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text "The system still have encrypted files. Please decrypt them all before disabling encryption."


Scenario: it should be possible to disable encryption after decrypting all of the encrypted files
Given the administrator has uploaded file with content "uploaded content" to "/lorem.txt"
And the administrator has decrypted everything
And the administrator invokes occ command "encryption:disable"
Then the command should have been successful
And the command output should contain the text "Cleaned up config"
And the command output should contain the text "Encryption disabled"
When the administrator invokes occ command "encryption:status"
Then the command should have been successful
And the command output should contain the text "enabled: false"


Scenario: move encryption keys to a different folder
When the administrator invokes occ command "encryption:change-key-storage-root owncloud-keys"
Then the command should have been successful
Expand All @@ -70,6 +66,6 @@ Feature: encryption command
@skipOnOcV10 @issue-encryption-303
Scenario: it should not be possible to disable encryption even after decrypting all encrypted files if keys root has been changed
Given the administrator has decrypted everything
When the administrator invokes occ command "encryption:disable"
When the administrator disables encryption using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text "The system still have encrypted files. Please decrypt them all before disabling encryption"

0 comments on commit 1bcb8e4

Please sign in to comment.