davclient 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +53 -0
- data/Manifest +31 -0
- data/README.rdoc +52 -13
- data/Rakefile +94 -0
- data/davclient.gemspec +32 -0
- data/examples/remove_ds_store.rb +15 -0
- data/examples/simple_find.rb +10 -0
- data/lib/davclient/hpricot_extensions.rb +0 -2
- data/lib/davclient/simple.rb +44 -0
- data/lib/davclient.rb +61 -14
- data/tests/dav.rb +12 -0
- data/tests/tc_dav-cat.rb +34 -0
- data/tests/tc_dav-cd.rb +45 -0
- data/tests/tc_dav-cp.rb +51 -0
- data/tests/tc_dav-delete.rb +37 -0
- data/tests/tc_dav-get.rb +63 -0
- data/tests/tc_dav-ls.rb +45 -0
- data/tests/tc_dav-mkcol.rb +64 -0
- data/tests/tc_dav-mv.rb +65 -0
- data/tests/tc_dav-propfind.rb +40 -0
- data/tests/tc_dav-put.rb +132 -0
- data/tests/tc_webdav_basic.rb +102 -0
- data/tests/tc_webdav_publish.rb +63 -0
- data/tests/test_helper.rb +2 -0
- data/tests/ts_davclient.rb +11 -0
- metadata +53 -36
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/zentest_assertions'
|
7
|
+
|
8
|
+
class TestDelete < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_basic_delete
|
11
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
12
|
+
WebDAV.cd(url)
|
13
|
+
|
14
|
+
new_url = url + "davclient_test_folder/"
|
15
|
+
|
16
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
17
|
+
if(props)
|
18
|
+
WebDAV.delete(new_url)
|
19
|
+
end
|
20
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
21
|
+
assert_nil props
|
22
|
+
|
23
|
+
WebDAV.mkcol("davclient_test_folder")
|
24
|
+
|
25
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
26
|
+
assert props
|
27
|
+
|
28
|
+
assert_equal url, WebDAV.CWURL
|
29
|
+
|
30
|
+
WebDAV.delete("davclient_test_folder")
|
31
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
32
|
+
assert_nil props
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
data/tests/tc_dav-get.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient/davcli'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'test/zentest_assertions'
|
8
|
+
|
9
|
+
class TestGetCLI < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def get(*args)
|
12
|
+
out, err = util_capture do
|
13
|
+
DavCLI.get(*args)
|
14
|
+
end
|
15
|
+
return [out.string, err.string]
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_file(filename, content)
|
19
|
+
File.open(filename, 'w') {|f| f.write(content) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@basename = "get_test.html"
|
24
|
+
@filename = "/tmp/" + @basename
|
25
|
+
@url = "https://vortex-dav.uio.no/brukere/thomasfl/get_test/"
|
26
|
+
@html = "<html><head><title>Testfile</title></head><body><h1>Testfile</h1></body></html>"
|
27
|
+
create_file(@filename, @html)
|
28
|
+
|
29
|
+
WebDAV.delete(@url)
|
30
|
+
WebDAV.mkcol(@url)
|
31
|
+
WebDAV.cd(@url)
|
32
|
+
|
33
|
+
for i in 1..4 do
|
34
|
+
filename = "get_test_" + i.to_s + ".html"
|
35
|
+
PutCLI.put([@filename, @url + filename])
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
File.delete(@filename)
|
42
|
+
# WebDAV.delete(@url)
|
43
|
+
WebDAV.cd("https://vortex-dav.uio.no/brukere/thomasfl/")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_basic_get
|
47
|
+
# dav get filename
|
48
|
+
# assert_equal @html, WebDAV.get(@url + @basename)
|
49
|
+
WebDAV.cd(@url)
|
50
|
+
# out, err = get(["get_test_1.html"])
|
51
|
+
`rm get_*.html 2> /dev/null`
|
52
|
+
DavCLI.get(["get_test_1.html"])
|
53
|
+
number_of_files = `ls -1 get_test*.html|wc -l`.to_i
|
54
|
+
assert_equal 1, number_of_files
|
55
|
+
|
56
|
+
`rm get_*.html 2> /dev/null`
|
57
|
+
DavCLI.get(["get_test_1.html", "get_test_2.html"])
|
58
|
+
number_of_files = `ls -1 get_test*.html|wc -l`.to_i
|
59
|
+
assert_equal 2, number_of_files
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/tests/tc_dav-ls.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient'
|
6
|
+
require 'davclient/davcli'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'test/zentest_assertions'
|
9
|
+
|
10
|
+
|
11
|
+
class TestLsCLI < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def ls(*args)
|
14
|
+
out, err = util_capture do
|
15
|
+
DavCLI.ls(*args)
|
16
|
+
end
|
17
|
+
return [out.string, err.string]
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def test_basic_ls
|
22
|
+
out, err = ls(["-a", "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/2005/"])
|
23
|
+
assert_equal(9, out.split(/\n/).size )
|
24
|
+
|
25
|
+
assert(out =~ /^https:\/\//)
|
26
|
+
assert_equal("", err)
|
27
|
+
|
28
|
+
out, err = ls(["https://vortex-dav.uio.no/brukere/thomasfl/"])
|
29
|
+
assert (not (out =~ /^http/))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_ls_cwurl
|
33
|
+
out, err = ls(["-a", "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/2006/"])
|
34
|
+
assert_equal(7, out.split(/\n/).size )
|
35
|
+
|
36
|
+
WebDAV.cd("https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/2006/")
|
37
|
+
out, err = ls(["-a"]) # If no url are given, should use the last used url
|
38
|
+
assert_equal(7, out.split(/\n/).size )
|
39
|
+
|
40
|
+
WebDAV.CWURL = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/2008/"
|
41
|
+
out, err = ls([])
|
42
|
+
assert_equal(10, out.split(/\n/).size )
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient/davcli'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'test/zentest_assertions'
|
8
|
+
|
9
|
+
class TestMkcolCLI < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def cd(*args)
|
12
|
+
out, err = util_capture do
|
13
|
+
DavCLI.cd(*args)
|
14
|
+
end
|
15
|
+
return [out.string, err.string]
|
16
|
+
end
|
17
|
+
|
18
|
+
def mkcol(*args)
|
19
|
+
out, err = util_capture do
|
20
|
+
DavCLI.mkcol(*args)
|
21
|
+
end
|
22
|
+
return [out.string, err.string]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_basic_mkcol
|
26
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
27
|
+
out, err = cd([url])
|
28
|
+
new_url = url + "davclient_test_folder/"
|
29
|
+
|
30
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
31
|
+
if(props)
|
32
|
+
WebDAV.delete(new_url)
|
33
|
+
end
|
34
|
+
|
35
|
+
WebDAV.mkcol(new_url)
|
36
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
37
|
+
assert props
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_relative_url
|
41
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
42
|
+
out, err = cd([url])
|
43
|
+
|
44
|
+
new_url = url + "davclient_test_folder/"
|
45
|
+
|
46
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
47
|
+
if(props)
|
48
|
+
WebDAV.delete(new_url)
|
49
|
+
end
|
50
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
51
|
+
assert_nil props
|
52
|
+
|
53
|
+
WebDAV.mkcol("davclient_test_folder")
|
54
|
+
|
55
|
+
props = WebDAV.propfind(new_url, :xml => true)
|
56
|
+
assert props
|
57
|
+
|
58
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
59
|
+
out, err = cd(url)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
data/tests/tc_dav-mv.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient/davcli'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'test/zentest_assertions'
|
8
|
+
|
9
|
+
class TestMove < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def mv(*args)
|
12
|
+
out, err = util_capture do
|
13
|
+
DavCLI.mv(*args)
|
14
|
+
end
|
15
|
+
return [out.string, err.string]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_mv
|
19
|
+
$DEBUG = false
|
20
|
+
src = "https://vortex-dav.uio.no/brukere/thomasfl/testfile.html"
|
21
|
+
dest = "https://vortex-dav.uio.no/brukere/thomasfl/testfile_copy.html"
|
22
|
+
WebDAV.delete(dest)
|
23
|
+
assert !WebDAV.exists?(dest)
|
24
|
+
|
25
|
+
WebDAV.mv(src,dest)
|
26
|
+
assert WebDAV.exists?(dest)
|
27
|
+
assert !WebDAV.exists?(src)
|
28
|
+
|
29
|
+
WebDAV.mv(dest, src)
|
30
|
+
|
31
|
+
assert !WebDAV.exists?(dest)
|
32
|
+
assert WebDAV.exists?(src)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_mv_command_line
|
36
|
+
src = "https://vortex-dav.uio.no/brukere/thomasfl/testfile.html"
|
37
|
+
dest = "https://vortex-dav.uio.no/brukere/thomasfl/testfile_copy.html"
|
38
|
+
WebDAV.delete(dest)
|
39
|
+
assert !WebDAV.exists?(dest)
|
40
|
+
|
41
|
+
out, err = mv([src,dest])
|
42
|
+
assert WebDAV.exists?(dest)
|
43
|
+
assert !WebDAV.exists?(src)
|
44
|
+
|
45
|
+
out, err = mv([dest, src])
|
46
|
+
assert !WebDAV.exists?(dest)
|
47
|
+
assert WebDAV.exists?(src)
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_mv_relative
|
52
|
+
WebDAV.cd("https://vortex-dav.uio.no/brukere/thomasfl/")
|
53
|
+
|
54
|
+
src = "testfile.html"
|
55
|
+
dest = "testfile.html"
|
56
|
+
|
57
|
+
out, err = mv([src,dest])
|
58
|
+
assert WebDAV.exists?(dest)
|
59
|
+
|
60
|
+
out, err = mv([dest, src])
|
61
|
+
assert WebDAV.exists?(src)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient/davcli'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'test/zentest_assertions'
|
8
|
+
|
9
|
+
class TestPropfind < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def props(*args)
|
12
|
+
out, err = util_capture do
|
13
|
+
DavCLI.propfind(*args)
|
14
|
+
end
|
15
|
+
return [out.string, err.string]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_propfind_library_call
|
19
|
+
$DEBUG = false
|
20
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
21
|
+
props = WebDAV.propfind(url)
|
22
|
+
assert props.to_s.size > 1000
|
23
|
+
|
24
|
+
props = WebDAV.propfind("..")
|
25
|
+
assert props.to_s.size > 1000
|
26
|
+
|
27
|
+
url = "https://vortex-dav.uio.no/brukere/"
|
28
|
+
props = WebDAV.propfind("../../brukere/")
|
29
|
+
assert props.to_s.size > 1000
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_propfind_command_line
|
34
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
35
|
+
out, err = props([url])
|
36
|
+
assert out.size > 10000
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
data/tests/tc_dav-put.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'davclient'
|
5
|
+
require 'davclient'
|
6
|
+
require 'davclient/davcli'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'test/zentest_assertions'
|
9
|
+
require 'pathname'
|
10
|
+
|
11
|
+
class TestPutCLI < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def put(*args)
|
14
|
+
out, err = util_capture do
|
15
|
+
PutCLI.put(*args)
|
16
|
+
end
|
17
|
+
return [out.string, err.string]
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_file(filename, content)
|
21
|
+
File.open(filename, 'w') {|f| f.write(content) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup
|
25
|
+
@basename = "put_test.html"
|
26
|
+
@filename = "/tmp/" + @basename
|
27
|
+
@url = "https://vortex-dav.uio.no/brukere/thomasfl/"
|
28
|
+
@html = "<html><head><title>Testfile</title></head><body><h1>Testfile</h1></body></html>"
|
29
|
+
create_file(@filename, @html)
|
30
|
+
WebDAV.delete(@url + @basename)
|
31
|
+
end
|
32
|
+
|
33
|
+
def teardown
|
34
|
+
File.delete(@filename)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_basic_put
|
38
|
+
# dav put /tmp/filename
|
39
|
+
WebDAV.delete(@url + @basename)
|
40
|
+
WebDAV.cd(@url)
|
41
|
+
out, err = put([@filename])
|
42
|
+
assert_equal @html, WebDAV.get(@url + @basename)
|
43
|
+
|
44
|
+
# dav put /tmp/filename http://url/collection/
|
45
|
+
WebDAV.delete(@url + @basename)
|
46
|
+
out, err = put([@filename,@url])
|
47
|
+
assert_equal @html, WebDAV.get(@url + @basename)
|
48
|
+
|
49
|
+
# dav put /tmp/filename http://url/collection/remote-filename
|
50
|
+
WebDAV.delete(@url + @basename)
|
51
|
+
out, err = put([@filename,@url + @basename])
|
52
|
+
assert_equal @html, WebDAV.get(@url + @basename)
|
53
|
+
|
54
|
+
# dav put filename
|
55
|
+
@local_testfile = "put_test.html"
|
56
|
+
|
57
|
+
path = Pathname.new( Dir.getwd())
|
58
|
+
@local_testfile = (path + @local_testfile).to_s
|
59
|
+
create_file(@local_testfile, @html)
|
60
|
+
WebDAV.delete(@url + @basename)
|
61
|
+
WebDAV.cd(@url)
|
62
|
+
|
63
|
+
out, err = put([@filename])
|
64
|
+
assert_equal @html, WebDAV.get(@url + @basename)
|
65
|
+
|
66
|
+
# dav put ./filename
|
67
|
+
@local_testfile = "put_test.html"
|
68
|
+
@local_testfile_basename = @local_testfile
|
69
|
+
path = Pathname.new( Dir.getwd())
|
70
|
+
@local_testfile = (path + @local_testfile).to_s
|
71
|
+
create_file(@local_testfile, @html)
|
72
|
+
WebDAV.delete(@url + @local_testfile_basename)
|
73
|
+
WebDAV.cd(@url)
|
74
|
+
|
75
|
+
out, err = put(["./" + @local_testfile_basename])
|
76
|
+
assert_equal @html, WebDAV.get(@url + @local_testfile_basename)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_put_multiple_files
|
80
|
+
# dav put filename1 filename2 filename3 filename4
|
81
|
+
filelist = []
|
82
|
+
for i in 1..4 do
|
83
|
+
filename = "put_test_" + i.to_s + ".html"
|
84
|
+
create_file(filename, @html)
|
85
|
+
WebDAV.delete(@url + filename )
|
86
|
+
filelist << filename
|
87
|
+
end
|
88
|
+
|
89
|
+
# PutCLI.put(filelist)
|
90
|
+
out, err = put(filelist)
|
91
|
+
|
92
|
+
for i in 1..4 do
|
93
|
+
filename = "put_test_" + i.to_s + ".html"
|
94
|
+
assert_equal @html, WebDAV.get(@url + filename)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def test_put_multiple_files_to_url
|
101
|
+
# dav put filename1 filename2 filename3 filename4 https://url.com/folder/
|
102
|
+
|
103
|
+
url = @url + "put_test/"
|
104
|
+
WebDAV.delete(url)
|
105
|
+
WebDAV.mkcol(url)
|
106
|
+
|
107
|
+
filelist = []
|
108
|
+
for i in 1..4 do
|
109
|
+
filename = "put_test_" + i.to_s + ".html"
|
110
|
+
create_file(filename, @html)
|
111
|
+
filelist << filename
|
112
|
+
end
|
113
|
+
|
114
|
+
filelist << url
|
115
|
+
|
116
|
+
out, err = put(filelist)
|
117
|
+
|
118
|
+
for i in 1..4 do
|
119
|
+
filename = "put_test_" + i.to_s + ".html"
|
120
|
+
assert_equal @html, WebDAV.get(url + filename)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_file_not_found
|
125
|
+
|
126
|
+
assert_raise RuntimeError do
|
127
|
+
PutCLI.put(["a_file_that_doesn_exists_for_sure"])
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'test_helper'
|
5
|
+
require 'davclient'
|
6
|
+
|
7
|
+
$curl = "/usr/local/bin/curl"
|
8
|
+
|
9
|
+
class TestWebDAVLib < Test::Unit::TestCase
|
10
|
+
|
11
|
+
|
12
|
+
def test_find
|
13
|
+
url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/"
|
14
|
+
items = WebDAV.find(url)
|
15
|
+
assert(items.size > 10 )
|
16
|
+
|
17
|
+
antall = items.size
|
18
|
+
WebDAV.cd(url)
|
19
|
+
items = WebDAV.find()
|
20
|
+
assert_equal(antall, items.size )
|
21
|
+
|
22
|
+
assert_raise RuntimeError do
|
23
|
+
WebDAV.CWURL = nil
|
24
|
+
items = WebDAV.find()
|
25
|
+
end
|
26
|
+
|
27
|
+
items = WebDAV.find(url, :type => "collection")
|
28
|
+
assert( items.size > 9 )
|
29
|
+
|
30
|
+
counter = 0
|
31
|
+
WebDAV.find(url, :type => "collection") do |item|
|
32
|
+
counter += 1
|
33
|
+
end
|
34
|
+
assert(counter > 9 )
|
35
|
+
|
36
|
+
counter = 0
|
37
|
+
WebDAV.find(url + "2008/", :type => "collection", :recursive => true) do |item|
|
38
|
+
counter += 1
|
39
|
+
end
|
40
|
+
assert(counter > 9 )
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class BullShit
|
46
|
+
|
47
|
+
def test_find_recursive
|
48
|
+
count = 0
|
49
|
+
url = "https://vortex-dav.uio.no/brukere/thomasfl/anniken_2007/sophos/"
|
50
|
+
WebDAV.find(url, :recursive => true ) do | item |
|
51
|
+
if(item.basename == ".DS_Store")
|
52
|
+
count += 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
assert_equal(1, count)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_get
|
59
|
+
url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/2008/02/nynorsk-paa-nett.html"
|
60
|
+
item = WebDAV.propfind(url)
|
61
|
+
assert(item)
|
62
|
+
|
63
|
+
content = WebDAV.get(url)
|
64
|
+
assert( content =~ /\<html/ )
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_mkcol
|
69
|
+
url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/testcol/"
|
70
|
+
|
71
|
+
WebDAV.delete(url)
|
72
|
+
|
73
|
+
result = WebDAV.mkcol(url,nil)
|
74
|
+
assert(result)
|
75
|
+
col = WebDAV.propfind(url)
|
76
|
+
assert(col)
|
77
|
+
|
78
|
+
# TODO Set properties på collection
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_propfind
|
83
|
+
url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/"
|
84
|
+
item = WebDAV.propfind(url, :xml => true)
|
85
|
+
assert(item.class == String)
|
86
|
+
# puts "DEBUG:: " + item
|
87
|
+
|
88
|
+
item = WebDAV.propfind(url)
|
89
|
+
assert(item.class != String)
|
90
|
+
assert_equal(url, item.href)
|
91
|
+
assert_equal("Nyheter", item.title)
|
92
|
+
|
93
|
+
assert_nil(item.denne_finnes_virkelig_ikke)
|
94
|
+
|
95
|
+
# Properties should be readable with minor misspellings like wrong casing
|
96
|
+
assert(item.property("v:resourceType") ) # CamelCased
|
97
|
+
assert(item.property("v:resourcetype") ) # Downcase
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test/unit'
|
3
|
+
require 'test_helper'
|
4
|
+
require 'davclient'
|
5
|
+
|
6
|
+
HTML = <<EOF
|
7
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
8
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
9
|
+
<head>
|
10
|
+
<title>Test title</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<p>Test content</p>
|
14
|
+
</body>
|
15
|
+
</html>
|
16
|
+
EOF
|
17
|
+
|
18
|
+
props = <<EOF
|
19
|
+
<v:authors xmlns:v="vrtx">
|
20
|
+
<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">
|
21
|
+
<vrtx:value>Firstname Lastname</vrtx:value>
|
22
|
+
</vrtx:values>
|
23
|
+
</v:authors>
|
24
|
+
<v:resourceType xmlns:v="vrtx">article</v:resourceType>
|
25
|
+
<v:xhtml10-type xmlns:v="vrtx">article</v:xhtml10-type>
|
26
|
+
<v:published-date xmlns:v="vrtx">Wed, 22 Jul 2009 12:34:56 GMT</v:published-date>
|
27
|
+
<v:userspecifiedcharacterencoding xmlns:v="vrtx">utf-8</v:userspecifiedcharacterencoding>
|
28
|
+
<v:characterEncoding xmlns:v="vrtx">utf-8</v:characterEncoding>
|
29
|
+
EOF
|
30
|
+
PROPERTIES = props.gsub("\n","").gsub(/ +/," ")
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
class TestWebDAVLibPublish < Test::Unit::TestCase
|
35
|
+
|
36
|
+
|
37
|
+
def test_publish
|
38
|
+
url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/"
|
39
|
+
nyhet_url = url + "testnyhet_skal_slettes.html"
|
40
|
+
|
41
|
+
WebDAV.delete(nyhet_url)
|
42
|
+
nyhet = WebDAV.find(nyhet_url)
|
43
|
+
assert_nil(nyhet)
|
44
|
+
|
45
|
+
error = false
|
46
|
+
begin
|
47
|
+
WebDAV.publish(nyhet_url + "/", HTML, PROPERTIES )
|
48
|
+
rescue
|
49
|
+
error = true
|
50
|
+
end
|
51
|
+
assert(error)
|
52
|
+
|
53
|
+
WebDAV.publish(nyhet_url, HTML, PROPERTIES)
|
54
|
+
|
55
|
+
nyhet = WebDAV.propfind(nyhet_url)
|
56
|
+
assert(nyhet)
|
57
|
+
assert_equal("Test title", nyhet.title)
|
58
|
+
assert_equal("article", nyhet.resourcetype)
|
59
|
+
assert_equal("utf-8", nyhet.characterencoding)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tc_webdav_basic.rb'
|
3
|
+
require 'tc_webdav_publish.rb'
|
4
|
+
require 'tc_dav-cat.rb'
|
5
|
+
# require 'tc_dav-cd.rb'
|
6
|
+
# require 'tc_dav-cp.rb'
|
7
|
+
# require 'tc_dav-delete.rb'
|
8
|
+
# require 'tc_dav-ls.rb'
|
9
|
+
# require 'tc_dav-mkcol.rb'
|
10
|
+
# require 'tc_dav-mv.rb'
|
11
|
+
# require 'tc_dav-propfind.rb'
|