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

Depocc existence Check #1479

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public abstract class AbstractIT {
public static OwnCloudClient client;
public static OwnCloudClient client2;
protected static NextcloudClient nextcloudClient;
protected static NextcloudClient nextcloudClient2;
protected static Context context;
protected static Uri url;

Expand Down Expand Up @@ -109,6 +110,10 @@ public static void beforeAll() throws InterruptedException,
String credentials = Credentials.basic(loginName, password);
nextcloudClient = new NextcloudClient(url, userId, credentials, context);

String userId2 = loginName; // for test same as userId
String credentials2 = Credentials.basic(loginName2, password2);
nextcloudClient2 = new NextcloudClient(url, userId2, credentials2, context);

waitForServer(client, url);
testConnection();
}
Expand Down Expand Up @@ -144,7 +149,7 @@ private static void testConnection() throws KeyStoreException,
InterruptedException {
GetStatusRemoteOperation getStatus = new GetStatusRemoteOperation(context);

RemoteOperationResult result = getStatus.execute(client);
RemoteOperationResult result = getStatus.execute(nextcloudClient);

if (result.isSuccess()) {
Log_OC.d("AbstractIT", "Connection to server successful");
Expand Down
22 changes: 11 additions & 11 deletions library/src/androidTest/java/com/owncloud/android/FileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.net.Uri;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
Expand All @@ -31,6 +27,10 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Tests related to file operations
*/
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testShareViaLinkSharees() {
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
Expand Down Expand Up @@ -167,7 +167,7 @@ public void testShareToGroupSharees() {
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
Expand Down Expand Up @@ -202,7 +202,7 @@ public void testOneSharees() {
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
Expand Down Expand Up @@ -239,15 +239,15 @@ public void testTwoShareesOnParent() {
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

assertTrue(new CreateShareRemoteOperation(path,
ShareType.USER,
"user2",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
Expand Down Expand Up @@ -287,15 +287,15 @@ public void testTwoSharees() {
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

assertTrue(new CreateShareRemoteOperation(path,
ShareType.USER,
"user2",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
.execute(nextcloudClient).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation(path).execute(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testCreatePublicShareSuccessful() {
"",
false,
"",
1).execute(client);
1).execute(client);
assertTrue(result.isSuccess());
}

Expand All @@ -67,7 +67,7 @@ public void testCreatePublicShareFailure() {
"",
false,
"",
1).execute(client);
1).execute(client);

assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
Expand All @@ -83,7 +83,7 @@ public void testCreatePrivateShareWithUserSuccessful() {
"admin",
false,
"",
31).execute(client);
31).execute(client);
assertTrue(result.isSuccess());
}

Expand All @@ -97,7 +97,7 @@ public void testCreatePrivateShareWithUserNotExists() {
"no_exist",
false,
"",
31).execute(client);
31).execute(client);
assertFalse(result.isSuccess());

// TODO 404 is File not found, but actually it is "user not found"
Expand All @@ -114,7 +114,7 @@ public void testCreatePrivateShareWithFileNotExists() {
"admin",
false,
"",
31).execute(client);
31).execute(client);
assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
}
Expand All @@ -129,7 +129,7 @@ public void testCreatePrivateShareWithGroupSuccessful() {
"admin",
false,
"",
1).execute(client);
1).execute(client);
assertTrue(result.isSuccess());
}

Expand All @@ -143,7 +143,7 @@ public void testCreatePrivateShareWithNonExistingGroupSharee() {
"no_exist",
false,
"",
31).execute(client);
31).execute(client);
assertFalse(result.isSuccess());

// TODO 404 is File not found, but actually it is "user not found"
Expand All @@ -160,7 +160,7 @@ public void testCreatePrivateShareWithNonExistingFile() {
"admin",
false,
"",
31).execute(client);
31).execute(client);
assertFalse(result.isSuccess());
assertEquals(ResultCode.FILE_NOT_FOUND, result.getCode());
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public void testCreateFederatedShareWithNonExistingSharee() {
"no_exist@" + serverUri2,
false,
"",
31).execute(client);
31).execute(client);

