Merge lp:~ralsina/ubuntuone-client/verify-harder into lp:ubuntuone-client

Proposed by Roberto Alsina on 2012-08-06
Status: Merged
Approved by: Alejandro J. Cura on 2012-08-06
Approved revision: 1292
Merged at revision: 1286
Proposed branch: lp:~ralsina/ubuntuone-client/verify-harder
Merge into: lp:ubuntuone-client
Diff against target: 54 lines (+17/-2)
2 files modified
tests/syncdaemon/test_vm.py (+13/-2)
ubuntuone/syncdaemon/volume_manager.py (+4/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-client/verify-harder
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve on 2012-08-06
Eric Casteleijn (community) 2012-08-06 Approve on 2012-08-06
Review via email: mp+118399@code.launchpad.net

Commit message

 - Added check for UDF path not being a file (LP:1033582).

Description of the change

 - Added check for UDF path not being a file (LP:1033582).

To post a comment you must log in.
Eric Casteleijn (thisfred) wrote :

+2

review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_vm.py'
2--- tests/syncdaemon/test_vm.py 2012-04-09 20:07:05 +0000
3+++ tests/syncdaemon/test_vm.py 2012-08-06 19:21:20 +0000
4@@ -2752,7 +2752,7 @@
5
6 result, msg = self.vm.validate_path_for_folder(folder_path)
7 self.assertTrue(result)
8- self.assertIs(msg, "",
9+ self.assertIs(msg, "",
10 '%r must be a valid path for creating a folder.' % folder_path)
11
12 def test_validate_UDF_path_if_folder_shares_a_prefix_with_an_udf(self):
13@@ -2769,7 +2769,7 @@
14
15 result, msg = self.vm.validate_path_for_folder(tricky_path)
16 self.assertTrue(result)
17- self.assertIs(msg, "",
18+ self.assertIs(msg, "",
19 '%r must be a valid path for creating a folder.' % tricky_path)
20
21 def test_validate_UDF_path_not_valid_if_outside_home(self):
22@@ -2818,6 +2818,17 @@
23 self.assertIsNot(msg, "",
24 '%r must be an invalid path for creating a folder.' % udf_parent)
25
26+ def test_not_valid_if_folder_is_file(self):
27+ """A link path is not valid."""
28+ self.patch(volume_manager.os.path, 'isdir', lambda p: False)
29+ self.patch(volume_manager, 'path_exists', lambda p: True)
30+ path_link = os.path.join(self.home_dir, 'Test Me')
31+
32+ result, msg = self.vm.validate_path_for_folder(path_link)
33+ self.assertFalse(result)
34+ self.assertIsNot(msg, "",
35+ '%r must be an invalid path for creating a folder.' % path_link)
36+
37 def test_not_valid_if_folder_is_link(self):
38 """A link path is not valid."""
39 self.patch(volume_manager, 'is_link', lambda p: True)
40
41=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
42--- ubuntuone/syncdaemon/volume_manager.py 2012-05-14 21:24:24 +0000
43+++ ubuntuone/syncdaemon/volume_manager.py 2012-08-06 19:21:20 +0000
44@@ -1207,6 +1207,10 @@
45 if is_link(path):
46 return (False, "UDFs can not be a symlink")
47
48+ # check if path exists but is not a directory
49+ if path_exists(path) and not os.path.isdir(path):
50+ return (False, "The path exists but is not a folder")
51+
52 # check if the path it's ok (outside root and
53 # isn't a ancestor or child of another UDF)
54 if self._is_nested_udf(path):

Subscribers

People subscribed via source and target branches