Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to dav4jvm #881

Draft
wants to merge 78 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d265714
use dav4jvm search and proppatch
tobiasKaminsky Oct 6, 2022
e695ba1
wip
tobiasKaminsky Nov 1, 2022
dea2f70
use api instead of implementation
tobiasKaminsky Nov 3, 2022
69d68cb
add todo
tobiasKaminsky Dec 13, 2022
3a881c8
update what properties are missing
tobiasKaminsky Dec 13, 2022
111dd53
Remote operation part2
tobiasKaminsky Sep 1, 2023
05b0c66
wip
tobiasKaminsky Sep 1, 2023
534a7fd
Add oc/nc counterpart for remaining methods
ZetaTom Feb 13, 2024
0cf0355
Move to NextcloudClient and OkHttp
ZetaTom Mar 11, 2024
5d3e071
Update WebdavEntry to support ExtendedProperties
ZetaTom Mar 19, 2024
0fdefc5
Add deprecation annotations to ExtendedProperties
ZetaTom Mar 19, 2024
1e92136
Rename `toDavProp()` to `getDavProp()`
ZetaTom Mar 19, 2024
c07a95e
Update WebdavEntry.kt
ZetaTom Mar 28, 2024
30fc9ce
Fix nullability
ZetaTom Mar 28, 2024
f99ab86
Fix tests
ZetaTom Apr 8, 2024
51a33b3
Handle 204 response for RemoveFileRemoteOperation
ZetaTom Apr 8, 2024
9371022
Adjust calls to CreateFolderRemoteOperation
ZetaTom Apr 8, 2024
cce1f31
Adjust calls to ReadFileRemoteOperation
ZetaTom Apr 8, 2024
4226e82
add test to check for duplicate folder creation
tobiasKaminsky Apr 8, 2024
92d362a
Fix CreateFolderRemoteOperation
ZetaTom Apr 9, 2024
e7a7d13
Rename .java to .kt
ZetaTom Apr 9, 2024
6c3d6d1
Port CreateFolderRemoteOperation to Kotlin
ZetaTom Apr 9, 2024
8ec38a2
Add comment to DavResponse constructor
ZetaTom Apr 9, 2024
c19ec4e
Fix spotless
ZetaTom Apr 9, 2024
4395c93
Change nextcloudClient2 to use correct username
ZetaTom Apr 10, 2024
4b45b59
Adapt ExternalLinksOperation to use NextcloudClient
ZetaTom Apr 10, 2024
d62bac6
Use PropFindResult.getContent in ReadFolderRemoteOperation
ZetaTom Apr 10, 2024
8160da6
Fix DashboardGetWidgetItemsRemoteOperationIT
ZetaTom Apr 10, 2024
57281da
Adapt remote operations to use NextcloudClient
ZetaTom Apr 10, 2024
7189625
Skip ToggleFileLockRemoteOperationIT if files_lock isn't installed
ZetaTom Apr 11, 2024
f8ff979
Change return type of OCCommentsUnread to Int
ZetaTom Apr 11, 2024
9d1b3c2
Refactor path
ZetaTom Apr 11, 2024
9d40ba7
Add missing properties to WebDavFileUtils
ZetaTom Apr 11, 2024
156be2f
Manual backport of #1446
ZetaTom May 16, 2024
4720173
Fix OutOfBoundsException when parsing DisplayName
ZetaTom May 29, 2024
4c7e7a1
GetCapabilitiesRemoteOperation: use resultData instead of singleData
ZetaTom May 29, 2024
fef6ee3
ExternalLinksOperationIT: ensure that external sites app is installed
ZetaTom May 29, 2024
2ab16f1
NCSharees: fix sharee parsing
ZetaTom May 29, 2024
273d0aa
Fix lint
ZetaTom May 30, 2024
ab54918
Fix nullability
ZetaTom Jun 11, 2024
78ce99c
Only run GetUserInfoRemoteOperationIT when users are set up as expected
ZetaTom Jun 11, 2024
2d9cedf
Refactor FileIT.java:testShareViaLinkSharees()
ZetaTom Jun 11, 2024
8be47a3
Fix GetCapabilitiesRemoteOperationIT:checkCapability()
ZetaTom Jun 12, 2024
2118f82
Replace calls to ToggleEncryptionRemoteOperation
ZetaTom Jun 12, 2024
2c828ac
Adjust calls to GetTagsRemoteOperation
ZetaTom Jun 12, 2024
fe81a2d
Allow AssistantIT to be skipped
ZetaTom Jun 12, 2024
05c5762
Add SPDX headers
ZetaTom Jun 12, 2024
3ba952e
Clean up
ZetaTom Jun 17, 2024
84d8422
Fix parsing in NCSharees
ZetaTom Jun 17, 2024
cf58a58
Revert "Allow AssistantIT to be skipped"
ZetaTom Jun 17, 2024
750647d
Revert "Only run GetUserInfoRemoteOperationIT when users are set up a…
ZetaTom Jun 17, 2024
5018d40
Fix GetCapabilitiesRemoteOperationIT
ZetaTom Jun 17, 2024
0a35718
Fix GetTagsRemoteOperation
ZetaTom Jun 18, 2024
6b3920f
TEMP: use main-SNAPSHOT for dav4jvm
ZetaTom Jun 18, 2024
0081edd
NextcloudClient: set global user agent
ZetaTom Jun 18, 2024
6c10a9b
Refactor ReadFolderRemoteOperationIT
ZetaTom Jun 18, 2024
1a76a51
Fix ReadTrashbinFolderRemoteOperationIT
ZetaTom Jun 18, 2024
5b6c1ad
Adjust calls to CreateFolderRemoteOperation
ZetaTom Jun 24, 2024
f58c781
Use URLDecoder in WebDavFileUtils:parseResponse()
ZetaTom Jun 24, 2024
90da977
Fix NCHidden
ZetaTom Jun 24, 2024
e60eb5b
Refactor ToggleFavoriteRemoteOperation
ZetaTom Jun 24, 2024
04bc164
SendCSRRemoteOperation: use JSONRequestBody
ZetaTom Jun 24, 2024
dfac6f8
Fix style
ZetaTom Jun 24, 2024
9eb290c
Add remaining SPDX headers
ZetaTom Jun 24, 2024
6f63dd6
Use secure processing mode when processing XML
ZetaTom Jun 24, 2024
f269024
use snapshot for dav4jvm for now
tobiasKaminsky Jun 26, 2024
c6f4543
Rename .java to .kt
tobiasKaminsky Jun 26, 2024
4d43590
migrate to Kotlin
tobiasKaminsky Jun 26, 2024
c6a243a
wip
tobiasKaminsky Jun 26, 2024
309dcc7
satisfy detekt
tobiasKaminsky Jun 27, 2024
27ba769
wip
tobiasKaminsky Jul 1, 2024
120d6a9
wip
tobiasKaminsky Aug 16, 2024
af04878
more tests
tobiasKaminsky Aug 16, 2024
25c261a
bump dav4jvm lib
tobiasKaminsky Aug 19, 2024
fa50997
bump dav4jvm lib
tobiasKaminsky Aug 19, 2024
04eac1b
verification
tobiasKaminsky Aug 20, 2024
7611def
fix test
tobiasKaminsky Aug 20, 2024
4f7f56d
wip
tobiasKaminsky Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3662,6 +3662,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
implementation 'com.github.bitfireAT:dav4jvm:2b414984a82f57248f6d519a328e93862b471316' // TODO move to release once dav4jvm#46 is upstream and released
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation 'androidx.annotation:annotation:1.7.1'
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
Loading