aboutsummaryrefslogtreecommitdiff
path: root/test/ftptest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/ftptest.lua')
-rw-r--r--test/ftptest.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ftptest.lua b/test/ftptest.lua
new file mode 100644
index 0000000..85dc16b
--- /dev/null
+++ b/test/ftptest.lua
@@ -0,0 +1,33 @@
1assert(dofile("../lua/ftp.lua"))
2assert(dofile("auxiliar.lua"))
3
4pdir = "/home/i/diego/public/html/luasocket/test/"
5ldir = "/home/luasocket/"
6adir = "/home/ftp/test/"
7
8-- needs an accound luasocket:password
9-- and a copy of /home/i/diego/public/html/luasocket/test in ~ftp/test
10
11print("testing authenticated upload")
12bf = readfile(pdir .. "index.html")
13e = ftp_put("ftp://luasocket:password@localhost/index.html", bf, "b")
14assert(not e, e)
15assert(compare(ldir .. "index.html", bf), "files differ")
16remove(ldir .. "index.html")
17
18print("testing authenticated download")
19f, e = ftp_get("ftp://luasocket:password@localhost/test/index.html", "b")
20assert(f, e)
21assert(compare(pdir .. "index.html", f), "files differ")
22
23print("testing anonymous download")
24f, e = ftp_get("ftp://localhost/test/index.html", "b")
25assert(f, e)
26assert(compare(adir .. "index.html", f), "files differ")
27
28print("testing directory listing")
29f, e = ftp_get("ftp://localhost/test/")
30assert(f, e)
31assert(f == "index.html\r\n", "files differ")
32
33print("passed all tests")