EndToEndRandomIT.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. *
  3. * Nextcloud Android client application
  4. *
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2020 Tobias Kaminsky
  7. * Copyright (C) 2020 Nextcloud GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. package com.nextcloud.client;
  23. import android.accounts.AccountManager;
  24. import com.nextcloud.test.RandomStringGenerator;
  25. import com.owncloud.android.AbstractOnServerIT;
  26. import com.owncloud.android.datamodel.ArbitraryDataProvider;
  27. import com.owncloud.android.datamodel.OCFile;
  28. import com.owncloud.android.db.OCUpload;
  29. import com.owncloud.android.files.services.FileUploader;
  30. import com.owncloud.android.lib.common.accounts.AccountUtils;
  31. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  32. import com.owncloud.android.lib.common.utils.Log_OC;
  33. import com.owncloud.android.lib.ocs.responses.PrivateKey;
  34. import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
  35. import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
  36. import com.owncloud.android.lib.resources.status.OCCapability;
  37. import com.owncloud.android.lib.resources.status.OwnCloudVersion;
  38. import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
  39. import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
  40. import com.owncloud.android.lib.resources.users.SendCSROperation;
  41. import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
  42. import com.owncloud.android.operations.DownloadFileOperation;
  43. import com.owncloud.android.operations.GetCapabilitiesOperation;
  44. import com.owncloud.android.operations.RemoveFileOperation;
  45. import com.owncloud.android.utils.CsrHelper;
  46. import com.owncloud.android.utils.EncryptionUtils;
  47. import com.owncloud.android.utils.FileStorageUtils;
  48. import org.junit.Before;
  49. import org.junit.BeforeClass;
  50. import org.junit.Rule;
  51. import org.junit.Test;
  52. import java.io.File;
  53. import java.io.IOException;
  54. import java.security.KeyPair;
  55. import java.util.ArrayList;
  56. import java.util.List;
  57. import java.util.Random;
  58. import static com.owncloud.android.lib.resources.status.OwnCloudVersion.nextcloud_19;
  59. import static junit.framework.TestCase.assertEquals;
  60. import static junit.framework.TestCase.assertFalse;
  61. import static junit.framework.TestCase.assertNotNull;
  62. import static junit.framework.TestCase.assertTrue;
  63. import static org.junit.Assume.assumeTrue;
  64. public class EndToEndRandomIT extends AbstractOnServerIT {
  65. public enum Action {
  66. CREATE_FOLDER,
  67. GO_INTO_FOLDER,
  68. GO_UP,
  69. UPLOAD_FILE,
  70. DOWNLOAD_FILE,
  71. DELETE_FILE,
  72. }
  73. private static ArbitraryDataProvider arbitraryDataProvider;
  74. private OCFile currentFolder;
  75. private int actionCount = 20;
  76. private String rootEncFolder = "/e/";
  77. @Rule
  78. public RetryTestRule retryTestRule = new RetryTestRule();
  79. @BeforeClass
  80. public static void initClass() {
  81. arbitraryDataProvider = new ArbitraryDataProvider(targetContext.getContentResolver());
  82. }
  83. @Before
  84. public void before() throws IOException {
  85. OCCapability capability = getStorageManager().getCapability(account.name);
  86. if (capability.getVersion().equals(new OwnCloudVersion("0.0.0"))) {
  87. // fetch new one
  88. assertTrue(new GetCapabilitiesOperation(getStorageManager())
  89. .execute(client)
  90. .isSuccess());
  91. }
  92. // tests only for NC19+
  93. assumeTrue(getStorageManager()
  94. .getCapability(account.name)
  95. .getVersion()
  96. .isNewerOrEqual(nextcloud_19)
  97. );
  98. // make sure that every file is available, even after tests that remove source file
  99. createDummyFiles();
  100. }
  101. @Test
  102. public void run() throws Exception {
  103. init();
  104. for (int i = 0; i < actionCount; i++) {
  105. Action nextAction = Action.values()[new Random().nextInt(Action.values().length)];
  106. switch (nextAction) {
  107. case CREATE_FOLDER:
  108. createFolder(i);
  109. break;
  110. case GO_INTO_FOLDER:
  111. goIntoFolder(i);
  112. break;
  113. case GO_UP:
  114. goUp(i);
  115. break;
  116. case UPLOAD_FILE:
  117. uploadFile(i);
  118. break;
  119. case DOWNLOAD_FILE:
  120. downloadFile(i);
  121. break;
  122. case DELETE_FILE:
  123. deleteFile(i);
  124. break;
  125. default:
  126. Log_OC.d(this, "[" + i + "/" + actionCount + "]" + " Unknown action: " + nextAction);
  127. break;
  128. }
  129. }
  130. }
  131. @Test
  132. public void uploadOneFile() throws Exception {
  133. init();
  134. uploadFile(0);
  135. }
  136. @Test
  137. public void createFolder() throws Exception {
  138. init();
  139. currentFolder = createFolder(0);
  140. assertNotNull(currentFolder);
  141. }
  142. @Test
  143. public void createSubFolders() throws Exception {
  144. init();
  145. currentFolder = createFolder(0);
  146. assertNotNull(currentFolder);
  147. currentFolder = createFolder(1);
  148. assertNotNull(currentFolder);
  149. currentFolder = createFolder(2);
  150. assertNotNull(currentFolder);
  151. }
  152. @Test
  153. public void createSubFoldersWithFiles() throws Exception {
  154. init();
  155. currentFolder = createFolder(0);
  156. assertNotNull(currentFolder);
  157. uploadFile(1);
  158. uploadFile(1);
  159. uploadFile(2);
  160. currentFolder = createFolder(1);
  161. assertNotNull(currentFolder);
  162. uploadFile(11);
  163. uploadFile(12);
  164. uploadFile(13);
  165. currentFolder = createFolder(2);
  166. assertNotNull(currentFolder);
  167. uploadFile(21);
  168. uploadFile(22);
  169. uploadFile(23);
  170. }
  171. @Test
  172. public void pseudoRandom() throws Exception {
  173. init();
  174. uploadFile(1);
  175. createFolder(2);
  176. goIntoFolder(3);
  177. goUp(4);
  178. createFolder(5);
  179. uploadFile(6);
  180. goUp(7);
  181. goIntoFolder(8);
  182. goIntoFolder(9);
  183. uploadFile(10);
  184. }
  185. @Test
  186. public void deleteFile() throws Exception {
  187. init();
  188. uploadFile(1);
  189. deleteFile(1);
  190. }
  191. @Test
  192. public void downloadFile() throws Exception {
  193. init();
  194. uploadFile(1);
  195. downloadFile(1);
  196. }
  197. private void init() throws Exception {
  198. // create folder
  199. createFolder(rootEncFolder);
  200. OCFile encFolder = createFolder(rootEncFolder + RandomStringGenerator.make(5) + "/");
  201. // encrypt it
  202. assertTrue(new ToggleEncryptionRemoteOperation(encFolder.getLocalId(),
  203. encFolder.getRemotePath(),
  204. true)
  205. .execute(client).isSuccess());
  206. encFolder.setEncrypted(true);
  207. getStorageManager().saveFolder(encFolder, new ArrayList<>(), new ArrayList<>());
  208. useExistingKeys();
  209. rootEncFolder = encFolder.getDecryptedRemotePath();
  210. currentFolder = encFolder;
  211. }
  212. private OCFile createFolder(int i) {
  213. String path = currentFolder.getDecryptedRemotePath() + RandomStringGenerator.make(5) + "/";
  214. Log_OC.d(this, "[" + i + "/" + actionCount + "] " + "Create folder: " + path);
  215. return createFolder(path);
  216. }
  217. private void goIntoFolder(int i) {
  218. ArrayList<OCFile> folders = new ArrayList<>();
  219. for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
  220. if (file.isFolder()) {
  221. folders.add(file);
  222. }
  223. }
  224. if (folders.isEmpty()) {
  225. Log_OC.d(this, "[" + i + "/" + actionCount + "] " + "Go into folder: No folders");
  226. return;
  227. }
  228. currentFolder = folders.get(new Random().nextInt(folders.size()));
  229. Log_OC.d(this,
  230. "[" + i + "/" + actionCount + "] " + "Go into folder: " + currentFolder.getDecryptedRemotePath());
  231. }
  232. private void goUp(int i) {
  233. if (currentFolder.getRemotePath().equals(rootEncFolder)) {
  234. Log_OC.d(this,
  235. "[" + i + "/" + actionCount + "] " + "Go up to folder: " + currentFolder.getDecryptedRemotePath());
  236. return;
  237. }
  238. currentFolder = getStorageManager().getFileById(currentFolder.getParentId());
  239. if (currentFolder == null) {
  240. throw new RuntimeException("Current folder is null");
  241. }
  242. Log_OC.d(this,
  243. "[" + i + "/" + actionCount + "] " + "Go up to folder: " + currentFolder.getDecryptedRemotePath());
  244. }
  245. private void uploadFile(int i) throws IOException {
  246. String fileName = RandomStringGenerator.make(5) + ".txt";
  247. File file;
  248. if (new Random().nextBoolean()) {
  249. file = createFile(fileName, new Random().nextInt(50000));
  250. } else {
  251. file = createFile(fileName, 500000 + new Random().nextInt(50000));
  252. }
  253. String remotePath = currentFolder.getRemotePath() + fileName;
  254. Log_OC.d(this,
  255. "[" + i + "/" + actionCount + "] " +
  256. "Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName);
  257. OCUpload ocUpload = new OCUpload(file.getAbsolutePath(),
  258. remotePath,
  259. account.name);
  260. uploadOCUpload(ocUpload);
  261. shortSleep();
  262. OCFile parentFolder = getStorageManager()
  263. .getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
  264. String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
  265. String decryptedPath = parentFolder.getDecryptedRemotePath() + uploadedFileName;
  266. OCFile uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
  267. verifyStoragePath(uploadedFile);
  268. // verify storage path
  269. refreshFolder(currentFolder.getRemotePath());
  270. uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
  271. verifyStoragePath(uploadedFile);
  272. // verify that encrypted file is on server
  273. assertTrue(new ReadFileRemoteOperation(currentFolder.getRemotePath() + uploadedFile.getEncryptedFileName())
  274. .execute(client)
  275. .isSuccess());
  276. // verify that unencrypted file is not on server
  277. assertFalse(new ReadFileRemoteOperation(currentFolder.getDecryptedRemotePath() + fileName)
  278. .execute(client)
  279. .isSuccess());
  280. }
  281. private void downloadFile(int i) {
  282. ArrayList<OCFile> files = new ArrayList<>();
  283. for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
  284. if (!file.isFolder()) {
  285. files.add(file);
  286. }
  287. }
  288. if (files.isEmpty()) {
  289. Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
  290. return;
  291. }
  292. OCFile fileToDownload = files.get(new Random().nextInt(files.size()));
  293. assertNotNull(fileToDownload.getRemoteId());
  294. Log_OC.d(this,
  295. "[" + i + "/" + actionCount + "] " + "Download file: " +
  296. currentFolder.getDecryptedRemotePath() + fileToDownload.getDecryptedFileName());
  297. assertTrue(new DownloadFileOperation(user, fileToDownload, targetContext)
  298. .execute(client)
  299. .isSuccess());
  300. assertTrue(new File(fileToDownload.getStoragePath()).exists());
  301. verifyStoragePath(fileToDownload);
  302. }
  303. @Test
  304. public void testUploadWithCopy() throws Exception {
  305. init();
  306. OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
  307. currentFolder.getRemotePath() + "nonEmpty.txt",
  308. account.name);
  309. uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
  310. File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
  311. OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
  312. "nonEmpty.txt");
  313. assertTrue(originalFile.exists());
  314. assertTrue(new File(uploadedFile.getStoragePath()).exists());
  315. }
  316. @Test
  317. public void testUploadWithMove() throws Exception {
  318. init();
  319. OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
  320. currentFolder.getRemotePath() + "nonEmpty.txt",
  321. account.name);
  322. uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_MOVE);
  323. File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
  324. OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
  325. "nonEmpty.txt");
  326. assertFalse(originalFile.exists());
  327. assertTrue(new File(uploadedFile.getStoragePath()).exists());
  328. }
  329. @Test
  330. public void testUploadWithForget() throws Exception {
  331. init();
  332. OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
  333. currentFolder.getRemotePath() + "nonEmpty.txt",
  334. account.name);
  335. uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
  336. File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
  337. OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
  338. "nonEmpty.txt");
  339. assertTrue(originalFile.exists());
  340. assertFalse(new File(uploadedFile.getStoragePath()).exists());
  341. }
  342. @Test
  343. public void testUploadWithDelete() throws Exception {
  344. init();
  345. OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
  346. currentFolder.getRemotePath() + "nonEmpty.txt",
  347. account.name);
  348. uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_DELETE);
  349. File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
  350. OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
  351. "nonEmpty.txt");
  352. assertFalse(originalFile.exists());
  353. assertFalse(new File(uploadedFile.getStoragePath()).exists());
  354. }
  355. private void deleteFile(int i) {
  356. ArrayList<OCFile> files = new ArrayList<>();
  357. for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
  358. if (!file.isFolder()) {
  359. files.add(file);
  360. }
  361. }
  362. if (files.isEmpty()) {
  363. Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
  364. return;
  365. }
  366. OCFile fileToDelete = files.get(new Random().nextInt(files.size()));
  367. assertNotNull(fileToDelete.getRemoteId());
  368. Log_OC.d(this,
  369. "[" + i + "/" + actionCount + "] " +
  370. "Delete file: " + currentFolder.getDecryptedRemotePath() + fileToDelete.getDecryptedFileName());
  371. assertTrue(new RemoveFileOperation(fileToDelete,
  372. false,
  373. user,
  374. false,
  375. targetContext,
  376. getStorageManager())
  377. .execute(client)
  378. .isSuccess());
  379. }
  380. @Test
  381. public void reInit() throws Exception {
  382. // create folder
  383. OCFile encFolder = createFolder(rootEncFolder);
  384. // encrypt it
  385. assertTrue(new ToggleEncryptionRemoteOperation(encFolder.getLocalId(),
  386. encFolder.getRemotePath(),
  387. true)
  388. .execute(client).isSuccess());
  389. encFolder.setEncrypted(true);
  390. getStorageManager().saveFolder(encFolder, new ArrayList<>(), new ArrayList<>());
  391. createKeys();
  392. // delete keys
  393. arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PRIVATE_KEY);
  394. arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PUBLIC_KEY);
  395. arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.MNEMONIC);
  396. useExistingKeys();
  397. }
  398. private void useExistingKeys() throws Exception {
  399. // download them from server
  400. GetPublicKeyOperation publicKeyOperation = new GetPublicKeyOperation();
  401. RemoteOperationResult publicKeyResult = publicKeyOperation.execute(account, targetContext);
  402. assertTrue(publicKeyResult.isSuccess());
  403. String publicKeyFromServer = (String) publicKeyResult.getData().get(0);
  404. arbitraryDataProvider.storeOrUpdateKeyValue(account.name,
  405. EncryptionUtils.PUBLIC_KEY,
  406. publicKeyFromServer);
  407. RemoteOperationResult<PrivateKey> privateKeyResult = new GetPrivateKeyOperation().execute(account,
  408. targetContext);
  409. assertTrue(privateKeyResult.isSuccess());
  410. PrivateKey privateKey = privateKeyResult.getResultData();
  411. String mnemonic = generateMnemonicString();
  412. String decryptedPrivateKey = EncryptionUtils.decryptPrivateKey(privateKey.getKey(), mnemonic);
  413. arbitraryDataProvider.storeOrUpdateKeyValue(account.name,
  414. EncryptionUtils.PRIVATE_KEY, decryptedPrivateKey);
  415. Log_OC.d(this, "Private key successfully decrypted and stored");
  416. arbitraryDataProvider.storeOrUpdateKeyValue(account.name, EncryptionUtils.MNEMONIC, mnemonic);
  417. }
  418. /*
  419. TODO do not c&p code
  420. */
  421. private void createKeys() throws Exception {
  422. String publicKey;
  423. // Create public/private key pair
  424. KeyPair keyPair = EncryptionUtils.generateKeyPair();
  425. // create CSR
  426. AccountManager accountManager = AccountManager.get(targetContext);
  427. String userId = accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID);
  428. String urlEncoded = CsrHelper.generateCsrPemEncodedString(keyPair, userId);
  429. SendCSROperation operation = new SendCSROperation(urlEncoded);
  430. RemoteOperationResult result = operation.execute(account, targetContext);
  431. if (result.isSuccess()) {
  432. publicKey = (String) result.getData().get(0);
  433. } else {
  434. throw new Exception("failed to send CSR", result.getException());
  435. }
  436. java.security.PrivateKey privateKey = keyPair.getPrivate();
  437. String privateKeyString = EncryptionUtils.encodeBytesToBase64String(privateKey.getEncoded());
  438. String privatePemKeyString = EncryptionUtils.privateKeyToPEM(privateKey);
  439. String encryptedPrivateKey = EncryptionUtils.encryptPrivateKey(privatePemKeyString,
  440. generateMnemonicString());
  441. // upload encryptedPrivateKey
  442. StorePrivateKeyOperation storePrivateKeyOperation = new StorePrivateKeyOperation(encryptedPrivateKey);
  443. RemoteOperationResult storePrivateKeyResult = storePrivateKeyOperation.execute(account, targetContext);
  444. if (storePrivateKeyResult.isSuccess()) {
  445. arbitraryDataProvider.storeOrUpdateKeyValue(account.name, EncryptionUtils.PRIVATE_KEY,
  446. privateKeyString);
  447. arbitraryDataProvider.storeOrUpdateKeyValue(account.name, EncryptionUtils.PUBLIC_KEY, publicKey);
  448. arbitraryDataProvider.storeOrUpdateKeyValue(account.name, EncryptionUtils.MNEMONIC,
  449. generateMnemonicString());
  450. } else {
  451. throw new RuntimeException("Error uploading private key!");
  452. }
  453. }
  454. private String generateMnemonicString() {
  455. return "1 2 3 4 5 6";
  456. }
  457. public void after() {
  458. // remove all encrypted files
  459. OCFile root = fileDataStorageManager.getFileByDecryptedRemotePath("/");
  460. removeFolder(root);
  461. // List<OCFile> files = fileDataStorageManager.getFolderContent(root, false);
  462. //
  463. // for (OCFile child : files) {
  464. // removeFolder(child);
  465. // }
  466. assertEquals(0, fileDataStorageManager.getFolderContent(root, false).size());
  467. super.after();
  468. }
  469. private void removeFolder(OCFile folder) {
  470. Log_OC.d(this, "Start removing content of folder: " + folder.getDecryptedRemotePath());
  471. List<OCFile> children = fileDataStorageManager.getFolderContent(folder, false);
  472. // remove children
  473. for (OCFile child : children) {
  474. if (child.isFolder()) {
  475. removeFolder(child);
  476. // remove folder
  477. Log_OC.d(this, "Remove folder: " + child.getDecryptedRemotePath());
  478. if (!folder.isEncrypted() && child.isEncrypted()) {
  479. assertTrue(new ToggleEncryptionRemoteOperation(child.getLocalId(),
  480. child.getRemotePath(),
  481. false)
  482. .execute(client)
  483. .isSuccess());
  484. OCFile f = getStorageManager().getFileByEncryptedRemotePath(child.getRemotePath());
  485. f.setEncrypted(false);
  486. getStorageManager().saveFile(f);
  487. child.setEncrypted(false);
  488. }
  489. } else {
  490. Log_OC.d(this, "Remove file: " + child.getDecryptedRemotePath());
  491. }
  492. assertTrue(new RemoveFileOperation(child, false, user, false, targetContext, getStorageManager())
  493. .execute(client)
  494. .isSuccess()
  495. );
  496. }
  497. Log_OC.d(this, "Finished removing content of folder: " + folder.getDecryptedRemotePath());
  498. }
  499. private void verifyStoragePath(OCFile file) {
  500. assertEquals(FileStorageUtils.getSavePath(account.name) +
  501. currentFolder.getDecryptedRemotePath() +
  502. file.getDecryptedFileName(),
  503. file.getStoragePath());
  504. }
  505. }