Skip to content

Commit

Permalink
use dav4jvm search and proppatch
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky committed Oct 30, 2024
1 parent 3ec02eb commit 017ae9d
Show file tree
Hide file tree
Showing 144 changed files with 4,721 additions and 2,697 deletions.
24 changes: 24 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,30 @@
</sha256>
</artifact>
</component>
<component group="com.github.bitfireAT" name="dav4jvm" version="2b414984a82f57248f6d519a328e93862b471316">
<artifact name="dav4jvm-2b414984a82f57248f6d519a328e93862b471316.jar">
<sha256 value="997da50a0c2a9b9f3eb465bc4638ae2cd038140280485c040bfeab31f0cea205" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="dav4jvm-2b414984a82f57248f6d519a328e93862b471316.module">
<sha256 value="4c534cfe4abe03386cd004e9fe419fd444da7ad37fa15251751d6b94d3545ac8" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.bitfireAT" name="dav4jvm" version="b8be778">
<artifact name="dav4jvm-b8be778.jar">
<sha256 value="f65d8d62b60af85360b3a998e86844d8f9a4f01f182fcc61ca47619aa3520658" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="dav4jvm-b8be778.module">
<sha256 value="dcada32bc5e01a4851d9fac98daae4c4080daa9307febb0b7898e241133c66c8" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.bitfireAT" name="dav4jvm" version="c1bc143488">
<artifact name="dav4jvm-c1bc143488.jar">
<sha256 value="a54377987c9ff260cc5d1296739a268bebb59f38bfb2936c2411471f1445d339" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="dav4jvm-c1bc143488.module">
<sha256 value="0b8662b56af6a1e7b22db91bd39db2d16c9e0d00c11f978395a997dda007b788" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.google" name="google" version="1">
<artifact name="google-1.pom">
<sha256 value="cd6db17a11a31ede794ccbd1df0e4d9750f640234731f21cff885a9997277e81" origin="Generated by Gradle" reason="Artifact is not signed"/>
Expand Down
3 changes: 1 addition & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ configurations {
dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
implementation 'com.github.bitfireAT:dav4jvm:2.2.1'
// in transition phase, we use old and new libs
api 'com.github.bitfireAT:dav4jvm:2b414984a82f57248f6d519a328e93862b471316' // in transition phase, we use old and new libs
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
implementation 'androidx.annotation:annotation:1.9.0'
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package com.nextcloud.android.lib.resources.dashboard

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation
import com.owncloud.android.lib.resources.shares.OCShare
import com.owncloud.android.lib.resources.shares.ShareType
Expand All @@ -22,11 +23,13 @@ class DashboardGetWidgetItemsRemoteOperationIT : AbstractIT() {
// only on NC25+
testOnlyOnServer(NextcloudVersion.nextcloud_25)

val folderPath = "/testFolder"

// create folder to have some content
assertTrue(CreateFolderRemoteOperation("/testFolder", false).execute(client2).isSuccess)
assertTrue(CreateFolderRemoteOperation(folderPath, false).execute(nextcloudClient2).isSuccess)
assertTrue(
CreateShareRemoteOperation(
"/testFolder",
folderPath,
ShareType.USER,
client.userId,
false,
Expand All @@ -37,17 +40,19 @@ class DashboardGetWidgetItemsRemoteOperationIT : AbstractIT() {
)

val widgetId = "activity"
val result =
DashboardGetWidgetItemsRemoteOperation(widgetId, LIMIT_SIZE).execute(nextcloudClient)
val result = DashboardGetWidgetItemsRemoteOperation(widgetId, LIMIT_SIZE).execute(nextcloudClient)

assertTrue(result.isSuccess)
assertTrue(result.resultData[widgetId]?.isNotEmpty() ?: false)
assertTrue(result.resultData?.get(widgetId)?.isNotEmpty() ?: false)

val firstResult = result.resultData[widgetId]?.get(0)
val firstResult = result.resultData?.get(widgetId)?.get(0)
assertTrue(firstResult?.title?.isNotEmpty() == true)
assertTrue(firstResult?.subtitle != null)
assertTrue(firstResult?.link?.isNotEmpty() == true)
assertTrue(firstResult?.iconUrl?.isNotEmpty() == true)

// remove folder
assertTrue(RemoveFileRemoteOperation(folderPath).execute(nextcloudClient2).isSuccess)
}

@Test
Expand All @@ -57,7 +62,7 @@ class DashboardGetWidgetItemsRemoteOperationIT : AbstractIT() {
DashboardGetWidgetItemsRemoteOperation(widgetId, LIMIT_SIZE).execute(nextcloudClient)

assertTrue(result.isSuccess)
assertTrue(result.resultData.isEmpty())
assertTrue(result.resultData?.isEmpty() ?: false)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class DashboardListWidgetsRemoteOperationIT : AbstractIT() {
val result = DashboardListWidgetsRemoteOperation().execute(nextcloudClient)
assertTrue(result.isSuccess)

assertTrue(result.resultData.isNotEmpty())
assertTrue(result.resultData?.isNotEmpty() ?: false)

assertTrue(result.resultData["recommendations"]?.buttons?.getOrNull(0) == null)
assertTrue(result.resultData?.get("recommendations")?.buttons?.getOrNull(0) == null)

assertEquals(1, result.resultData["activity"]?.buttons?.size)
assertTrue(result.resultData["activity"]?.buttons?.getOrNull(0)?.type == DashBoardButtonType.MORE)
assertTrue(result.resultData["activity"]?.roundIcons == false)
assertEquals(1, result.resultData?.get("activity")?.buttons?.size)
assertTrue(result.resultData?.get("activity")?.buttons?.getOrNull(0)?.type == DashBoardButtonType.MORE)
assertTrue(result.resultData?.get("activity")?.roundIcons == false)

assertTrue(result.resultData["user_status"]?.roundIcons == true)
assertTrue(result.resultData?.get("user_status")?.roundIcons == true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class DirectEditingObtainRemoteOperationIT : AbstractIT() {
fun testGetAll() {
val result = DirectEditingObtainRemoteOperation().run(nextcloudClient)
assertTrue(result.isSuccess)
assertNotNull(result.resultData)

val (editors, creators) = result.resultData
val (editors, creators) = result.resultData!!
assertTrue(editors.containsKey("text"))

val textEditor = editors["text"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void openFile() throws IOException {
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());
TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(nextcloudClient).isSuccess());

// open file
RemoteOperationResult<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
Expand All @@ -58,7 +58,7 @@ public void openFileWithSpecialChars() throws IOException {
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());
TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(nextcloudClient).isSuccess());

// open file
RemoteOperationResult<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
Expand All @@ -82,7 +82,7 @@ public void openFileWithSpecialChars2() throws IOException {
1464818400
).execute(client).isSuccess());

TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());
TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(nextcloudClient).isSuccess());

// open file
RemoteOperationResult<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
Expand All @@ -98,7 +98,7 @@ public void openFileWithSpecialChars2() throws IOException {
public void openNonExistingFile() {
String remotePath = "/nonExisting.md";

TestCase.assertFalse(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess());
TestCase.assertFalse(new ReadFileRemoteOperation(remotePath).execute(nextcloudClient).isSuccess());

// open file
RemoteOperationResult<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.FileLockType
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.lib.resources.status.NextcloudVersion.Companion.nextcloud_24
import okhttp3.internal.http.HTTP_NOT_IMPLEMENTED
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assume.assumeTrue
import org.junit.Test

class ToggleFileLockRemoteOperationIT : AbstractIT() {
Expand All @@ -32,21 +34,24 @@ class ToggleFileLockRemoteOperationIT : AbstractIT() {
UploadFileRemoteOperation(filePath, remotePath, "text/markdown", 1464818400)
.execute(client).isSuccess
)
val initialFile =
ReadFileRemoteOperation(remotePath).execute(client).singleData as RemoteFile
val initialFile = ReadFileRemoteOperation(remotePath).execute(nextcloudClient).resultData as RemoteFile
assertFalse("File shouldn't be locked", initialFile.isLocked)

// lock file
val lockResult = ToggleFileLockRemoteOperation(toLock = true, remotePath).execute(nextcloudClient)

// check if file locking is enabled (files_lock app needs to be installed)
assumeTrue(lockResult.httpCode != HTTP_NOT_IMPLEMENTED)

assertTrue("File lock failed", lockResult.isSuccess)
val lockFile = ReadFileRemoteOperation(remotePath).execute(client).singleData as RemoteFile
val lockFile = ReadFileRemoteOperation(remotePath).execute(nextcloudClient).resultData as RemoteFile
assertTrue("File should be locked", lockFile.isLocked)
assertEquals("Wrong lock type", FileLockType.MANUAL, lockFile.lockType)

// unlock again
val unlockResult = ToggleFileLockRemoteOperation(toLock = false, remotePath).execute(nextcloudClient)
assertTrue("File unlock failed", unlockResult.isSuccess)
val unlockFile = ReadFileRemoteOperation(remotePath).execute(client).singleData as RemoteFile
val unlockFile = ReadFileRemoteOperation(remotePath).execute(nextcloudClient).resultData as RemoteFile
assertFalse("File shouldn't be locked", unlockFile.isLocked)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ package com.nextcloud.android.lib.resources.groupfolders

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation
import com.owncloud.android.lib.resources.status.OCCapability
import org.junit.Assert.assertEquals
import org.junit.Assume.assumeTrue
import org.junit.Test

class GetGroupfoldersRemoteOperationIT : AbstractIT() {
@Test
fun getGroupfolders() {
val capability = GetCapabilitiesRemoteOperation().execute(client).singleData as OCCapability
val capability = GetCapabilitiesRemoteOperation().execute(nextcloudClient).resultData

assumeTrue(capability.groupfolders.isTrue)
assumeTrue(capability?.groupfolders?.isTrue == true)

val map = GetGroupfoldersRemoteOperation().execute(nextcloudClient).resultData
assertEquals(1, map.size)
assertEquals("groupfolder", map["1"]?.mountPoint)
assertEquals(1, map?.size)
assertEquals("groupfolder", map?.get("1")?.mountPoint)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package com.nextcloud.android.lib.resources.search

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation
import com.owncloud.android.lib.resources.status.OCCapability
import com.owncloud.android.lib.resources.status.OwnCloudVersion
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
Expand All @@ -28,22 +27,18 @@ class SearchProvidersRemoteOperationIT : AbstractIT() {
assertTrue(result.isSuccess)

val providers = result.resultData

assertTrue(providers.eTag.isNotBlank())
assertTrue(providers.providers.isNotEmpty())
assertNotNull(providers.providers.find { it.name == "Files" })
assertNull(providers.providers.find { it.name == "RandomSearchProvider" })
assertTrue(providers?.eTag?.isNotBlank() == true)
assertNotNull(providers?.providers)
assertTrue(providers?.providers?.isNotEmpty() == true)
assertNotNull(providers?.providers?.find { it.name == "Files" })
assertNull(providers?.providers?.find { it.name == "RandomSearchProvider" })
}

@Test
fun getSearchProvidersOnOldServer() {
// only on < NC20
val ocCapability =
GetCapabilitiesRemoteOperation()
.execute(nextcloudClient).singleData as OCCapability
assumeTrue(
ocCapability.version.isOlderThan(OwnCloudVersion.nextcloud_20)
)
val ocCapability = GetCapabilitiesRemoteOperation().execute(nextcloudClient).resultData
assumeTrue(ocCapability?.version?.isOlderThan(OwnCloudVersion.nextcloud_20) == true)

val result = nextcloudClient.execute(UnifiedSearchProvidersRemoteOperation())
assertFalse(result.isSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package com.nextcloud.android.lib.resources.search
import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.RemoteFile
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
Expand All @@ -36,28 +35,25 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {
fun filesSearchEmptyResult() {
val result = UnifiedSearchRemoteOperation("files", "test").execute(nextcloudClient)
assertTrue(result.isSuccess)

val data = result.resultData
assertTrue(data.entries.isEmpty())
assertNotNull(result.resultData)
assertTrue(result.resultData?.entries?.isEmpty() == true)
}

@Test
fun filesSearch() {
val remotePath = "/testFolder"
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(client).isSuccess)
val remoteFile =
ReadFileRemoteOperation(remotePath)
.execute(client).data[0] as RemoteFile
val fileId = remoteFile.localId
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient).isSuccess)
val remoteFile = ReadFileRemoteOperation(remotePath).execute(nextcloudClient).resultData
val fileId = remoteFile?.localId

val result = UnifiedSearchRemoteOperation("files", "test").execute(nextcloudClient)
assertTrue(result.isSuccess)

val data = result.resultData
assertEquals("Files", data.name)
assertTrue(data.entries.isNotEmpty())
assertEquals("Files", data?.name)
assertTrue(data?.entries?.isNotEmpty() == true)

val firstResult = data.entries.find { it.title == "testFolder" }
val firstResult = data?.entries?.find { it.title == "testFolder" }

assertNotNull(firstResult)
assertEquals(remotePath, firstResult?.remotePath())
Expand All @@ -66,14 +62,14 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {

@Test
fun filesSearchWhitespace() {
assertTrue(CreateFolderRemoteOperation("/test Folder/", true).execute(client).isSuccess)
assertTrue(CreateFolderRemoteOperation("/test Folder/", true).execute(nextcloudClient).isSuccess)

val result = UnifiedSearchRemoteOperation("files", "test").execute(nextcloudClient)
assertTrue(result.isSuccess)

val data = result.resultData
assertTrue(data.name == "Files")
assertTrue(data.entries.isNotEmpty())
assertNotNull(data.entries.find { it.title == "test Folder" })
assertTrue(data?.name == "Files")
assertTrue(data?.entries?.isNotEmpty() == true)
assertNotNull(data?.entries?.find { it.title == "test Folder" })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,35 @@
import android.text.TextUtils;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.OwnCloudBasicCredentials;
import com.owncloud.android.lib.common.OwnCloudCredentials;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;

import org.junit.Test;

import okhttp3.Credentials;

public class GenerateAppPasswordRemoteOperationIT extends AbstractIT {

@Test
public void generateAppPassword() {
GenerateAppPasswordRemoteOperation sut = new GenerateAppPasswordRemoteOperation();
RemoteOperationResult result = sut.execute(client);
RemoteOperationResult<String> result = sut.execute(nextcloudClient);

assertTrue(result.isSuccess());

String appPassword = (String) result.getSingleData();
String appPassword = result.getResultData();
assertFalse(TextUtils.isEmpty(appPassword));

OwnCloudCredentials oldOwnCloudCredentials = client.getCredentials();
OwnCloudCredentials newOwnCloudCredentials = new OwnCloudBasicCredentials(oldOwnCloudCredentials.getUsername(),
appPassword);
String clientCredentials = nextcloudClient.getCredentials();
String newClientCredentials = Credentials.basic(nextcloudClient.getUserId(), appPassword);

assertNotEquals(oldOwnCloudCredentials, newOwnCloudCredentials);
assertNotEquals(clientCredentials, newClientCredentials);

client.setCredentials(newOwnCloudCredentials);
nextcloudClient.setCredentials(newClientCredentials);

assertTrue(new ReadFolderRemoteOperation("/").execute(client).isSuccess());
assertTrue(new ReadFolderRemoteOperation("/").execute(nextcloudClient).isSuccess());

// using app password to generate new password should fail
assertFalse(new GenerateAppPasswordRemoteOperation().execute(client).isSuccess());
assertFalse(new GenerateAppPasswordRemoteOperation().execute(nextcloudClient).isSuccess());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void getEditLinkForRoot() {
public void getEditLinkForFolder() {
String path = "/workspace/sub1/";

assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation(path, true).execute(nextcloudClient).isSuccess());

RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(path).execute(client);
assertTrue(result.isSuccess());
Expand All @@ -56,7 +56,7 @@ public void reuseExistingFile() throws IOException {
String filePath = folder + "Readme.md";
File txtFile = getFile(ASSETS__TEXT_FILE_NAME);

assertTrue(new CreateFolderRemoteOperation(folder, true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation(folder, true).execute(nextcloudClient).isSuccess());

RemoteOperationResult uploadResult = new UploadFileRemoteOperation(
txtFile.getAbsolutePath(),
Expand Down
Loading

0 comments on commit 017ae9d

Please sign in to comment.