Skip to content

Commit

Permalink
Merge pull request #35435 from owncloud/stable10-form-from
Browse files Browse the repository at this point in the history
[stable10] cli test for security certificates
  • Loading branch information
individual-it authored Jun 5, 2019
2 parents e5f6ef7 + 56b8f6f commit d95c0ab
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/acceptance/features/bootstrap/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public function findLines($input, $text) {
$results[] = $line;
}
}

return $results;
}

Expand Down
54 changes: 54 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class OccContext implements Context {
*/
private $featureContext;

/**
*
* @var ImportedCertificates
*/
private $importedCertificates = [];

/**
*
* @var RemovedCertificates
*/
private $removedCertificates = [];

/**
* @var string lastDeletedJobId
*/
Expand All @@ -55,6 +67,33 @@ public function invokingTheCommand($cmd) {
$this->featureContext->runOcc([$cmd]);
}

/**
* @When the administrator imports security certificate from the path :path
* @Given the administrator has imported security certificate from the path :path
*
* @param string $path
*
* @return void
*/
public function theAdministratorImportsSecurityCertificateFromThePath($path) {
$this->invokingTheCommand("security:certificates:import " . $path);
$pathComponents = \explode("/", $path);
$certificate = \end($pathComponents);
\array_push($this->importedCertificates, $certificate);
}

/**
* @When the administrator removes the security certificate :certificate
*
* @param string $certificate
*
* @return void
*/
public function theAdministratorRemovesTheSecurityCertificate($certificate) {
$this->invokingTheCommand("security:certificates:remove " . $certificate);
\array_push($this->removedCertificates, $certificate);
}

/**
* @When /^the administrator invokes occ command "([^"]*)" with environment variable "([^"]*)" set to "([^"]*)"$/
* @Given /^the administrator has invoked occ command "([^"]*)" with environment variable "([^"]*)" set to "([^"]*)"$/
Expand Down Expand Up @@ -846,6 +885,21 @@ public function theSystemConfigKeyFromLastCommandOutputShouldContainValue(
);
}

/**
* This will run after EVERY scenario.
* It will set the properties for this object.
*
* @AfterScenario
*
* @return void
*/
public function removeImportedCertificates() {
$remainingCertificates = \array_diff($this->importedCertificates, $this->removedCertificates);
foreach ($remainingCertificates as $certificate) {
$this->invokingTheCommand("security:certificates:remove " . $certificate);
$this->theCommandShouldHaveBeenSuccessful();
}
}
/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
43 changes: 43 additions & 0 deletions tests/acceptance/features/cliMain/securityCertificates.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@cli
Feature: security certificates
As an admin
I want to be able to manage the ownCloud security certificates
So that I can ensure the proper encrpytion mechanism

Scenario: Import a security certificate
When the administrator imports security certificate from the path "tests/data/certificates/goodCertificate.crt"
Then the command should have been successful
When the administrator invokes occ command "security:certificates"
Then the command should have been successful
And the command output table should contain the following text:
| table_column |
| goodCertificate.crt |

Scenario: List security certificates when multiple certificates are imported
Given the administrator has imported security certificate from the path "tests/data/certificates/goodCertificate.crt"
And the administrator has imported security certificate from the path "tests/data/certificates/badCertificate.crt"
When the administrator invokes occ command "security:certificates"
And the command output table should contain the following text:
| table_column |
| goodCertificate.crt |
| badCertificate.crt |

Scenario: Remove a security certificate
Given the administrator has imported security certificate from the path "tests/data/certificates/goodCertificate.crt"
And the administrator has imported security certificate from the path "tests/data/certificates/badCertificate.crt"
When the administrator removes the security certificate "goodCertificate.crt"
Then the command should have been successful
When the administrator invokes occ command "security:certificates"
And the command output table should contain the following text:
| table_column |
| badCertificate.crt |

@issue-35364
Scenario: Remove a security certificate that is not installed
When the administrator removes the security certificate "someCertificate.crt"
Then the command should have been successful
# Then the command should not have been successful

Scenario: Import random file as certificate
When the administrator imports security certificate from the path "tests/data/lorem.txt"
Then the command error output should contain the text "Certificate could not get parsed."

0 comments on commit d95c0ab

Please sign in to comment.