|
|
|
|
@ -36,9 +36,9 @@ class ManagerTest extends TestCase { |
|
|
|
|
public function testManagerIsDisabledIfDisabledButModules() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(false); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function() use ($em) {return $em;}); |
|
|
|
|
$this->assertFalse($this->manager->isEnabled()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -50,29 +50,32 @@ class ManagerTest extends TestCase { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException |
|
|
|
|
* @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0" |
|
|
|
|
* @expectedExceptionMessage Id "id" already used by encryption module "TestDummyModule0" |
|
|
|
|
*/ |
|
|
|
|
public function testModuleRegistration() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn('yes'); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
|
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
$this->assertSame(1, count($this->manager->getEncryptionModules())); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testModuleUnRegistration() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(true); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
$this->assertSame(1, |
|
|
|
|
count($this->manager->getEncryptionModules()) |
|
|
|
|
); |
|
|
|
|
$this->manager->unregisterEncryptionModule($em); |
|
|
|
|
|
|
|
|
|
$this->manager->unregisterEncryptionModule('id'); |
|
|
|
|
$this->assertEmpty($this->manager->getEncryptionModules()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -82,9 +85,9 @@ class ManagerTest extends TestCase { |
|
|
|
|
public function testGetEncryptionModuleUnknown() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(true); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
$this->assertSame(1, count($this->manager->getEncryptionModules())); |
|
|
|
|
$this->manager->getEncryptionModule('unknown'); |
|
|
|
|
} |
|
|
|
|
@ -92,23 +95,23 @@ class ManagerTest extends TestCase { |
|
|
|
|
public function testGetEncryptionModule() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(true); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
$this->assertSame(1, count($this->manager->getEncryptionModules())); |
|
|
|
|
$en0 = $this->manager->getEncryptionModule(0); |
|
|
|
|
$this->assertEquals(0, $en0->getId()); |
|
|
|
|
$en0 = $this->manager->getEncryptionModule('id'); |
|
|
|
|
$this->assertEquals('id', $en0->getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetDefaultEncryptionModule() { |
|
|
|
|
$this->config->expects($this->any())->method('getAppValue')->willReturn(true); |
|
|
|
|
$em = $this->getMock('\OCP\Encryption\IEncryptionModule'); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn(0); |
|
|
|
|
$em->expects($this->any())->method('getId')->willReturn('id'); |
|
|
|
|
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); |
|
|
|
|
$this->manager->registerEncryptionModule($em); |
|
|
|
|
$this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { return $em;}); |
|
|
|
|
$this->assertSame(1, count($this->manager->getEncryptionModules())); |
|
|
|
|
$en0 = $this->manager->getEncryptionModule(0); |
|
|
|
|
$this->assertEquals(0, $en0->getId()); |
|
|
|
|
$en0 = $this->manager->getEncryptionModule('id'); |
|
|
|
|
$this->assertEquals('id', $en0->getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// /** |
|
|
|
|
|