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

verify that modification date is not tampered #6496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions src/androidTest/java/com/owncloud/android/UploadIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.owncloud.android.db.OCUpload;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.UploadFileOperation;
Expand All @@ -38,8 +40,14 @@
import org.junit.After;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;

import androidx.annotation.NonNull;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;

Expand Down Expand Up @@ -310,4 +318,23 @@ public void testUploadOnWifiOnlyAndWifi() {
targetContext)
.execute(client, getStorageManager());
}

@Test
public void testUploadSameModificationDate() throws IOException {
File file = new File(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt");
BasicFileAttributes attributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
long modifiedDate = attributes.lastModifiedTime().toMillis();

OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
FOLDER + "nonEmpty.txt",
account.name);

shortSleep();
uploadOCUpload(ocUpload);

RemoteOperationResult readFileResult = new ReadFileRemoteOperation(FOLDER + "nonEmpty.txt").execute(client);
RemoteFile remoteFile = (RemoteFile) readFileResult.getData().get(0);

assertEquals(modifiedDate, remoteFile.getModifiedTimestamp());
}
}