1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

[api2] Fix create dir shared item bug

This commit is contained in:
zhengxie
2015-12-04 16:17:13 +08:00
parent 2cb64b9e92
commit e91e796efc
2 changed files with 15 additions and 0 deletions

View File

@@ -249,6 +249,10 @@ class DirSharedItemsEndpoint(APIView):
if share_type == 'user':
share_to_users = request.DATA.getlist('username')
for to_user in share_to_users:
if not is_valid_username(to_user):
return api_error(status.HTTP_400_BAD_REQUEST,
'Username must be a valid email address.')
if not check_user_share_quota(username, shared_repo, users=[to_user]):
return api_error(status.HTTP_403_FORBIDDEN,
'Failed to share: No enough quota.')

View File

@@ -68,6 +68,17 @@ class DirSharedItemsTest(BaseTestCase):
assert len(json_resp['success']) == 2
assert json_resp['success'][0]['permission'] == 'r'
def test_share_folder_to_invalid_email(self):
self.login_as(self.user)
resp = self.client.put(
'/api2/repos/%s/dir/shared_items/?p=%s' % (self.repo.id,
self.folder),
"share_type=user&username=abc",
'application/x-www-form-urlencoded',
)
self.assertEqual(400, resp.status_code)
def test_can_share_root_to_groups(self):
self.login_as(self.user)