summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-04-16 10:48:25 +0200
committerLukas Reschke <lukas@owncloud.com>2015-04-20 13:00:02 +0200
commit9bc48451b939df58b7e7e90300c9c716c348027f (patch)
treeca5e8858f60e8f479a4bb299b26d867bbfda7ab6 /tests
parent89353695648eb686e6fffd49f86a6d014121f551 (diff)
downloadnextcloud-server-9bc48451b939df58b7e7e90300c9c716c348027f.tar.gz
nextcloud-server-9bc48451b939df58b7e7e90300c9c716c348027f.zip
Adjust tests and statuscode
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/security/certificatemanager.php20
-rw-r--r--tests/settings/controller/CertificateControllerTest.php6
2 files changed, 18 insertions, 8 deletions
diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php
index aea1fb71bc5..fab1c208443 100644
--- a/tests/lib/security/certificatemanager.php
+++ b/tests/lib/security/certificatemanager.php
@@ -14,8 +14,6 @@ class CertificateManagerTest extends \Test\TestCase {
private $certificateManager;
/** @var String */
private $username;
- /** @var \OC\User\User */
- private $user;
protected function setUp() {
parent::setUp();
@@ -68,12 +66,24 @@ class CertificateManagerTest extends \Test\TestCase {
}
/**
+ * @return array
+ */
+ public function dangerousFileProvider() {
+ return [
+ ['.htaccess'],
+ ['../../foo.txt'],
+ ['..\..\foo.txt'],
+ ];
+ }
+
+ /**
* @expectedException \Exception
* @expectedExceptionMessage Filename is not valid
+ * @dataProvider dangerousFileProvider
+ * @param string $filename
*/
- function testAddDangerousFile() {
- $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), '.htaccess');
- $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), '../../foo.txt');
+ function testAddDangerousFile($filename) {
+ $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), $filename);
}
function testRemoveDangerousFile() {
diff --git a/tests/settings/controller/CertificateControllerTest.php b/tests/settings/controller/CertificateControllerTest.php
index 363175cca41..b6981195034 100644
--- a/tests/settings/controller/CertificateControllerTest.php
+++ b/tests/settings/controller/CertificateControllerTest.php
@@ -141,7 +141,7 @@ class CertificateControllerTest extends \Test\TestCase {
$this->assertEquals($expected, $this->certificateController->addPersonalRootCertificate());
}
- public function testAddPersonalRootCertificateInValidCertificate() {
+ public function testAddPersonalRootCertificateInvalidCertificate() {
$uploadedFile = [
'tmp_name' => __DIR__ . '/../../data/certificates/badCertificate.crt',
'name' => 'badCertificate.crt',
@@ -155,10 +155,10 @@ class CertificateControllerTest extends \Test\TestCase {
$this->certificateManager
->expects($this->once())
->method('addCertificate')
- ->with(file_get_contents($uploadedFile['tmp_name'], 'goodCertificate.crt'))
+ ->with(file_get_contents($uploadedFile['tmp_name'], 'badCertificate.crt'))
->will($this->throwException(new \Exception()));
- $expected = new DataResponse('An error occurred.', Http::STATUS_INTERNAL_SERVER_ERROR);
+ $expected = new DataResponse('An error occurred.', Http::STATUS_UNPROCESSABLE_ENTITY);
$this->assertEquals($expected, $this->certificateController->addPersonalRootCertificate());
}