[Pkg-owncloud-commits] [owncloud] 107/165: Adjust tests and statuscode

David Prévot taffit at moszumanska.debian.org
Thu Apr 23 04:06:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 9bc48451b939df58b7e7e90300c9c716c348027f
Author: Lukas Reschke <lukas at owncloud.com>
Date:   Thu Apr 16 10:48:25 2015 +0200

    Adjust tests and statuscode
---
 settings/controller/certificatecontroller.php        |  2 +-
 tests/lib/security/certificatemanager.php            | 20 +++++++++++++++-----
 .../controller/CertificateControllerTest.php         |  6 +++---
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/settings/controller/certificatecontroller.php b/settings/controller/certificatecontroller.php
index c8d05a5..d9026cd 100644
--- a/settings/controller/certificatecontroller.php
+++ b/settings/controller/certificatecontroller.php
@@ -76,7 +76,7 @@ class CertificateController extends Controller {
 				'issuerOrganization' => $certificate->getIssuerOrganization(),
 			]);
 		} catch (\Exception $e) {
-			return new DataResponse('An error occurred.', Http::STATUS_INTERNAL_SERVER_ERROR);
+			return new DataResponse('An error occurred.', Http::STATUS_UNPROCESSABLE_ENTITY);
 		}
 	}
 
diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php
index aea1fb7..fab1c20 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 363175c..b698119 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());
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list