From: masensio Date: Fri, 15 Nov 2013 13:41:06 +0000 (+0100) Subject: OC-1991: Add more cases in rename file / folder tests X-Git-Tag: oc-android-1.5.5~123^2~6 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/6e092bf23512a87556898acd10a6cb20b5414319 OC-1991: Add more cases in rename file / folder tests --- diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java index 5f847476..90c59bb4 100644 --- a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java @@ -56,7 +56,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testCreateFolderSpecialCharacters() { boolean createFullPath = true; diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java index 119d160f..015565c6 100644 --- a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java @@ -1,7 +1,10 @@ package com.owncloud.android.oc_framework_test_project.test; +import java.io.File; + import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.utils.FileUtils; import com.owncloud.android.oc_framework_test_project.TestActivity; import android.test.ActivityInstrumentationTestCase2; @@ -12,17 +15,14 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testRenameFolderForbiddenChars() { RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath, - mNewFolderNameInvalidChars, mNewFolderPathInvalidChars); + mNewFolderName + "//", mNewFolderPath + "//" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "\\", mNewFolderPath + "\\" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "<", mNewFolderPath + "<" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + ">", mNewFolderPath + ">" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + ":", mNewFolderPath + ":" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "\"", mNewFolderPath + "\"" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "|", mNewFolderPath + "|" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "?", mNewFolderPath + "?" + FileUtils.PATH_SEPARATOR); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "*", mNewFolderPath + "*" + FileUtils.PATH_SEPARATOR); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); } @@ -62,18 +95,52 @@ public class RenameFileTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testRenameFileForbiddenChars() { RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath, - mNewFileNameInvalidChars, mNewFilePathInvalidChars); + mNewFileName + "//" + mFileExtension, mNewFilePath + "//" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "\\" + mFileExtension, mNewFilePath + "\\" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "<" + mFileExtension, mNewFilePath + "<" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + ">" + mFileExtension, mNewFilePath + ">" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + ":" + mFileExtension, mNewFilePath + ":" + mFileExtension); assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "\"" + mFileExtension, mNewFilePath + "\"" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "|" + mFileExtension, mNewFilePath + "|" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "?" + mFileExtension, mNewFilePath + "?" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "*" + mFileExtension, mNewFilePath + "*" + mFileExtension); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + } diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 7df78bd4..5cf1bb6e 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -58,8 +58,8 @@ public class TestActivity extends Activity { // am.setUserData(mAccount, "oc_version", "5.0.14"); // am.setUserData(mAccount, "oc_base_url", "http://beta.owncloud.com/owncloud"); // } else { - Log.d(TAG, "oc_version --->"+ am.getUserData(mAccount, "oc_version") ); - Log.d(TAG, "oc_base_url --->"+ am.getUserData(mAccount, "oc_base_url") ); +// Log.d(TAG, "oc_version --->"+ am.getUserData(mAccount, "oc_version") ); +// Log.d(TAG, "oc_base_url --->"+ am.getUserData(mAccount, "oc_base_url") ); // } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java b/oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java index 5c41edb0..0c0c2072 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java @@ -78,8 +78,8 @@ public class OwnCloudClientFactory { } else { String username = account.name.substring(0, account.name.lastIndexOf('@')); - //String password = am.getPassword(account); - String password = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypePass(account.type), false); + String password = am.getPassword(account); + //String password = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypePass(account.type), false); client.setBasicCredentials(username, password); }