Skip to content

Commit

Permalink
Added cli acceptance tests for encrpytion command
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Sep 23, 2021
1 parent 76ae2be commit 6de850b
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ config = {
"federatedServerNeeded": True,
"federatedServerVersions": ["git", "latest", "10.7.0"],
},
"cliEncryption": {
"suites": [
"cliEncryption",
],
"extraApps": {
"encryption": "composer install",
},
"extraCommandsBeforeTestRun": [
"mkdir data/owncloud-keys",
"chown -R www-data data/owncloud-keys",
"chmod -R 0770 data/owncloud-keys",
],
},
"webUI": {
"suites": {
"webUIAddUsers": "",
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,16 @@ default:
- FeatureContext: *common_feature_context_params
- OccContext:

cliEncryption:
paths:
- '%paths.base%/../features/cliEncryption'
context: *common_ldap_suite_context
contexts:
- FeatureContext: *common_feature_context_params
- OccContext:
- WebDavPropertiesContext:
- EncryptionContext:

cliExternalStorage:
paths:
- '%paths.base%/../features/cliExternalStorage'
Expand Down
21 changes: 21 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,16 @@ public function theAdministratorHasInvokedOccCommand($cmd) {
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @Given the administrator has selected master key encryption type using the occ command
*
* @return void
* @throws Exception
*/
public function theAdministratorHasSelectedMasterKeyEncryptionTypeUsingTheOccCommand():void {
$this->featureContext->runOcc(['encryption:select-encryption-type', "masterkey --yes"]);
}

/**
* @When the administrator imports security certificate from file :filename in temporary storage on the system under test
*
Expand Down Expand Up @@ -711,6 +721,17 @@ public function theAdministratorRunsUpgradeRoutinesOnLocalServerUsingTheOccComma
}
}

/**
* @When the administrator runs encryption decrypt all using the occ command
*
* @return void
*/
public function theAdministratorRunsEncryptionDecryptAllUsingTheOccCommand() {
\system("echo 'admin' | sudo -S www-data ./occ encryption:decrypt-all -c yes", $status);
\var_dump($status);
\system("echo 'admin' | sudo -S www-data ./occ maintenance:mode --off");
}

/**
* @return bool
*/
Expand Down
65 changes: 65 additions & 0 deletions tests/acceptance/features/cliEncryption/encryption.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@cli
Feature: encryption command
As an admin
I want to encrypt-decrypt my data
So that users' files 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"
Then the command should have been successful
And the command output should contain the text "enabled: true"
And the command output should contain the text "defaultModule: OC_DEFAULT_MODULE"


Scenario: list available encryption modules
When the administrator invokes occ command "encryption:list-modules"
Then the command should have been successful
And the command output should contain the text "OC_DEFAULT_MODULE: Default encryption module [default*]"


Scenario: show current key storage root
When the administrator invokes occ command "encryption:show-key-storage-root"
Then the command should have been successful
And the command output should contain the text "Current key storage root: default storage location (data/)"


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
When the administrator invokes occ command "encryption:show-key-storage-root"
And the command output should contain the text "Current key storage root: owncloud-keys"

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
Then file "fileToUpload.txt" of user "Alice" should be encrypted


Scenario: downloaded content of an uploaded should not be encrypted
Given user "brand-new-user" has been created with default attributes and without skeleton files
When user "brand-new-user" uploads file with content "uploaded content" to "fileToUpload.txt" using the WebDAV API
And the content of file "fileToUpload.txt" for user "brand-new-user" should be "uploaded content"


Scenario: should not be possible to disable encryption without decrypting encrypted files
When the administrator invokes occ command "encryption:disable"
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."

@skipOnOcV10 @issue-encryption-303
Scenario: should be possible to disable encryption after decrypting all encrypted files
When the administrator runs encryption decrypt all using the occ command
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 is already 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"


0 comments on commit 6de850b

Please sign in to comment.