use Test\TestCase;
class KeyManagerTest extends TestCase {
- /**
- * @var bool
- */
- private static $trashbinState;
/**
* @var KeyManager
*/
private $instance;
- /**
- * @var string
- */
- private static $testUser = 'test-keyManager-user.dot';
/**
* @var string
*/
/** @var \PHPUnit_Framework_MockObject_MockObject */
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() {
parent::setUp();
$this->userId = 'user1';
);
}
-
public function testGetPrivateKey() {
$this->keyStorageMock->expects($this->any())
->method('getUserKey')
$this->assertTrue($this->instance->recoveryKeyExists());
}
- /**
- *
- */
public function testCheckRecoveryKeyPassword() {
$this->keyStorageMock->expects($this->any())
->method('getSystemUserKey')
->method('decryptPrivateKey')
->with($this->equalTo('recoveryKey'), $this->equalTo('pass'))
->willReturn('decryptedRecoveryKey');
-
$this->assertTrue($this->instance->checkRecoveryPassword('pass'));
}
-
public function testSetPublicKey() {
$this->keyStorageMock->expects($this->any())
->method('setUserKey')
$this->assertTrue(
$this->instance->setPublicKey($this->userId, 'key')
);
-
}
public function testSetPrivateKey() {
);
}
- /**
- *
- */
public function testInit() {
$this->keyStorageMock->expects($this->any())
->method('getUserKey')
);
}
- public function setSystemPrivateKey() {
+ public function testSetSystemPrivateKey() {
$this->keyStorageMock->expects($this->exactly(1))
->method('setSystemUserKey')
->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))
);
}
- public function getSystemPrivateKey() {
+ public function testGetSystemPrivateKey() {
$this->keyStorageMock->expects($this->exactly(1))
- ->method('setSystemUserKey')
+ ->method('getSystemUserKey')
->with($this->equalTo('keyId.privateKey'))
->willReturn('systemPrivateKey');
$this->instance->getSystemPrivateKey('keyId')
);
}
-
-
}