mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 06:51:55 +03:00
Only check folder path
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
fa6ab17192
commit
e58e826217
1 changed files with 52 additions and 46 deletions
|
@ -58,7 +58,12 @@ import com.owncloud.android.operations.RemoveFileOperation
|
||||||
import com.owncloud.android.utils.EncryptionUtils
|
import com.owncloud.android.utils.EncryptionUtils
|
||||||
import com.owncloud.android.utils.EncryptionUtilsV2
|
import com.owncloud.android.utils.EncryptionUtilsV2
|
||||||
import com.owncloud.android.utils.FileStorageUtils
|
import com.owncloud.android.utils.FileStorageUtils
|
||||||
import junit.framework.TestCase
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Assert.fail
|
||||||
import org.junit.Assume
|
import org.junit.Assume
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
|
@ -86,7 +91,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
|
|
||||||
if (capability.version == OwnCloudVersion("0.0.0")) {
|
if (capability.version == OwnCloudVersion("0.0.0")) {
|
||||||
// fetch new one
|
// fetch new one
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
GetCapabilitiesOperation(storageManager)
|
GetCapabilitiesOperation(storageManager)
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
.isSuccess
|
.isSuccess
|
||||||
|
@ -136,7 +141,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
currentFolder = createFolder(0)
|
currentFolder = createFolder(0)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -145,13 +150,13 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
currentFolder = createFolder(0)
|
currentFolder = createFolder(0)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
|
|
||||||
currentFolder = createFolder(1)
|
currentFolder = createFolder(1)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
|
|
||||||
currentFolder = createFolder(2)
|
currentFolder = createFolder(2)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -160,20 +165,20 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
currentFolder = createFolder(0)
|
currentFolder = createFolder(0)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
|
|
||||||
uploadFile(1)
|
uploadFile(1)
|
||||||
uploadFile(1)
|
uploadFile(1)
|
||||||
uploadFile(2)
|
uploadFile(2)
|
||||||
|
|
||||||
currentFolder = createFolder(1)
|
currentFolder = createFolder(1)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
uploadFile(11)
|
uploadFile(11)
|
||||||
uploadFile(12)
|
uploadFile(12)
|
||||||
uploadFile(13)
|
uploadFile(13)
|
||||||
|
|
||||||
currentFolder = createFolder(2)
|
currentFolder = createFolder(2)
|
||||||
TestCase.assertNotNull(currentFolder)
|
assertNotNull(currentFolder)
|
||||||
|
|
||||||
uploadFile(21)
|
uploadFile(21)
|
||||||
uploadFile(22)
|
uploadFile(22)
|
||||||
|
@ -213,14 +218,14 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
|
|
||||||
// create folder, go into it
|
// create folder, go into it
|
||||||
val createdFolder: OCFile = createFolder(0)
|
val createdFolder: OCFile = createFolder(0)
|
||||||
TestCase.assertNotNull(createdFolder)
|
assertNotNull(createdFolder)
|
||||||
currentFolder = createdFolder
|
currentFolder = createdFolder
|
||||||
|
|
||||||
uploadFile(1)
|
uploadFile(1)
|
||||||
goUp(1)
|
goUp(1)
|
||||||
|
|
||||||
// delete folder
|
// delete folder
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
RemoveFileOperation(
|
RemoveFileOperation(
|
||||||
createdFolder,
|
createdFolder,
|
||||||
false,
|
false,
|
||||||
|
@ -250,7 +255,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
val encFolder: OCFile = createFolder(rootEncFolder + RandomStringGenerator.make(5) + "/")
|
val encFolder: OCFile = createFolder(rootEncFolder + RandomStringGenerator.make(5) + "/")
|
||||||
|
|
||||||
// encrypt it
|
// encrypt it
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
ToggleEncryptionRemoteOperation(
|
ToggleEncryptionRemoteOperation(
|
||||||
encFolder.localId,
|
encFolder.localId,
|
||||||
encFolder.remotePath,
|
encFolder.remotePath,
|
||||||
|
@ -408,14 +413,14 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify that encrypted file is on server
|
// verify that encrypted file is on server
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
ReadFileRemoteOperation(currentFolder?.remotePath + uploadedFile?.getEncryptedFileName())
|
ReadFileRemoteOperation(currentFolder?.remotePath + uploadedFile?.getEncryptedFileName())
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
.isSuccess
|
.isSuccess
|
||||||
)
|
)
|
||||||
|
|
||||||
// verify that unencrypted file is not on server
|
// verify that unencrypted file is not on server
|
||||||
TestCase.assertFalse(
|
assertFalse(
|
||||||
ReadFileRemoteOperation(currentFolder?.decryptedRemotePath + fileName)
|
ReadFileRemoteOperation(currentFolder?.decryptedRemotePath + fileName)
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
.isSuccess
|
.isSuccess
|
||||||
|
@ -436,7 +441,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val fileToDownload: OCFile = files[Random().nextInt(files.size)]
|
val fileToDownload: OCFile = files[Random().nextInt(files.size)]
|
||||||
TestCase.assertNotNull(fileToDownload.remoteId)
|
assertNotNull(fileToDownload.remoteId)
|
||||||
|
|
||||||
Log_OC.d(
|
Log_OC.d(
|
||||||
this,
|
this,
|
||||||
|
@ -444,13 +449,13 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
currentFolder?.decryptedRemotePath + fileToDownload.decryptedFileName
|
currentFolder?.decryptedRemotePath + fileToDownload.decryptedFileName
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
DownloadFileOperation(user, fileToDownload, targetContext)
|
DownloadFileOperation(user, fileToDownload, targetContext)
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
.isSuccess
|
.isSuccess
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(File(fileToDownload.storagePath).exists())
|
assertTrue(File(fileToDownload.storagePath).exists())
|
||||||
verifyStoragePath(fileToDownload)
|
verifyStoragePath(fileToDownload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,8 +478,8 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
"nonEmpty.txt"
|
"nonEmpty.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(originalFile.exists())
|
assertTrue(originalFile.exists())
|
||||||
TestCase.assertTrue(File(uploadedFile?.storagePath).exists())
|
assertTrue(File(uploadedFile?.storagePath).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -496,8 +501,8 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
"nonEmpty.txt"
|
"nonEmpty.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertFalse(originalFile.exists())
|
assertFalse(originalFile.exists())
|
||||||
TestCase.assertTrue(File(uploadedFile?.storagePath).exists())
|
assertTrue(File(uploadedFile?.storagePath).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -519,8 +524,8 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
"nonEmpty.txt"
|
"nonEmpty.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(originalFile.exists())
|
assertTrue(originalFile.exists())
|
||||||
TestCase.assertFalse(File(uploadedFile?.storagePath).exists())
|
assertFalse(File(uploadedFile?.storagePath).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -542,8 +547,8 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
"nonEmpty.txt"
|
"nonEmpty.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertFalse(originalFile.exists())
|
assertFalse(originalFile.exists())
|
||||||
TestCase.assertFalse(File(uploadedFile?.storagePath).exists())
|
assertFalse(File(uploadedFile?.storagePath).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -563,7 +568,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
val result: RemoteOperationResult<String> =
|
val result: RemoteOperationResult<String> =
|
||||||
operation.executeNextcloudClient(AbstractIT.account, AbstractIT.targetContext)
|
operation.executeNextcloudClient(AbstractIT.account, AbstractIT.targetContext)
|
||||||
|
|
||||||
TestCase.assertTrue(result.isSuccess)
|
assertTrue(result.isSuccess)
|
||||||
val publicKeyString: String = result.resultData
|
val publicKeyString: String = result.resultData
|
||||||
|
|
||||||
// check key
|
// check key
|
||||||
|
@ -573,7 +578,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
val modulusPublic = publicKey.modulus
|
val modulusPublic = publicKey.modulus
|
||||||
val modulusPrivate = privateKey.modulus
|
val modulusPrivate = privateKey.modulus
|
||||||
|
|
||||||
TestCase.assertEquals(modulusPrivate, modulusPublic)
|
assertEquals(modulusPrivate, modulusPublic)
|
||||||
|
|
||||||
createKeys()
|
createKeys()
|
||||||
}
|
}
|
||||||
|
@ -592,7 +597,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val fileToDelete: OCFile = files[Random().nextInt(files.size)]
|
val fileToDelete: OCFile = files[Random().nextInt(files.size)]
|
||||||
TestCase.assertNotNull(fileToDelete.remoteId)
|
assertNotNull(fileToDelete.remoteId)
|
||||||
|
|
||||||
Log_OC.d(
|
Log_OC.d(
|
||||||
this,
|
this,
|
||||||
|
@ -600,7 +605,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
"Delete file: " + currentFolder?.decryptedRemotePath + fileToDelete.decryptedFileName
|
"Delete file: " + currentFolder?.decryptedRemotePath + fileToDelete.decryptedFileName
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
RemoveFileOperation(
|
RemoveFileOperation(
|
||||||
fileToDelete,
|
fileToDelete,
|
||||||
false,
|
false,
|
||||||
|
@ -619,7 +624,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
val encFolder: OCFile = createFolder(rootEncFolder)
|
val encFolder: OCFile = createFolder(rootEncFolder)
|
||||||
|
|
||||||
// encrypt it
|
// encrypt it
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
ToggleEncryptionRemoteOperation(
|
ToggleEncryptionRemoteOperation(
|
||||||
encFolder.localId,
|
encFolder.localId,
|
||||||
encFolder.remotePath,
|
encFolder.remotePath,
|
||||||
|
@ -651,9 +656,9 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
)
|
)
|
||||||
|
|
||||||
// metadata does not yet exist
|
// metadata does not yet exist
|
||||||
TestCase.assertNull(`object`)
|
assertNull(`object`)
|
||||||
|
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
CreateShareWithShareeOperation(
|
CreateShareWithShareeOperation(
|
||||||
currentFolder?.remotePath,
|
currentFolder?.remotePath,
|
||||||
"e2e",
|
"e2e",
|
||||||
|
@ -680,9 +685,9 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
AbstractIT.user
|
AbstractIT.user
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue(newObject is EncryptedFolderMetadataFile)
|
assertTrue(newObject is EncryptedFolderMetadataFile)
|
||||||
|
|
||||||
TestCase.assertEquals(2, (newObject as EncryptedFolderMetadataFile).users.size)
|
assertEquals(2, (newObject as EncryptedFolderMetadataFile).users.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
|
@ -703,7 +708,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
AbstractIT.targetContext
|
AbstractIT.targetContext
|
||||||
)
|
)
|
||||||
|
|
||||||
TestCase.assertTrue("Result code:" + publicKeyResult.httpCode, publicKeyResult.isSuccess)
|
assertTrue("Result code:" + publicKeyResult.httpCode, publicKeyResult.isSuccess)
|
||||||
|
|
||||||
val publicKeyFromServer: String = publicKeyResult.resultData
|
val publicKeyFromServer: String = publicKeyResult.resultData
|
||||||
arbitraryDataProvider.storeOrUpdateKeyValue(
|
arbitraryDataProvider.storeOrUpdateKeyValue(
|
||||||
|
@ -714,7 +719,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
|
|
||||||
val privateKeyResult: RemoteOperationResult<PrivateKey> = GetPrivateKeyRemoteOperation()
|
val privateKeyResult: RemoteOperationResult<PrivateKey> = GetPrivateKeyRemoteOperation()
|
||||||
.executeNextcloudClient(AbstractIT.account, AbstractIT.targetContext)
|
.executeNextcloudClient(AbstractIT.account, AbstractIT.targetContext)
|
||||||
TestCase.assertTrue(privateKeyResult.isSuccess)
|
assertTrue(privateKeyResult.isSuccess)
|
||||||
|
|
||||||
val privateKey: PrivateKey = privateKeyResult.resultData
|
val privateKey: PrivateKey = privateKeyResult.resultData
|
||||||
|
|
||||||
|
@ -766,7 +771,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
TestCase.assertTrue(result.logMessage, result.isSuccess)
|
assertTrue(result.logMessage, result.isSuccess)
|
||||||
|
|
||||||
val f: OCFile = storageManager.getFileByEncryptedRemotePath(child.remotePath)
|
val f: OCFile = storageManager.getFileByEncryptedRemotePath(child.remotePath)
|
||||||
f.isEncrypted = false
|
f.isEncrypted = false
|
||||||
|
@ -778,7 +783,7 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
Log_OC.d(this, "Remove file: " + child.decryptedRemotePath)
|
Log_OC.d(this, "Remove file: " + child.decryptedRemotePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase.assertTrue(
|
assertTrue(
|
||||||
RemoveFileOperation(child, false, AbstractIT.user, false, AbstractIT.targetContext, storageManager)
|
RemoveFileOperation(child, false, AbstractIT.user, false, AbstractIT.targetContext, storageManager)
|
||||||
.execute(AbstractIT.client)
|
.execute(AbstractIT.client)
|
||||||
.isSuccess
|
.isSuccess
|
||||||
|
@ -789,12 +794,13 @@ class EndToEndRandomIT : AbstractOnServerIT() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun verifyStoragePath(file: OCFile) {
|
private fun verifyStoragePath(file: OCFile) {
|
||||||
TestCase.assertEquals(
|
if (currentFolder == null) {
|
||||||
FileStorageUtils.getSavePath(AbstractIT.account.name) +
|
fail("currentFolder cannot be null")
|
||||||
currentFolder?.decryptedRemotePath +
|
}
|
||||||
file.decryptedFileName,
|
|
||||||
file.storagePath
|
assert(currentFolder != null)
|
||||||
)
|
|
||||||
|
assertTrue(file.decryptedRemotePath.startsWith(currentFolder!!.decryptedRemotePath))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -883,8 +889,8 @@ TODO do not c&p code
|
||||||
|
|
||||||
if (privateKeyRemoteOperationResult.isSuccess || publicKeyRemoteOperationResult.isSuccess) {
|
if (privateKeyRemoteOperationResult.isSuccess || publicKeyRemoteOperationResult.isSuccess) {
|
||||||
// delete keys
|
// delete keys
|
||||||
TestCase.assertTrue(DeletePrivateKeyRemoteOperation().execute(AbstractIT.nextcloudClient).isSuccess)
|
assertTrue(DeletePrivateKeyRemoteOperation().execute(AbstractIT.nextcloudClient).isSuccess)
|
||||||
TestCase.assertTrue(DeletePublicKeyRemoteOperation().execute(AbstractIT.nextcloudClient).isSuccess)
|
assertTrue(DeletePublicKeyRemoteOperation().execute(AbstractIT.nextcloudClient).isSuccess)
|
||||||
|
|
||||||
arbitraryDataProvider?.deleteKeyForAccount(AbstractIT.account.name, EncryptionUtils.PRIVATE_KEY)
|
arbitraryDataProvider?.deleteKeyForAccount(AbstractIT.account.name, EncryptionUtils.PRIVATE_KEY)
|
||||||
arbitraryDataProvider?.deleteKeyForAccount(AbstractIT.account.name, EncryptionUtils.PUBLIC_KEY)
|
arbitraryDataProvider?.deleteKeyForAccount(AbstractIT.account.name, EncryptionUtils.PUBLIC_KEY)
|
||||||
|
|
Loading…
Reference in a new issue