aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/lib/users/SetupTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/lib/users/SetupTest.php')
-rw-r--r--apps/encryption/tests/lib/users/SetupTest.php59
1 files changed, 39 insertions, 20 deletions
diff --git a/apps/encryption/tests/lib/users/SetupTest.php b/apps/encryption/tests/lib/users/SetupTest.php
index 0cc59384b16..e7d8afbb102 100644
--- a/apps/encryption/tests/lib/users/SetupTest.php
+++ b/apps/encryption/tests/lib/users/SetupTest.php
@@ -41,26 +41,6 @@ class SetupTest extends TestCase {
*/
private $instance;
- public function testSetupServerSide() {
- $this->keyManagerMock->expects($this->exactly(2))->method('validateShareKey');
- $this->keyManagerMock->expects($this->exactly(2))->method('validateMasterKey');
- $this->keyManagerMock->expects($this->exactly(2))
- ->method('userHasKeys')
- ->with('admin')
- ->willReturnOnConsecutiveCalls(true, false);
-
- $this->assertTrue($this->instance->setupServerSide('admin',
- 'password'));
-
- $this->keyManagerMock->expects($this->once())
- ->method('storeKeyPair')
- ->with('admin', 'password')
- ->willReturn(false);
-
- $this->assertFalse($this->instance->setupServerSide('admin',
- 'password'));
- }
-
protected function setUp() {
parent::setUp();
$logMock = $this->getMock('OCP\ILogger');
@@ -81,4 +61,43 @@ class SetupTest extends TestCase {
$this->keyManagerMock);
}
+
+ public function testSetupSystem() {
+ $this->keyManagerMock->expects($this->once())->method('validateShareKey');
+ $this->keyManagerMock->expects($this->once())->method('validateMasterKey');
+
+ $this->instance->setupSystem();
+ }
+
+ /**
+ * @dataProvider dataTestSetupUser
+ *
+ * @param bool $hasKeys
+ * @param bool $expected
+ */
+ public function testSetupUser($hasKeys, $expected) {
+
+ $this->keyManagerMock->expects($this->once())->method('userHasKeys')
+ ->with('uid')->willReturn($hasKeys);
+
+ if ($hasKeys) {
+ $this->keyManagerMock->expects($this->never())->method('storeKeyPair');
+ } else {
+ $this->cryptMock->expects($this->once())->method('createKeyPair')->willReturn('keyPair');
+ $this->keyManagerMock->expects($this->once())->method('storeKeyPair')
+ ->with('uid', 'password', 'keyPair')->willReturn(true);
+ }
+
+ $this->assertSame($expected,
+ $this->instance->setupUser('uid', 'password')
+ );
+ }
+
+ public function dataTestSetupUser() {
+ return [
+ [true, true],
+ [false, true]
+ ];
+ }
+
}