You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

676 lines
19 KiB

11 years ago
9 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Clark Tomlinson <fallen013@gmail.com>
  9. * @author Joas Schilling <coding@schilljs.com>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. * @author Vincent Petry <pvince81@owncloud.com>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. namespace OCA\Encryption\Tests;
  32. use OC\Files\FileInfo;
  33. use OC\Files\View;
  34. use OCA\Encryption\Crypto\Crypt;
  35. use OCA\Encryption\KeyManager;
  36. use OCA\Encryption\Session;
  37. use OCA\Encryption\Util;
  38. use OCP\Encryption\Keys\IStorage;
  39. use OCP\Files\Cache\ICache;
  40. use OCP\Files\Storage;
  41. use OCP\IConfig;
  42. use OCP\ILogger;
  43. use OCP\IUserSession;
  44. use Test\TestCase;
  45. class KeyManagerTest extends TestCase {
  46. /**
  47. * @var KeyManager
  48. */
  49. private $instance;
  50. /**
  51. * @var string
  52. */
  53. private $userId;
  54. /** @var string */
  55. private $systemKeyId;
  56. /** @var \OCP\Encryption\Keys\IStorage|\PHPUnit_Framework_MockObject_MockObject */
  57. private $keyStorageMock;
  58. /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */
  59. private $cryptMock;
  60. /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
  61. private $userMock;
  62. /** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */
  63. private $sessionMock;
  64. /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */
  65. private $logMock;
  66. /** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */
  67. private $utilMock;
  68. /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
  69. private $configMock;
  70. protected function setUp(): void {
  71. parent::setUp();
  72. $this->userId = 'user1';
  73. $this->systemKeyId = 'systemKeyId';
  74. $this->keyStorageMock = $this->createMock(IStorage::class);
  75. $this->cryptMock = $this->getMockBuilder(Crypt::class)
  76. ->disableOriginalConstructor()
  77. ->getMock();
  78. $this->configMock = $this->createMock(IConfig::class);
  79. $this->configMock->expects($this->any())
  80. ->method('getAppValue')
  81. ->willReturn($this->systemKeyId);
  82. $this->userMock = $this->createMock(IUserSession::class);
  83. $this->sessionMock = $this->getMockBuilder(Session::class)
  84. ->disableOriginalConstructor()
  85. ->getMock();
  86. $this->logMock = $this->createMock(ILogger::class);
  87. $this->utilMock = $this->getMockBuilder(Util::class)
  88. ->disableOriginalConstructor()
  89. ->getMock();
  90. $this->instance = new KeyManager(
  91. $this->keyStorageMock,
  92. $this->cryptMock,
  93. $this->configMock,
  94. $this->userMock,
  95. $this->sessionMock,
  96. $this->logMock,
  97. $this->utilMock);
  98. }
  99. public function testDeleteShareKey() {
  100. $this->keyStorageMock->expects($this->any())
  101. ->method('deleteFileKey')
  102. ->with($this->equalTo('/path'), $this->equalTo('keyId.shareKey'))
  103. ->willReturn(true);
  104. $this->assertTrue(
  105. $this->instance->deleteShareKey('/path', 'keyId')
  106. );
  107. }
  108. public function testGetPrivateKey() {
  109. $this->keyStorageMock->expects($this->any())
  110. ->method('getUserKey')
  111. ->with($this->equalTo($this->userId), $this->equalTo('privateKey'))
  112. ->willReturn('privateKey');
  113. $this->assertSame('privateKey',
  114. $this->instance->getPrivateKey($this->userId)
  115. );
  116. }
  117. public function testGetPublicKey() {
  118. $this->keyStorageMock->expects($this->any())
  119. ->method('getUserKey')
  120. ->with($this->equalTo($this->userId), $this->equalTo('publicKey'))
  121. ->willReturn('publicKey');
  122. $this->assertSame('publicKey',
  123. $this->instance->getPublicKey($this->userId)
  124. );
  125. }
  126. public function testRecoveryKeyExists() {
  127. $this->keyStorageMock->expects($this->any())
  128. ->method('getSystemUserKey')
  129. ->with($this->equalTo($this->systemKeyId . '.publicKey'))
  130. ->willReturn('recoveryKey');
  131. $this->assertTrue($this->instance->recoveryKeyExists());
  132. }
  133. public function testCheckRecoveryKeyPassword() {
  134. $this->keyStorageMock->expects($this->any())
  135. ->method('getSystemUserKey')
  136. ->with($this->equalTo($this->systemKeyId . '.privateKey'))
  137. ->willReturn('recoveryKey');
  138. $this->cryptMock->expects($this->any())
  139. ->method('decryptPrivateKey')
  140. ->with($this->equalTo('recoveryKey'), $this->equalTo('pass'))
  141. ->willReturn('decryptedRecoveryKey');
  142. $this->assertTrue($this->instance->checkRecoveryPassword('pass'));
  143. }
  144. public function testSetPublicKey() {
  145. $this->keyStorageMock->expects($this->any())
  146. ->method('setUserKey')
  147. ->with(
  148. $this->equalTo($this->userId),
  149. $this->equalTo('publicKey'),
  150. $this->equalTo('key'))
  151. ->willReturn(true);
  152. $this->assertTrue(
  153. $this->instance->setPublicKey($this->userId, 'key')
  154. );
  155. }
  156. public function testSetPrivateKey() {
  157. $this->keyStorageMock->expects($this->any())
  158. ->method('setUserKey')
  159. ->with(
  160. $this->equalTo($this->userId),
  161. $this->equalTo('privateKey'),
  162. $this->equalTo('key'))
  163. ->willReturn(true);
  164. $this->assertTrue(
  165. $this->instance->setPrivateKey($this->userId, 'key')
  166. );
  167. }
  168. /**
  169. * @dataProvider dataTestUserHasKeys
  170. */
  171. public function testUserHasKeys($key, $expected) {
  172. $this->keyStorageMock->expects($this->exactly(2))
  173. ->method('getUserKey')
  174. ->with($this->equalTo($this->userId), $this->anything())
  175. ->willReturn($key);
  176. $this->assertSame($expected,
  177. $this->instance->userHasKeys($this->userId)
  178. );
  179. }
  180. public function dataTestUserHasKeys() {
  181. return [
  182. ['key', true],
  183. ['', false]
  184. ];
  185. }
  186. public function testUserHasKeysMissingPrivateKey() {
  187. $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
  188. $this->keyStorageMock->expects($this->exactly(2))
  189. ->method('getUserKey')
  190. ->willReturnCallback(function ($uid, $keyID, $encryptionModuleId) {
  191. if ($keyID=== 'privateKey') {
  192. return '';
  193. }
  194. return 'key';
  195. });
  196. $this->instance->userHasKeys($this->userId);
  197. }
  198. public function testUserHasKeysMissingPublicKey() {
  199. $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
  200. $this->keyStorageMock->expects($this->exactly(2))
  201. ->method('getUserKey')
  202. ->willReturnCallback(function ($uid, $keyID, $encryptionModuleId) {
  203. if ($keyID === 'publicKey') {
  204. return '';
  205. }
  206. return 'key';
  207. });
  208. $this->instance->userHasKeys($this->userId);
  209. }
  210. /**
  211. * @dataProvider dataTestInit
  212. *
  213. * @param bool $useMasterKey
  214. */
  215. public function testInit($useMasterKey) {
  216. /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */
  217. $instance = $this->getMockBuilder(KeyManager::class)
  218. ->setConstructorArgs(
  219. [
  220. $this->keyStorageMock,
  221. $this->cryptMock,
  222. $this->configMock,
  223. $this->userMock,
  224. $this->sessionMock,
  225. $this->logMock,
  226. $this->utilMock
  227. ]
  228. )->setMethods(['getMasterKeyId', 'getMasterKeyPassword', 'getSystemPrivateKey', 'getPrivateKey'])
  229. ->getMock();
  230. $this->utilMock->expects($this->once())->method('isMasterKeyEnabled')
  231. ->willReturn($useMasterKey);
  232. $this->sessionMock->expects($this->at(0))->method('setStatus')
  233. ->with(Session::INIT_EXECUTED);
  234. $instance->expects($this->any())->method('getMasterKeyId')->willReturn('masterKeyId');
  235. $instance->expects($this->any())->method('getMasterKeyPassword')->willReturn('masterKeyPassword');
  236. $instance->expects($this->any())->method('getSystemPrivateKey')->with('masterKeyId')->willReturn('privateMasterKey');
  237. $instance->expects($this->any())->method('getPrivateKey')->with($this->userId)->willReturn('privateUserKey');
  238. if ($useMasterKey) {
  239. $this->cryptMock->expects($this->once())->method('decryptPrivateKey')
  240. ->with('privateMasterKey', 'masterKeyPassword', 'masterKeyId')
  241. ->willReturn('key');
  242. } else {
  243. $this->cryptMock->expects($this->once())->method('decryptPrivateKey')
  244. ->with('privateUserKey', 'pass', $this->userId)
  245. ->willReturn('key');
  246. }
  247. $this->sessionMock->expects($this->once())->method('setPrivateKey')
  248. ->with('key');
  249. $this->assertTrue($instance->init($this->userId, 'pass'));
  250. }
  251. public function dataTestInit() {
  252. return [
  253. [true],
  254. [false]
  255. ];
  256. }
  257. public function testSetRecoveryKey() {
  258. $this->keyStorageMock->expects($this->exactly(2))
  259. ->method('setSystemUserKey')
  260. ->willReturn(true);
  261. $this->cryptMock->expects($this->any())
  262. ->method('encryptPrivateKey')
  263. ->with($this->equalTo('privateKey'), $this->equalTo('pass'))
  264. ->willReturn('decryptedPrivateKey');
  265. $this->assertTrue(
  266. $this->instance->setRecoveryKey('pass',
  267. ['publicKey' => 'publicKey', 'privateKey' => 'privateKey'])
  268. );
  269. }
  270. public function testSetSystemPrivateKey() {
  271. $this->keyStorageMock->expects($this->exactly(1))
  272. ->method('setSystemUserKey')
  273. ->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))
  274. ->willReturn(true);
  275. $this->assertTrue(
  276. $this->instance->setSystemPrivateKey('keyId', 'key')
  277. );
  278. }
  279. public function testGetSystemPrivateKey() {
  280. $this->keyStorageMock->expects($this->exactly(1))
  281. ->method('getSystemUserKey')
  282. ->with($this->equalTo('keyId.privateKey'))
  283. ->willReturn('systemPrivateKey');
  284. $this->assertSame('systemPrivateKey',
  285. $this->instance->getSystemPrivateKey('keyId')
  286. );
  287. }
  288. public function testGetEncryptedFileKey() {
  289. $this->keyStorageMock->expects($this->once())
  290. ->method('getFileKey')
  291. ->with('/', 'fileKey')
  292. ->willReturn(true);
  293. $this->assertTrue($this->instance->getEncryptedFileKey('/'));
  294. }
  295. public function dataTestGetFileKey() {
  296. return [
  297. ['user1', false, 'privateKey', true],
  298. ['user1', false, false, ''],
  299. ['user1', true, 'privateKey', true],
  300. ['user1', true, false, ''],
  301. [null, false, 'privateKey', true],
  302. [null, false, false, ''],
  303. [null, true, 'privateKey', true],
  304. [null, true, false, '']
  305. ];
  306. }
  307. /**
  308. * @dataProvider dataTestGetFileKey
  309. *
  310. * @param $uid
  311. * @param $isMasterKeyEnabled
  312. * @param $privateKey
  313. * @param $expected
  314. */
  315. public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $expected) {
  316. $path = '/foo.txt';
  317. if ($isMasterKeyEnabled) {
  318. $expectedUid = 'masterKeyId';
  319. $this->configMock->expects($this->any())->method('getSystemValue')->with('secret')
  320. ->willReturn('password');
  321. } elseif (!$uid) {
  322. $expectedUid = 'systemKeyId';
  323. } else {
  324. $expectedUid = $uid;
  325. }
  326. $this->invokePrivate($this->instance, 'masterKeyId', ['masterKeyId']);
  327. $this->keyStorageMock->expects($this->at(0))
  328. ->method('getFileKey')
  329. ->with($path, 'fileKey', 'OC_DEFAULT_MODULE')
  330. ->willReturn(true);
  331. $this->keyStorageMock->expects($this->at(1))
  332. ->method('getFileKey')
  333. ->with($path, $expectedUid . '.shareKey', 'OC_DEFAULT_MODULE')
  334. ->willReturn(true);
  335. $this->utilMock->expects($this->any())->method('isMasterKeyEnabled')
  336. ->willReturn($isMasterKeyEnabled);
  337. if (is_null($uid)) {
  338. $this->keyStorageMock->expects($this->once())
  339. ->method('getSystemUserKey')
  340. ->willReturn(true);
  341. $this->cryptMock->expects($this->once())
  342. ->method('decryptPrivateKey')
  343. ->willReturn($privateKey);
  344. } else {
  345. $this->keyStorageMock->expects($this->never())
  346. ->method('getSystemUserKey');
  347. $this->sessionMock->expects($this->once())->method('getPrivateKey')->willReturn($privateKey);
  348. }
  349. if ($privateKey) {
  350. $this->cryptMock->expects($this->once())
  351. ->method('multiKeyDecrypt')
  352. ->willReturn(true);
  353. } else {
  354. $this->cryptMock->expects($this->never())
  355. ->method('multiKeyDecrypt');
  356. }
  357. $this->assertSame($expected,
  358. $this->instance->getFileKey($path, $uid)
  359. );
  360. }
  361. public function testDeletePrivateKey() {
  362. $this->keyStorageMock->expects($this->once())
  363. ->method('deleteUserKey')
  364. ->with('user1', 'privateKey')
  365. ->willReturn(true);
  366. $this->assertTrue(self::invokePrivate($this->instance,
  367. 'deletePrivateKey',
  368. [$this->userId]));
  369. }
  370. public function testDeleteAllFileKeys() {
  371. $this->keyStorageMock->expects($this->once())
  372. ->method('deleteAllFileKeys')
  373. ->willReturn(true);
  374. $this->assertTrue($this->instance->deleteAllFileKeys('/'));
  375. }
  376. /**
  377. * test add public share key and or recovery key to the list of public keys
  378. *
  379. * @dataProvider dataTestAddSystemKeys
  380. *
  381. * @param array $accessList
  382. * @param array $publicKeys
  383. * @param string $uid
  384. * @param array $expectedKeys
  385. */
  386. public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys) {
  387. $publicShareKeyId = 'publicShareKey';
  388. $recoveryKeyId = 'recoveryKey';
  389. $this->keyStorageMock->expects($this->any())
  390. ->method('getSystemUserKey')
  391. ->willReturnCallback(function ($keyId, $encryptionModuleId) {
  392. return $keyId;
  393. });
  394. $this->utilMock->expects($this->any())
  395. ->method('isRecoveryEnabledForUser')
  396. ->willReturnCallback(function ($uid) {
  397. if ($uid === 'user1') {
  398. return true;
  399. }
  400. return false;
  401. });
  402. // set key IDs
  403. self::invokePrivate($this->instance, 'publicShareKeyId', [$publicShareKeyId]);
  404. self::invokePrivate($this->instance, 'recoveryKeyId', [$recoveryKeyId]);
  405. $result = $this->instance->addSystemKeys($accessList, $publicKeys, $uid);
  406. foreach ($expectedKeys as $expected) {
  407. $this->assertArrayHasKey($expected, $result);
  408. }
  409. $this->assertSameSize($expectedKeys, $result);
  410. }
  411. /**
  412. * data provider for testAddSystemKeys()
  413. *
  414. * @return array
  415. */
  416. public function dataTestAddSystemKeys() {
  417. return [
  418. [['public' => true],[], 'user1', ['publicShareKey', 'recoveryKey']],
  419. [['public' => false], [], 'user1', ['recoveryKey']],
  420. [['public' => true],[], 'user2', ['publicShareKey']],
  421. [['public' => false], [], 'user2', []],
  422. ];
  423. }
  424. public function testGetMasterKeyId() {
  425. $this->assertSame('systemKeyId', $this->instance->getMasterKeyId());
  426. }
  427. public function testGetPublicMasterKey() {
  428. $this->keyStorageMock->expects($this->once())->method('getSystemUserKey')
  429. ->with('systemKeyId.publicKey', \OCA\Encryption\Crypto\Encryption::ID)
  430. ->willReturn(true);
  431. $this->assertTrue(
  432. $this->instance->getPublicMasterKey()
  433. );
  434. }
  435. public function testGetMasterKeyPassword() {
  436. $this->configMock->expects($this->once())->method('getSystemValue')->with('secret')
  437. ->willReturn('password');
  438. $this->assertSame('password',
  439. $this->invokePrivate($this->instance, 'getMasterKeyPassword', [])
  440. );
  441. }
  442. public function testGetMasterKeyPasswordException() {
  443. $this->expectException(\Exception::class);
  444. $this->configMock->expects($this->once())->method('getSystemValue')->with('secret')
  445. ->willReturn('');
  446. $this->invokePrivate($this->instance, 'getMasterKeyPassword', []);
  447. }
  448. /**
  449. * @dataProvider dataTestValidateMasterKey
  450. *
  451. * @param $masterKey
  452. */
  453. public function testValidateMasterKey($masterKey) {
  454. /** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */
  455. $instance = $this->getMockBuilder(KeyManager::class)
  456. ->setConstructorArgs(
  457. [
  458. $this->keyStorageMock,
  459. $this->cryptMock,
  460. $this->configMock,
  461. $this->userMock,
  462. $this->sessionMock,
  463. $this->logMock,
  464. $this->utilMock
  465. ]
  466. )->setMethods(['getPublicMasterKey', 'setSystemPrivateKey', 'getMasterKeyPassword'])
  467. ->getMock();
  468. $instance->expects($this->once())->method('getPublicMasterKey')
  469. ->willReturn($masterKey);
  470. $instance->expects($this->any())->method('getMasterKeyPassword')->willReturn('masterKeyPassword');
  471. $this->cryptMock->expects($this->any())->method('generateHeader')->willReturn('header');
  472. if (empty($masterKey)) {
  473. $this->cryptMock->expects($this->once())->method('createKeyPair')
  474. ->willReturn(['publicKey' => 'public', 'privateKey' => 'private']);
  475. $this->keyStorageMock->expects($this->once())->method('setSystemUserKey')
  476. ->with('systemKeyId.publicKey', 'public', \OCA\Encryption\Crypto\Encryption::ID);
  477. $this->cryptMock->expects($this->once())->method('encryptPrivateKey')
  478. ->with('private', 'masterKeyPassword', 'systemKeyId')
  479. ->willReturn('EncryptedKey');
  480. $instance->expects($this->once())->method('setSystemPrivateKey')
  481. ->with('systemKeyId', 'headerEncryptedKey');
  482. } else {
  483. $this->cryptMock->expects($this->never())->method('createKeyPair');
  484. $this->keyStorageMock->expects($this->never())->method('setSystemUserKey');
  485. $this->cryptMock->expects($this->never())->method('encryptPrivateKey');
  486. $instance->expects($this->never())->method('setSystemPrivateKey');
  487. }
  488. $instance->validateMasterKey();
  489. }
  490. public function dataTestValidateMasterKey() {
  491. return [
  492. ['masterKey'],
  493. ['']
  494. ];
  495. }
  496. public function testGetVersionWithoutFileInfo() {
  497. $view = $this->getMockBuilder(View::class)
  498. ->disableOriginalConstructor()->getMock();
  499. $view->expects($this->once())
  500. ->method('getFileInfo')
  501. ->with('/admin/files/myfile.txt')
  502. ->willReturn(false);
  503. /** @var \OC\Files\View $view */
  504. $this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view));
  505. }
  506. public function testGetVersionWithFileInfo() {
  507. $view = $this->getMockBuilder(View::class)
  508. ->disableOriginalConstructor()->getMock();
  509. $fileInfo = $this->getMockBuilder(FileInfo::class)
  510. ->disableOriginalConstructor()->getMock();
  511. $fileInfo->expects($this->once())
  512. ->method('getEncryptedVersion')
  513. ->willReturn(1337);
  514. $view->expects($this->once())
  515. ->method('getFileInfo')
  516. ->with('/admin/files/myfile.txt')
  517. ->willReturn($fileInfo);
  518. /** @var \OC\Files\View $view */
  519. $this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view));
  520. }
  521. public function testSetVersionWithFileInfo() {
  522. $view = $this->getMockBuilder(View::class)
  523. ->disableOriginalConstructor()->getMock();
  524. $cache = $this->getMockBuilder(ICache::class)
  525. ->disableOriginalConstructor()->getMock();
  526. $cache->expects($this->once())
  527. ->method('update')
  528. ->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]);
  529. $storage = $this->getMockBuilder(Storage::class)
  530. ->disableOriginalConstructor()->getMock();
  531. $storage->expects($this->once())
  532. ->method('getCache')
  533. ->willReturn($cache);
  534. $fileInfo = $this->getMockBuilder(FileInfo::class)
  535. ->disableOriginalConstructor()->getMock();
  536. $fileInfo->expects($this->once())
  537. ->method('getStorage')
  538. ->willReturn($storage);
  539. $fileInfo->expects($this->once())
  540. ->method('getId')
  541. ->willReturn(123);
  542. $view->expects($this->once())
  543. ->method('getFileInfo')
  544. ->with('/admin/files/myfile.txt')
  545. ->willReturn($fileInfo);
  546. /** @var \OC\Files\View $view */
  547. $this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
  548. }
  549. public function testSetVersionWithoutFileInfo() {
  550. $view = $this->getMockBuilder(View::class)
  551. ->disableOriginalConstructor()->getMock();
  552. $view->expects($this->once())
  553. ->method('getFileInfo')
  554. ->with('/admin/files/myfile.txt')
  555. ->willReturn(false);
  556. /** @var \OC\Files\View $view */
  557. $this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
  558. }
  559. public function testBackupUserKeys() {
  560. $this->keyStorageMock->expects($this->once())->method('backupUserKeys')
  561. ->with('OC_DEFAULT_MODULE', 'test', 'user1');
  562. $this->instance->backupUserKeys('test', 'user1');
  563. }
  564. }