mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Update public share tests and refactored publicUpload permission handling
This commit is contained in:
		
							parent
							
								
									5c68c3f605
								
							
						
					
					
						commit
						57aa370be0
					
				| @ -86,7 +86,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation { | |||||||
|     /** |     /** | ||||||
|      * Upload permissions for the public link (only folders) |      * Upload permissions for the public link (only folders) | ||||||
|      */ |      */ | ||||||
|     private boolean mPublicUpload; |     private Boolean mPublicUpload; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -98,7 +98,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation { | |||||||
|         mRemoteId = remoteId; |         mRemoteId = remoteId; | ||||||
|         mPassword = null;               // no update |         mPassword = null;               // no update | ||||||
|         mExpirationDateInMillis = 0;    // no update |         mExpirationDateInMillis = 0;    // no update | ||||||
|         mPublicUpload = false; |         mPublicUpload = null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -174,13 +174,9 @@ public class UpdateRemoteShareOperation extends RemoteOperation { | |||||||
|             parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions))); |             parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions))); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         parametersToUpdate.add(new Pair(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload))); |  | ||||||
| 
 |  | ||||||
|         /* TODO complete rest of parameters |  | ||||||
|         if (mPublicUpload != null) { |         if (mPublicUpload != null) { | ||||||
|             parametersToUpdate.add(new Pair("publicUpload", mPublicUpload.toString()); |             parametersToUpdate.add(new Pair(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload))); | ||||||
|         } |         } | ||||||
|         */ |  | ||||||
| 
 | 
 | ||||||
|         /// perform required PUT requests |         /// perform required PUT requests | ||||||
|         PutMethod put = null; |         PutMethod put = null; | ||||||
|  | |||||||
| @ -64,13 +64,18 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 	/* File to share and update.*/ | 	/* File to share and update.*/ | ||||||
| 	private static final String FILE_TO_SHARE = "/fileToShare.txt"; | 	private static final String FILE_TO_SHARE = "/fileToShare.txt"; | ||||||
| 	 | 	 | ||||||
|  | 	/* Folder to share and update */ | ||||||
|  | 	private static final String FOLDER_TO_SHARE = "/folderToShare"; | ||||||
|  | 	 | ||||||
| 	// Data for tests  | 	// Data for tests  | ||||||
| 	private static final String PASSWORD = "password"; | 	private static final String PASSWORD = "password"; | ||||||
| 	private static final String PASS_SPECIAL_CHARS = "p@ssw<73>rd"; | 	private static final String PASS_SPECIAL_CHARS = "p@ssw<73>rd"; | ||||||
| 	 | 	 | ||||||
| 	private String mFullPath2FileToShare; | 	private String mFullPath2FileToShare; | ||||||
|  | 	private String mFullPath2FolderToShare; | ||||||
| 	 | 	 | ||||||
| 	private OCShare mShare; | 	private OCShare mShare; | ||||||
|  | 	private OCShare mFolderShare; | ||||||
| 	 | 	 | ||||||
| 	String mServerUri, mUser, mPass; | 	String mServerUri, mUser, mPass; | ||||||
| 	OwnCloudClient mClient = null; | 	OwnCloudClient mClient = null; | ||||||
| @ -107,7 +112,7 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 	     | 	     | ||||||
| 	    Log.v(LOG_TAG, "Setting up the remote fixture..."); | 	    Log.v(LOG_TAG, "Setting up the remote fixture..."); | ||||||
| 	     | 	     | ||||||
| 	    // Upload the files | 	    // Upload the file | ||||||
| 	    mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; | 	    mFullPath2FileToShare = mBaseFolderPath + FILE_TO_SHARE; | ||||||
| 	     | 	     | ||||||
| 	    File textFile = getActivity().extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); | 	    File textFile = getActivity().extractAsset(TestActivity.ASSETS__TEXT_FILE_NAME); | ||||||
| @ -126,7 +131,7 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 				"",  | 				"",  | ||||||
| 				false,  | 				false,  | ||||||
| 				"",  | 				"",  | ||||||
| 				1); | 				OCShare.READ_PERMISSION_FLAG); | ||||||
| 
 | 
 | ||||||
