diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2016-06-09 17:41:57 +0200 |
---|---|---|
committer | blizzz <blizzz@arthur-schiwon.de> | 2016-06-09 17:41:57 +0200 |
commit | 51fd2602a77d8d885c53d24ebb8f72be62dc52ce (patch) | |
tree | 2c38e740669ab2fa6ab50615187d01b9d6dc00d1 /tests | |
parent | b688aac402cf9d7ee08252077d37ea1c43b22f4a (diff) | |
download | nextcloud-server-51fd2602a77d8d885c53d24ebb8f72be62dc52ce.tar.gz nextcloud-server-51fd2602a77d8d885c53d24ebb8f72be62dc52ce.zip |
Revert "Downstream 2016-06-08"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/TokenControllerTest.php | 40 | ||||
-rw-r--r-- | tests/Core/Controller/TwoFactorChallengeControllerTest.php | 21 | ||||
-rw-r--r-- | tests/lib/AllConfigTest.php | 19 | ||||
-rw-r--r-- | tests/lib/Encryption/DecryptAllTest.php | 35 | ||||
-rw-r--r-- | tests/lib/Files/Storage/LocalTest.php | 31 | ||||
-rw-r--r-- | tests/lib/Files/ViewTest.php | 51 |
6 files changed, 24 insertions, 173 deletions
diff --git a/tests/Core/Controller/TokenControllerTest.php b/tests/Core/Controller/TokenControllerTest.php index b6b54b14fad..386140a8a4f 100644 --- a/tests/Core/Controller/TokenControllerTest.php +++ b/tests/Core/Controller/TokenControllerTest.php @@ -23,9 +23,8 @@ namespace Tests\Core\Controller; use OC\AppFramework\Http; -use OC\Authentication\Token\IToken; use OC\Core\Controller\TokenController; -use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\Response; use Test\TestCase; class TokenControllerTest extends TestCase { @@ -35,7 +34,6 @@ class TokenControllerTest extends TestCase { private $request; private $userManager; private $tokenProvider; - private $twoFactorAuthManager; private $secureRandom; protected function setUp() { @@ -45,17 +43,17 @@ class TokenControllerTest extends TestCase { $this->userManager = $this->getMockBuilder('\OC\User\Manager') ->disableOriginalConstructor() ->getMock(); - $this->tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider'); - $this->twoFactorAuthManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager') + $this->tokenProvider = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider') ->disableOriginalConstructor() ->getMock(); $this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom'); - $this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider, $this->twoFactorAuthManager, $this->secureRandom); + $this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider, + $this->secureRandom); } public function testWithoutCredentials() { - $expected = new JSONResponse(); + $expected = new Response(); $expected->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY); $actual = $this->tokenController->generateToken(null, null); @@ -68,7 +66,7 @@ class TokenControllerTest extends TestCase { ->method('checkPassword') ->with('john', 'passme') ->will($this->returnValue(false)); - $expected = new JSONResponse(); + $expected = new Response(); $expected->setStatus(Http::STATUS_UNAUTHORIZED); $actual = $this->tokenController->generateToken('john', 'passme'); @@ -85,17 +83,13 @@ class TokenControllerTest extends TestCase { $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('john')); - $this->twoFactorAuthManager->expects($this->once()) - ->method('isTwoFactorAuthenticated') - ->with($user) - ->will($this->returnValue(false)); $this->secureRandom->expects($this->once()) ->method('generate') ->with(128) ->will($this->returnValue('verysecurerandomtoken')); $this->tokenProvider->expects($this->once()) ->method('generateToken') - ->with('verysecurerandomtoken', 'john', 'john', '123456', 'unknown client', IToken::PERMANENT_TOKEN); + ->with('verysecurerandomtoken', 'john', 'john', '123456', 'unknown client', \OC\Authentication\Token\IToken::PERMANENT_TOKEN); $expected = [ 'token' => 'verysecurerandomtoken' ]; @@ -105,24 +99,4 @@ class TokenControllerTest extends TestCase { $this->assertEquals($expected, $actual); } - public function testWithValidCredentialsBut2faEnabled() { - $user = $this->getMock('\OCP\IUser'); - $this->userManager->expects($this->once()) - ->method('checkPassword') - ->with('john', '123456') - ->will($this->returnValue($user)); - $this->twoFactorAuthManager->expects($this->once()) - ->method('isTwoFactorAuthenticated') - ->with($user) - ->will($this->returnValue(true)); - $this->secureRandom->expects($this->never()) - ->method('generate'); - $expected = new JSONResponse(); - $expected->setStatus(Http::STATUS_UNAUTHORIZED); - - $actual = $this->tokenController->generateToken('john', '123456'); - - $this->assertEquals($expected, $actual); - } - } diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php index 08d8dd1452c..2da6dcd52ac 100644 --- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php +++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php @@ -33,7 +33,7 @@ class TwoFactorChallengeControllerTest extends TestCase { private $session; private $urlGenerator; - /** @var TwoFactorChallengeController|\PHPUnit_Framework_MockObject_MockObject */ + /** TwoFactorChallengeController */ private $controller; protected function setUp() { @@ -47,20 +47,9 @@ class TwoFactorChallengeControllerTest extends TestCase { $this->session = $this->getMock('\OCP\ISession'); $this->urlGenerator = $this->getMock('\OCP\IURLGenerator'); - $this->controller = $this->getMockBuilder('OC\Core\Controller\TwoFactorChallengeController') - ->setConstructorArgs([ - 'core', - $this->request, - $this->twoFactorManager, - $this->userSession, - $this->session, - $this->urlGenerator, - ]) - ->setMethods(['getLogoutAttribute']) - ->getMock(); - $this->controller->expects($this->any()) - ->method('getLogoutAttribute') - ->willReturn('logoutAttribute'); + $this->controller = new TwoFactorChallengeController( + 'core', $this->request, $this->twoFactorManager, $this->userSession, $this->session, $this->urlGenerator + ); } public function testSelectChallenge() { @@ -81,7 +70,6 @@ class TwoFactorChallengeControllerTest extends TestCase { $expected = new \OCP\AppFramework\Http\TemplateResponse('core', 'twofactorselectchallenge', [ 'providers' => $providers, 'redirect_url' => '/some/url', - 'logout_attribute' => 'logoutAttribute', ], 'guest'); $this->assertEquals($expected, $this->controller->selectChallenge('/some/url')); @@ -122,7 +110,6 @@ class TwoFactorChallengeControllerTest extends TestCase { $expected = new \OCP\AppFramework\Http\TemplateResponse('core', 'twofactorshowchallenge', [ 'error' => true, 'provider' => $provider, - 'logout_attribute' => 'logoutAttribute', 'template' => '<html/>', ], 'guest'); diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index 3d0a9cb0827..4f8b0658b80 100644 --- a/tests/lib/AllConfigTest.php +++ b/tests/lib/AllConfigTest.php @@ -123,25 +123,6 @@ class AllConfigTest extends \Test\TestCase { $config->deleteUserValue('userPreCond', 'appPreCond', 'keyPreCond'); } - public function dataSetUserValueUnexpectedValue() { - return [ - [true], - [false], - [null], - [new \stdClass()], - ]; - } - - /** - * @dataProvider dataSetUserValueUnexpectedValue - * @param mixed $value - * @expectedException \UnexpectedValueException - */ - public function testSetUserValueUnexpectedValue($value) { - $config = $this->getConfig(); - $config->setUserValue('userSetBool', 'appSetBool', 'keySetBool', $value); - } - /** * @expectedException \OCP\PreConditionNotMetException */ diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index d7cf2fb7baf..ffcbbc74a99 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -86,25 +86,13 @@ class DecryptAllTest extends TestCase { $this->invokePrivate($this->instance, 'output', [$this->outputInterface]); } - public function dataDecryptAll() { - return [ - [true, 'user1', true], - [false, 'user1', true], - [true, '0', true], - [false, '0', true], - [true, '', false], - ]; - } - /** - * @dataProvider dataDecryptAll + * @dataProvider dataTrueFalse * @param bool $prepareResult - * @param string $user - * @param bool $userExistsChecked */ - public function testDecryptAll($prepareResult, $user, $userExistsChecked) { + public function testDecryptAll($prepareResult, $user) { - if ($userExistsChecked) { + if (!empty($user)) { $this->userManager->expects($this->once())->method('userExists')->willReturn(true); } else { $this->userManager->expects($this->never())->method('userExists'); @@ -137,6 +125,15 @@ class DecryptAllTest extends TestCase { $instance->decryptAll($this->inputInterface, $this->outputInterface, $user); } + public function dataTrueFalse() { + return [ + [true, 'user1'], + [false, 'user1'], + [true, ''], + [true, null] + ]; + } + /** * test decrypt all call with a user who doesn't exists */ @@ -150,16 +147,8 @@ class DecryptAllTest extends TestCase { ); } - public function dataTrueFalse() { - return [ - [true], - [false], - ]; - } - /** * @dataProvider dataTrueFalse - * @param bool $success */ public function testPrepareEncryptionModules($success) { diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index cca4d6a6676..7b8ae6a24b2 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -84,36 +84,5 @@ class LocalTest extends Storage { public function testInvalidArgumentsNoArray() { new \OC\Files\Storage\Local(null); } - - /** - * @expectedException \OCP\Files\ForbiddenException - */ - public function testDisallowSymlinksOutsideDatadir() { - $subDir1 = $this->tmpDir . 'sub1'; - $subDir2 = $this->tmpDir . 'sub2'; - $sym = $this->tmpDir . 'sub1/sym'; - mkdir($subDir1); - mkdir($subDir2); - - symlink($subDir2, $sym); - - $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]); - - $storage->file_put_contents('sym/foo', 'bar'); - } - - public function testDisallowSymlinksInsideDatadir() { - $subDir1 = $this->tmpDir . 'sub1'; - $subDir2 = $this->tmpDir . 'sub1/sub2'; - $sym = $this->tmpDir . 'sub1/sym'; - mkdir($subDir1); - mkdir($subDir2); - - symlink($subDir2, $sym); - - $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]); - - $storage->file_put_contents('sym/foo', 'bar'); - } } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 59b17b83958..2c27bb64a70 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -2417,7 +2417,7 @@ class ViewTest extends \Test\TestCase { $content = $view->getDirectoryContent('', $filter); - $files = array_map(function (FileInfo $info) { + $files = array_map(function(FileInfo $info) { return $info->getName(); }, $content); sort($files); @@ -2444,53 +2444,4 @@ class ViewTest extends \Test\TestCase { $data = $view->getFileInfo('.'); $this->assertEquals('', $data->getChecksum()); } - - public function testDeleteGhostFile() { - $storage = new Temporary(array()); - $scanner = $storage->getScanner(); - $cache = $storage->getCache(); - $storage->file_put_contents('foo.txt', 'bar'); - \OC\Files\Filesystem::mount($storage, array(), '/test/'); - $scanner->scan(''); - - $storage->unlink('foo.txt'); - - $this->assertTrue($cache->inCache('foo.txt')); - - $view = new \OC\Files\View('/test'); - $rootInfo = $view->getFileInfo(''); - $this->assertEquals(3, $rootInfo->getSize()); - $view->unlink('foo.txt'); - $newInfo = $view->getFileInfo(''); - - $this->assertFalse($cache->inCache('foo.txt')); - $this->assertNotEquals($rootInfo->getEtag(), $newInfo->getEtag()); - $this->assertEquals(0, $newInfo->getSize()); - } - - public function testDeleteGhostFolder() { - $storage = new Temporary(array()); - $scanner = $storage->getScanner(); - $cache = $storage->getCache(); - $storage->mkdir('foo'); - $storage->file_put_contents('foo/foo.txt', 'bar'); - \OC\Files\Filesystem::mount($storage, array(), '/test/'); - $scanner->scan(''); - - $storage->rmdir('foo'); - - $this->assertTrue($cache->inCache('foo')); - $this->assertTrue($cache->inCache('foo/foo.txt')); - - $view = new \OC\Files\View('/test'); - $rootInfo = $view->getFileInfo(''); - $this->assertEquals(3, $rootInfo->getSize()); - $view->rmdir('foo'); - $newInfo = $view->getFileInfo(''); - - $this->assertFalse($cache->inCache('foo')); - $this->assertFalse($cache->inCache('foo/foo.txt')); - $this->assertNotEquals($rootInfo->getEtag(), $newInfo->getEtag()); - $this->assertEquals(0, $newInfo->getSize()); - } } |