Skip to content

Commit

Permalink
Revert "Backport of E2E sharing"
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky authored Jan 16, 2024
1 parent 6b81e35 commit 1af419e
Show file tree
Hide file tree
Showing 31 changed files with 216 additions and 965 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- su www-data -c "git clone -b artonge/feat/allow_metadata_update_for_subfolders https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
- su www-data -c "git clone -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/"
- su www-data -c "php /var/www/html/occ app:enable password_policy"
Expand Down Expand Up @@ -213,6 +213,6 @@ trigger:
- pull_request
---
kind: signature
hmac: 56749c47df149cc2d3c06343c609210a310e27635ea6ccb040890ab0afbce79d
hmac: 6d69c7c3739747691580d04a781eb67cf95d2f33f8149d5ebd2cbcc30611b4f0

...
4 changes: 3 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ configurations {
dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
implementation 'com.github.bitfireAT:dav4jvm:2.2.1'
// in transition phase, we use old and new libs
implementation 'com.github.bitfireAT:dav4jvm:2.2.1' // in transition phase, we use old and new libs
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation 'androidx.annotation:annotation:1.7.0'
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'

implementation "androidx.core:core-ktx:1.10.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'org.bouncycastle:bcpkix-jdk18on:1.75'

spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.2'

Expand Down
29 changes: 0 additions & 29 deletions library/lint.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
import com.owncloud.android.lib.resources.status.E2EVersion;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.NextcloudVersion;
import com.owncloud.android.lib.resources.status.OCCapability;
Expand All @@ -46,7 +44,7 @@
/**
* Class to test GetRemoteCapabilitiesOperation
*/
public class GetCapabilitiesRemoteOperationIT extends AbstractIT {
public class GetCapabilitiesIT extends AbstractIT {
/**
* Test get capabilities
*/
Expand Down Expand Up @@ -152,15 +150,12 @@ private void checkCapability(OCCapability capability, String userId) {
// groupfolder
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_27)) {
if (userId.equals("test")) {
assertTrue(capability.getGroupfolders().isTrue());
capability.getGroupfolders().isTrue();
} else {
assertTrue(capability.getGroupfolders().isFalse());
capability.getGroupfolders().isFalse();
}
} else {
assertTrue(capability.getGroupfolders().isFalse());
capability.getGroupfolders().isFalse();
}

// e2e
assertNotSame(capability.getEndToEndEncryptionApiVersion(), E2EVersion.UNKNOWN);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
/* Nextcloud Android Library is available under MIT license
/*
*
* @author Tobias Kaminsky
* Copyright (C) 2023 Tobias Kaminsky
* Copyright (C) 2023 Nextcloud GmbH
* Nextcloud Android client application
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* @author Tobias Kaminsky
* Copyright (C) 2020 Tobias Kaminsky
* Copyright (C) 2020 Nextcloud GmbH
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.owncloud.android.lib.resources.e2ee;
Expand All @@ -42,9 +37,11 @@
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.junit.Test;

public class UpdateMetadataRemoteOperationIT extends AbstractIT {
//@Test
public void uploadAndModifyV1() {
@Test
public void uploadAndModify() {
// tests only for NC19+
testOnlyOnServer(OwnCloudVersion.nextcloud_20);

Expand All @@ -69,7 +66,8 @@ public void uploadAndModifyV1() {
// Lock
String token = new LockFileRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();
.getSingleData()
.toString();
assertFalse(TextUtils.isEmpty(token));

// add metadata
Expand All @@ -82,16 +80,17 @@ public void uploadAndModifyV1() {
assertTrue(new UnlockFileRemoteOperation(remoteFolder.getLocalId(), token).execute(client).isSuccess());

// verify metadata
MetadataResponse retrievedMetadata = new GetMetadataRemoteOperation(remoteFolder.getLocalId())
String retrievedMetadata = (String) new GetMetadataRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();
.getSingleData();

assertEquals(expectedMetadata, retrievedMetadata.getMetadata());
assertEquals(expectedMetadata, retrievedMetadata);

// Lock
token = new LockFileRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();
.getSingleData()
.toString();
assertFalse(TextUtils.isEmpty(token));

// update metadata
Expand All @@ -110,88 +109,4 @@ public void uploadAndModifyV1() {

assertEquals(updatedMetadata, retrievedMetadata2);
}

//@Test
public void uploadAndModifyV2() {
// tests only for NC19+
testOnlyOnServer(OwnCloudVersion.nextcloud_20);

// E2E server app checks for official NC client with >=3.13.0,
// and blocks all other clients, e.g. 3rd party apps using this lib
OwnCloudClientManagerFactory.setUserAgent("Mozilla/5.0 (Android) Nextcloud-android/3.13.0");

// create folder
String folder = "/" + RandomStringGenerator.make(20) + "/";
assertTrue(new CreateFolderRemoteOperation(folder, true).execute(client).isSuccess());
RemoteFile remoteFolder = (RemoteFile) new ReadFileRemoteOperation(folder).execute(client).getSingleData();

assertNotNull(remoteFolder);

// mark as encrypted
assertTrue(new ToggleEncryptionRemoteOperation(remoteFolder.getLocalId(),
remoteFolder.getRemotePath(),
true)
.execute(client)
.isSuccess());

// Lock
int counter = 0;
String token = new LockFileRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();
assertFalse(TextUtils.isEmpty(token));

// add metadata
String expectedMetadata = "metadata";
String signature = "signature";

assertTrue(new StoreMetadataV2RemoteOperation(
remoteFolder.getRemoteId(),
expectedMetadata,
token,
signature)
.execute(client)
.isSuccess());

// unlock
assertTrue(new UnlockFileRemoteOperation(remoteFolder.getLocalId(), token).execute(client).isSuccess());

// verify metadata
MetadataResponse metadataResponse = new GetMetadataRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();

assertEquals(signature, metadataResponse.getSignature());
assertEquals(expectedMetadata, metadataResponse.getMetadata());

// Lock
counter += 1;
token = new LockFileRemoteOperation(remoteFolder.getLocalId(), counter)
.execute(client)
.getResultData();
assertFalse(TextUtils.isEmpty(token));

// update metadata
String updatedMetadata = "metadata2";
signature = "signature2";
assertTrue(
new UpdateMetadataV2RemoteOperation(
remoteFolder.getRemoteId(),
updatedMetadata,
token,
signature)
.execute(client)
.isSuccess());

// unlock
assertTrue(new UnlockFileRemoteOperation(remoteFolder.getLocalId(), token).execute(client).isSuccess());

// verify metadata
metadataResponse = new GetMetadataRemoteOperation(remoteFolder.getLocalId())
.execute(client)
.getResultData();

assertEquals(signature, metadataResponse.getSignature());
assertEquals(updatedMetadata, metadataResponse.getMetadata());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.Request
import okhttp3.Response
import java.io.IOException
import java.net.HttpURLConnection

/**
* Common base class for all new OkHttpMethods
Expand Down Expand Up @@ -185,8 +184,4 @@ abstract class OkHttpMethodBase(
}

abstract fun applyType(temp: Request.Builder)

fun isSuccess(): Boolean {
return getStatusCode() == HttpURLConnection.HTTP_OK
}
}
Loading

0 comments on commit 1af419e

Please sign in to comment.