1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 16:10:26 +00:00

update parameter and tests

This commit is contained in:
lian
2017-08-04 15:01:55 +08:00
parent e15f6c6737
commit 45f0d9cd9a
2 changed files with 10 additions and 8 deletions

View File

@@ -293,7 +293,7 @@ class ReposBatchCopyDirView(APIView):
{ {
"src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118", "src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
"dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db", "dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db",
"path":[ "paths":[
{"src_path":"/1/2/3/","dst_path":"/4/5/6/"}, {"src_path":"/1/2/3/","dst_path":"/4/5/6/"},
{"src_path":"/a/b/c/","dst_path":"/d/e/f/"}, {"src_path":"/a/b/c/","dst_path":"/d/e/f/"},
] ]
@@ -301,9 +301,9 @@ class ReposBatchCopyDirView(APIView):
""" """
# argument check # argument check
path_list = request.data.get('path', None) path_list = request.data.get('paths', None)
if not path_list: if not path_list:
error_msg = 'path invalid.' error_msg = 'paths invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
src_repo_id = request.data.get('src_repo_id', None) src_repo_id = request.data.get('src_repo_id', None)
@@ -316,12 +316,12 @@ class ReposBatchCopyDirView(APIView):
error_msg = 'dst_repo_id invalid.' error_msg = 'dst_repo_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# permission check, user must has `r/rw` permission for src folder. # permission check, user must has `r/rw` permission for src repo.
if check_folder_permission(request, src_repo_id, '/') is None: if check_folder_permission(request, src_repo_id, '/') is None:
error_msg = 'Permission denied.' error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg) return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# permission check, user must has `rw` permission for dst folder. # permission check, user must has `rw` permission for dst repo.
if check_folder_permission(request, dst_repo_id, '/') != 'rw': if check_folder_permission(request, dst_repo_id, '/') != 'rw':
error_msg = 'Permission denied.' error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg) return api_error(status.HTTP_403_FORBIDDEN, error_msg)

View File

@@ -247,7 +247,7 @@ class ReposBatchCopyDirView(BaseTestCase):
data = { data = {
"src_repo_id": self.repo_id, "src_repo_id": self.repo_id,
"dst_repo_id": tmp_repo_id, "dst_repo_id": tmp_repo_id,
"path": [ "paths": [
{"src_path": src_folder_1, "dst_path": dst_folder_1}, {"src_path": src_folder_1, "dst_path": dst_folder_1},
{"src_path": src_folder_2, "dst_path": dst_folder_2}, {"src_path": src_folder_2, "dst_path": dst_folder_2},
] ]
@@ -285,7 +285,7 @@ class ReposBatchCopyDirView(BaseTestCase):
data = { data = {
"src_repo_id": self.repo_id, "src_repo_id": self.repo_id,
"dst_repo_id": tmp_repo_id, "dst_repo_id": tmp_repo_id,
"path": [ "paths": [
{"src_path": '/', "dst_path": '/'}, {"src_path": '/', "dst_path": '/'},
{"src_path": '/', "dst_path": '/'}, {"src_path": '/', "dst_path": '/'},
] ]
@@ -308,7 +308,7 @@ class ReposBatchCopyDirView(BaseTestCase):
data = { data = {
"src_repo_id": self.repo_id, "src_repo_id": self.repo_id,
"dst_repo_id": tmp_repo_id, "dst_repo_id": tmp_repo_id,
"path": [ "paths": [
{"src_path": '/', "dst_path": '/'}, {"src_path": '/', "dst_path": '/'},
] ]
} }
@@ -323,3 +323,5 @@ class ReposBatchCopyDirView(BaseTestCase):
assert json_resp['failed'][0]['error_msg'] == \ assert json_resp['failed'][0]['error_msg'] == \
"The source path can not be '/'." "The source path can not be '/'."
self.remove_repo(tmp_repo_id)