fixing unit test execution

This commit is contained in:
Thomas Müller 2015-04-02 10:26:40 +02:00
parent e507dc11a0
commit 4c899238e9
3 changed files with 5 additions and 47 deletions

View File

@ -192,7 +192,6 @@ class KeyManager {
* @param string $password * @param string $password
* @param array $keyPair * @param array $keyPair
* @return bool * @return bool
* @internal param string $uid
*/ */
public function setRecoveryKey($password, $keyPair) { public function setRecoveryKey($password, $keyPair) {
// Save Public Key // Save Public Key

View File

@ -14,18 +14,10 @@ use OCA\Encryption\KeyManager;
use Test\TestCase; use Test\TestCase;
class KeyManagerTest extends TestCase { class KeyManagerTest extends TestCase {
/**
* @var bool
*/
private static $trashbinState;
/** /**
* @var KeyManager * @var KeyManager
*/ */
private $instance; private $instance;
/**
* @var string
*/
private static $testUser = 'test-keyManager-user.dot';
/** /**
* @var string * @var string
*/ */
@ -55,27 +47,6 @@ class KeyManagerTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */ /** @var \PHPUnit_Framework_MockObject_MockObject */
private $configMock; private $configMock;
/**
*
*/
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
// Remember files_trashbin state
self::$trashbinState = \OC_App::isEnabled('files_trashbin');
// We dont want tests with app files_trashbin enabled
\OC_App::disable('files_trashbin');
$userManager = \OC::$server->getUserManager();
$userManager->get(self::$testUser)->delete();
$userManager->createUser(self::$testUser,
self::$testUser);
// Create test user
parent::loginAsUser(self::$testUser);
}
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->userId = 'user1'; $this->userId = 'user1';
@ -118,7 +89,6 @@ class KeyManagerTest extends TestCase {
); );
} }
public function testGetPrivateKey() { public function testGetPrivateKey() {
$this->keyStorageMock->expects($this->any()) $this->keyStorageMock->expects($this->any())
->method('getUserKey') ->method('getUserKey')
@ -153,9 +123,6 @@ class KeyManagerTest extends TestCase {
$this->assertTrue($this->instance->recoveryKeyExists()); $this->assertTrue($this->instance->recoveryKeyExists());
} }
/**
*
*/
public function testCheckRecoveryKeyPassword() { public function testCheckRecoveryKeyPassword() {
$this->keyStorageMock->expects($this->any()) $this->keyStorageMock->expects($this->any())
->method('getSystemUserKey') ->method('getSystemUserKey')
@ -165,12 +132,10 @@ class KeyManagerTest extends TestCase {
->method('decryptPrivateKey') ->method('decryptPrivateKey')
->with($this->equalTo('recoveryKey'), $this->equalTo('pass')) ->with($this->equalTo('recoveryKey'), $this->equalTo('pass'))
->willReturn('decryptedRecoveryKey'); ->willReturn('decryptedRecoveryKey');
$this->assertTrue($this->instance->checkRecoveryPassword('pass')); $this->assertTrue($this->instance->checkRecoveryPassword('pass'));
} }
public function testSetPublicKey() { public function testSetPublicKey() {
$this->keyStorageMock->expects($this->any()) $this->keyStorageMock->expects($this->any())
->method('setUserKey') ->method('setUserKey')
@ -184,7 +149,6 @@ class KeyManagerTest extends TestCase {
$this->assertTrue( $this->assertTrue(
$this->instance->setPublicKey($this->userId, 'key') $this->instance->setPublicKey($this->userId, 'key')
); );
} }
public function testSetPrivateKey() { public function testSetPrivateKey() {
@ -214,9 +178,6 @@ class KeyManagerTest extends TestCase {
); );
} }
/**
*
*/
public function testInit() { public function testInit() {
$this->keyStorageMock->expects($this->any()) $this->keyStorageMock->expects($this->any())
->method('getUserKey') ->method('getUserKey')
@ -249,7 +210,7 @@ class KeyManagerTest extends TestCase {
); );
} }
public function setSystemPrivateKey() { public function testSetSystemPrivateKey() {
$this->keyStorageMock->expects($this->exactly(1)) $this->keyStorageMock->expects($this->exactly(1))
->method('setSystemUserKey') ->method('setSystemUserKey')
->with($this->equalTo('keyId.privateKey'), $this->equalTo('key')) ->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))
@ -261,9 +222,9 @@ class KeyManagerTest extends TestCase {
); );
} }
public function getSystemPrivateKey() { public function testGetSystemPrivateKey() {
$this->keyStorageMock->expects($this->exactly(1)) $this->keyStorageMock->expects($this->exactly(1))
->method('setSystemUserKey') ->method('getSystemUserKey')
->with($this->equalTo('keyId.privateKey')) ->with($this->equalTo('keyId.privateKey'))
->willReturn('systemPrivateKey'); ->willReturn('systemPrivateKey');
@ -272,6 +233,4 @@ class KeyManagerTest extends TestCase {
$this->instance->getSystemPrivateKey('keyId') $this->instance->getSystemPrivateKey('keyId')
); );
} }
} }

View File

@ -35,10 +35,10 @@ class SessionTest extends TestCase {
private $sessionMock; private $sessionMock;
/** /**
* @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
* @expectedExceptionMessage Private Key missing for user: please try to log-out and log-in again
*/ */
public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() { public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() {
$this->setExpectedException('OCA\Encryption\Exceptions\PrivateKeyMissingException', 'no private key stored in session');
$this->instance->getPrivateKey(); $this->instance->getPrivateKey();
} }