| 	    if (result.isSuccess()){ | 	    if (result.isSuccess()){ | ||||||
| 	    	mShare = (OCShare) result.getData().get(0); | 	    	mShare = (OCShare) result.getData().get(0); | ||||||
| @ -134,7 +139,31 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 	    	mShare = null; | 	    	mShare = null; | ||||||
| 	    } | 	    } | ||||||
| 	     | 	     | ||||||
| 		Log.v(LOG_TAG, "Remote fixture created."); | 	 // Create the folder | ||||||
|  | 	 		mFullPath2FolderToShare = mBaseFolderPath + FOLDER_TO_SHARE; | ||||||
|  | 	 		result = getActivity().createFolder( | ||||||
|  | 	 				mFullPath2FolderToShare, | ||||||
|  | 	 				true); | ||||||
|  | 	 		if (!result.isSuccess()) { | ||||||
|  | 	 			Utils.logAndThrow(LOG_TAG, result); | ||||||
|  | 	 		} | ||||||
|  | 
 | ||||||
|  | 	 		// Share the folder privately with a group | ||||||
|  | 	 		result = getActivity().createShare( | ||||||
|  | 	 				mFullPath2FolderToShare, | ||||||
|  | 	 				ShareType.PUBLIC_LINK, | ||||||
|  | 	 				"", | ||||||
|  | 	 				false, | ||||||
|  | 	 				"", | ||||||
|  | 	 				OCShare.READ_PERMISSION_FLAG); | ||||||
|  | 
 | ||||||
|  | 	 		if (result.isSuccess()){ | ||||||
|  | 	 			mFolderShare = (OCShare) result.getData().get(0); | ||||||
|  | 	 		} else{ | ||||||
|  | 	 			mFolderShare = null; | ||||||
|  | 	 		} | ||||||
|  | 	     | ||||||
|  | 		Log.v(LOG_TAG, "Remote fixtures created."); | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -165,8 +194,8 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 			result = updateShare.execute(mClient); | 			result = updateShare.execute(mClient); | ||||||
| 			assertTrue(result.isSuccess()); | 			assertTrue(result.isSuccess()); | ||||||
| 
 | 
 | ||||||
|             // Update Share with edit permission | 			// Update the Folder Share with edit permission | ||||||
|             updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); | 			updateShare = new UpdateRemoteShareOperation(mFolderShare.getRemoteId()); | ||||||
| 			updateShare.setPublicUpload(true); | 			updateShare.setPublicUpload(true); | ||||||
| 			result = updateShare.execute(mClient); | 			result = updateShare.execute(mClient); | ||||||
| 			assertTrue(result.isSuccess()); | 			assertTrue(result.isSuccess()); | ||||||
| @ -180,6 +209,12 @@ public class UpdatePublicShareTest extends RemoteTest { | |||||||
| 			result = updateShare.execute(mClient); | 			result = updateShare.execute(mClient); | ||||||
| 			assertFalse(result.isSuccess()); | 			assertFalse(result.isSuccess()); | ||||||
| 			 | 			 | ||||||
|  | 			// Try to update the file Share with edit permission | ||||||
|  | 			updateShare = new UpdateRemoteShareOperation(mShare.getRemoteId()); | ||||||
|  | 			updateShare.setPublicUpload(true); | ||||||
|  | 			result = updateShare.execute(mClient); | ||||||
|  | 			assertFalse(result.isSuccess()); | ||||||
|  | 
 | ||||||
| 			// Unshare the file before the unsuccessful tests | 			// Unshare the file before the unsuccessful tests | ||||||
| 			RemoveRemoteShareOperation unshare = new RemoveRemoteShareOperation((int) mShare.getRemoteId()); | 			RemoveRemoteShareOperation unshare = new RemoveRemoteShareOperation((int) mShare.getRemoteId()); | ||||||
| 			result = unshare.execute(mClient); | 			result = unshare.execute(mClient); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user