summaryrefslogtreecommitdiff
path: root/addons/document_ftp
diff options
context:
space:
mode:
authoruco (OpenERP) <uco@tinyerp.com>2010-11-15 10:19:34 +0530
committeruco (OpenERP) <uco@tinyerp.com>2010-11-15 10:19:34 +0530
commitf3a868e28d3a74bdff4bdfdbf9b3ec68e9c9dbb7 (patch)
tree1f953fde279e044c776653310a5f8cb7bc2615bf /addons/document_ftp
parentf58df4820f36bfec3ffad087af275de5c2af7e5d (diff)
parent8ad87d0d946ecc5fcfc75f665409828921d2299b (diff)
[MERGE]: Merged with team1.
bzr revid: uco@tinyerp.com-20101112044246-qc1tp6ohth0kduie bzr revid: uco@tinyerp.com-20101115044934-pu05mgdtmmcqs2hz
Diffstat (limited to 'addons/document_ftp')
-rw-r--r--addons/document_ftp/ftpserver/abstracted_fs.py4
-rw-r--r--addons/document_ftp/ftpserver/ftpserver.py1
-rw-r--r--addons/document_ftp/test/document_ftp_test2.yml31
-rw-r--r--addons/document_ftp/test/document_ftp_test4.yml29
-rw-r--r--addons/document_ftp/test/document_ftp_test5.yml30
5 files changed, 92 insertions, 3 deletions
diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py
index 9c16e7dde55..65b17a52c51 100644
--- a/addons/document_ftp/ftpserver/abstracted_fs.py
+++ b/addons/document_ftp/ftpserver/abstracted_fs.py
@@ -146,16 +146,18 @@ class abstracted_fs(object):
ret = child.open_data(cr, mode)
cr.commit()
+ assert ret, "Cannot create descriptor for %r: %r" % (child, ret)
return ret
except EnvironmentError:
raise
- except Exception,e:
+ except Exception:
self._log.exception('Cannot locate item %s at node %s', objname, repr(node))
pass
try:
child = node.create_child(cr, objname, data=None)
ret = child.open_data(cr, mode)
+ assert ret, "cannot create descriptor for %r" % child
cr.commit()
return ret
except EnvironmentError:
diff --git a/addons/document_ftp/ftpserver/ftpserver.py b/addons/document_ftp/ftpserver/ftpserver.py
index 710494bb9db..bd727427541 100644
--- a/addons/document_ftp/ftpserver/ftpserver.py
+++ b/addons/document_ftp/ftpserver/ftpserver.py
@@ -2223,6 +2223,7 @@ class FTPHandler(asynchat.async_chat):
if self.restart_position:
mode = 'r+'
fd = self.try_as_current_user(self.fs.create, (datacr, datacr[2], mode + 'b'))
+ assert fd
except FTPExceptionSent:
self.fs.close_cr(datacr)
return
diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml
index da55c353767..5da4bcd83ef 100644
--- a/addons/document_ftp/test/document_ftp_test2.yml
+++ b/addons/document_ftp/test/document_ftp_test2.yml
@@ -7,6 +7,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_plain_ftp(timeout=2.0)
assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp
+ ftp.close()
-
I read the list of databases at port 8021 and confirm our db is
there
@@ -15,6 +16,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_login(cr, uid, self)
assert cr.dbname in ftp.nlst("/")
+ ftp.close()
-
I try to locate the default "Documents" folder in the db.
-
@@ -22,6 +24,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_login(cr, uid, self)
ftp.cwd('Documents')
+ ftp.close()
-
I create a "test.txt" file at the server (directly). The file
should have the "abcd" content
@@ -32,6 +35,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
fdata = StringIO('abcd')
ftp.storbinary('STOR test.txt', fdata)
+ ftp.close()
-
I look for the "test.txt" file at the server
-
@@ -39,6 +43,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
assert ftp.nlst("test.txt") == ['test.txt']
+ ftp.close()
-
I check that the content of "test.txt" is "abcd"
-
@@ -46,7 +51,9 @@
from document_ftp import test_easyftp as te
from cStringIO import StringIO
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
- assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd'
+ gotdata = te.get_ftp_fulldata(ftp, "test.txt")
+ ftp.close()
+ assert gotdata == 'abcd', 'Data: %r' % gotdata
-
I append the string 'defgh' to "test.txt"
-
@@ -56,6 +63,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
fdata = StringIO('defgh')
ftp.storbinary('APPE test.txt', fdata)
+ ftp.close()
-
I check that the content of "text.txt" is 'abcddefgh'
-
@@ -63,7 +71,9 @@
from document_ftp import test_easyftp as te
from cStringIO import StringIO
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
- assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcddefgh'
+ gotdata = te.get_ftp_fulldata(ftp, "test.txt")
+ ftp.close()
+ assert gotdata == 'abcddefgh', 'Data: %r' % gotdata
-
I try to cd into an non-existing folder 'Not-This'
-
@@ -77,7 +87,9 @@
except ftplib.error_perm:
pass
except OSError, err:
+ ftp.close()
assert err.errno == 2, err.errno
+ ftp.close()
-
I create a "test2.txt" file through FTP.
-
@@ -87,6 +99,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
fdata = StringIO('abcd')
ftp.storbinary('STOR test2.txt', fdata)
+ ftp.close()
-
I look for the "test2.txt" file at the server
-
@@ -101,6 +114,7 @@
from cStringIO import StringIO
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.delete('test2.txt')
+ ftp.close()
-
I check at the server that test2.txt is deleted
-
@@ -116,6 +130,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
fdata = StringIO('abcd')
ftp.storbinary('STOR test2.txt', fdata)
+ ftp.close()
-
I delete the test2.txt from the server (RPC).
-
@@ -137,6 +152,7 @@
except ftplib.error_perm: # 550 error: 'path not exists'
nlst_result = []
assert "test2.txt" not in nlst_result, "Files: %r" % nlst_result
+ ftp.close()
-
I create a "test-name.txt" file
-
@@ -146,6 +162,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
fdata = StringIO('abcd')
ftp.storbinary('STOR test-name.txt', fdata)
+ ftp.close()
-
I rename the "test-name.txt" file through ftp.
-
@@ -153,6 +170,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.rename("test-name.txt", "test-renamed.txt")
+ ftp.close()
-
I check that test-name.txt has been renamed.
-
@@ -166,6 +184,7 @@
except error_perm, e:
pass
assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt']
+ ftp.close()
-
I create a new folder 'Test-Folder2' through FTP
-
@@ -173,6 +192,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.mkd("Test-Folder2")
+ ftp.close()
-
I create a file 'test3.txt' at the 'Test-Folder2'
-
@@ -182,6 +202,7 @@
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
fdata = StringIO('abcd')
ftp.storbinary('STOR test3.txt', fdata)
+ ftp.close()
-
I try to retrieve test3.txt
-
@@ -189,6 +210,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
assert ftp.nlst("test3.txt") == ['test3.txt'], "File test3.txt is not there!"
+ ftp.close()
-
I create a new folder, 'Test-Folder3', through FTP
I try to move test3.txt to 'Test-Folder3'
@@ -197,6 +219,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.mkd("Test-Folder3")
+ ftp.close()
# TODO move
-
I remove the 'Test-Folder3'
@@ -205,6 +228,7 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.rmd("Test-Folder3")
+ ftp.close()
-
I check that test3.txt is removed.
-
@@ -219,6 +243,7 @@
for i in range(0, 200):
fdata.seek(0)
ftp.storbinary('STOR test-name%s.txt' %i, fdata)
+ ftp.close()
-
I list the 200 files, check speed
-
@@ -245,6 +270,7 @@
ftp.delete('test3.txt')
for i in range(0, 200):
ftp.delete('test-name%s.txt' %i)
+ ftp.close()
-
I remove the 'Test-Folder2'
-
@@ -252,3 +278,4 @@
from document_ftp import test_easyftp as te
ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
ftp.rmd("Test-Folder2")
+ ftp.close()
diff --git a/addons/document_ftp/test/document_ftp_test4.yml b/addons/document_ftp/test/document_ftp_test4.yml
index 2bb616dc1bd..2441be3bf92 100644
--- a/addons/document_ftp/test/document_ftp_test4.yml
+++ b/addons/document_ftp/test/document_ftp_test4.yml
@@ -114,6 +114,35 @@
- res_model == 'res.partner'
- res_id != False
-
+ I try to create a file directly under the Partners Testing folder
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ import ftplib
+ from cStringIO import StringIO
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
+ fdata = StringIO('abcd')
+ try:
+ ftp.storbinary('STOR stray.txt', fdata)
+ assert False, "We should't be able to create files here"
+ except ftplib.error_perm:
+ # That's what should happen
+ pass
+-
+ I try to create a folder directly under the Partners Testing folder
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ import ftplib
+ from cStringIO import StringIO
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
+ try:
+ ftp.mkd('Weird folder')
+ assert False, "We should't be able to create folders here"
+ except ftplib.error_perm:
+ # That's what should happen
+ pass
+-
I check that all/Partner1 also has the file
- |
Bonus Piste:
diff --git a/addons/document_ftp/test/document_ftp_test5.yml b/addons/document_ftp/test/document_ftp_test5.yml
new file mode 100644
index 00000000000..a66f409905b
--- /dev/null
+++ b/addons/document_ftp/test/document_ftp_test5.yml
@@ -0,0 +1,30 @@
+-
+ In order to check the permissions setup and functionality of the
+ document module:
+-
+ I create a testing user for the documents
+-
+ I assign some ... group to the testing user
+-
+ I create a "group testing" user, which also belongs to the same ... group
+-
+ I create a "blocked" user.
+-
+ I create (as root) a testing folder in the document hierarchy, and
+ assign ownership to the testing user, groups to the ... group.
+-
+ I create a "private" folder inside the testing folder.
+-
+ I try to read the testing folder as the testing user
+-
+ I try to read the folder as the group user, it should fail.
+-
+ I try to read the folder as the blocked user.
+-
+ I create a "group" folder, with the ... group.
+-
+ I try to read the "group" folder as the testing user
+-
+ I try to read the "group" folder as the group user
+-
+ I try to read the "group" folder as the blocked user