assertFalse("sharee doesn't exist in an existing remote server", result.isSuccess());
assertEquals("sharee doesn't exist in an existing remote server, forbidden",
Expand All @@ -206,7 +206,7 @@ public void testCreateFederatedShareWithNonExistingRemoteServer() {
"no_exist",
false,
"",
31).execute(client);
31).execute(client);
assertFalse(result.isSuccess());
// TODO expected:<SHARE_WRONG_PARAMETER> but was:<SHARE_FORBIDDEN>
assertEquals("remote server doesn't exist", ResultCode.SHARE_FORBIDDEN, result.getCode());
Expand All @@ -222,7 +222,7 @@ public void testCreateFederatedShareWithNonExistingFile() {
"admin@" + serverUri2,
false,
"",
31).execute(client);
31).execute(client);

assertFalse("file doesn't exist", result.isSuccess());
assertEquals("file doesn't exist", ResultCode.FILE_NOT_FOUND, result.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public void testGetShares() {
"",
false,
"",
1).execute(client).isSuccess());
1).execute(client).isSuccess());

assertTrue(new CreateFolderRemoteOperation("/2/", true).execute(client).isSuccess());
assertTrue(new CreateShareRemoteOperation("/2/",
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client).isSuccess());
1).execute(client).isSuccess());

RemoteOperationResult<List<OCShare>> result = new GetSharesRemoteOperation().execute(client);
assertTrue(result.isSuccess());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testRemoveShare() throws IOException {
ShareType.PUBLIC_LINK,
"",
false,
"", 1).execute(client);
"", 1).execute(client);

assertTrue(result.isSuccess());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class RenameFileRemoteOperationIT : AbstractIT() {
.isSuccess
)

assertFalse(ExistenceCheckRemoteOperation(oldRemotePath, false).execute(client).isSuccess)
assertTrue(ExistenceCheckRemoteOperation(newRemotePath, false).execute(client).isSuccess)
assertFalse(ExistenceCheckRemoteOperation(oldRemotePath, false).execute(nextcloudClient).isSuccess)
assertTrue(ExistenceCheckRemoteOperation(newRemotePath, false).execute(nextcloudClient).isSuccess)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void favoriteFiles() throws IOException {
client.getUserId(),
false,
"",
31).execute(client2)
31).execute(client2)
.isSuccess()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ public void searchSharedFiles() {

// share folder to user "admin"
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(client).isSuccess());
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(client).isSuccess());

// share folder via public link
assertTrue(new CreateShareRemoteOperation("/shareViaLink/",
ShareType.PUBLIC_LINK,
"",
true,
"",
OCShare.READ_PERMISSION_FLAG)
.execute(client).isSuccess());
ShareType.PUBLIC_LINK,
"",
true,
"",
OCShare.READ_PERMISSION_FLAG)
.execute(client).isSuccess());

// share folder to group
assertTrue(new CreateShareRemoteOperation("/shareToGroup/",
ShareType.GROUP,
"users",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
ShareType.GROUP,
"users",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());

// share folder to circle
// get share
Expand Down Expand Up @@ -169,12 +169,12 @@ public void sharedWithMe() {
// share folder to user "admin"
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(client).isSuccess());
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(client).isSuccess());

// Expect one file shared by me, no file shared with me
result = sut.execute(client);
Expand All @@ -196,12 +196,12 @@ public void sharedWithMe() {
// share folder to previous user
assertTrue(new CreateFolderRemoteOperation("/shareToUser/", true).execute(clientUser1).isSuccess());
assertTrue(new CreateShareRemoteOperation("/shareToUser/",
ShareType.USER,
client.getCredentials().getUsername(),
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(clientUser1).isSuccess());
ShareType.USER,
client.getCredentials().getUsername(),
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(clientUser1).isSuccess());

// Expect one file shared by me, one file shared with me
result = sut.execute(client);
Expand All @@ -225,7 +225,7 @@ public void favorites() {
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
true)
.execute(client);
.execute(client);

assertTrue(createResult.isSuccess());

Expand All @@ -243,7 +243,7 @@ public void favorites() {
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
true)
.execute(client);
.execute(client);

assertTrue(createResult.isSuccess());

Expand All @@ -269,7 +269,7 @@ public void noFavorite() {
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
true)
.execute(client);
.execute(client);

assertTrue(createResult.isSuccess());

Expand Down Expand Up @@ -299,7 +299,7 @@ public void favorite() {
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
true)
.execute(client);
.execute(nextcloudClient);

assertTrue(createResult.isSuccess());

Expand Down
Loading
Loading