fernyb_davclient 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'rubygems'
4
+ require 'test/unit'
5
+ require 'davclient/util'
6
+ require 'davclient/curl_commands'
7
+
8
+ $cmd = <<EOF
9
+ curl --user thomasfl --request PROPFIND --header 'Content-Type: text/xml; charset="utf-8"' --header "Depth: 1" --data-ascii '<?xml version="1.0" encoding="utf-8"?><DAV:propfind xmlns:DAV="DAV:"><DAV:allprop/></DAV:propfind>' "https://vortex-dav.uio.no/brukere/thomasfl/testseminar/"
10
+ EOF
11
+
12
+ class TestUtil < Test::Unit::TestCase
13
+
14
+ def test_extract_host
15
+ assert_equal "host.host.com", DavClient.exctract_host("https://host.host.com/lots-of-rubbish")
16
+ assert_equal "host.host.com", DavClient.exctract_host("http://host.host.com?lots-of-rubbish")
17
+ assert_equal nil, DavClient.exctract_host("//not-an-url")
18
+ end
19
+
20
+ # Interactiv tests
21
+ def zzz_test_01_password_prompt
22
+ $username = nil
23
+ $password = nil
24
+ DavClient.prompt_for_username_and_password("host.host.com")
25
+ assert $username
26
+ assert $password
27
+ end
28
+
29
+ def zzz_test_02_spawn_curl
30
+ result = DavClient.spawn_curl($cmd, $password)
31
+ assert result =~ /d:multistatus/
32
+ result = DavClient.spawn_curl($cmd, "feil")
33
+ assert result =~ /401 Unauthorized/
34
+ cmd = $cmd.sub("--user thomasfl","--netrc")
35
+ result = DavClient.spawn_curl(cmd, nil)
36
+ assert result =~ /d:multistatus/
37
+ end
38
+
39
+ end
@@ -0,0 +1,86 @@
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
+ def test_01_hpricot_extensions
12
+ url = "https://vortex-dav.uio.no/brukere/thomasfl/"
13
+ test_content = "<html><head><title>title</title></head><body>one two three</body></html>"
14
+ WebDAV.delete(url + "testcase")
15
+ WebDAV.mkcol(url + "testcase")
16
+ WebDAV.publish(url + "testcase/test_page.html", test_content,nil)
17
+
18
+ webpage = nil
19
+ WebDAV.find(url + "testcase/") do |item|
20
+ webpage = item
21
+ end
22
+
23
+ # puts webpage.href
24
+ # puts "content: " + webpage.content
25
+
26
+ webpage.content = webpage.content.gsub(/two/,"2")
27
+
28
+ webpage = nil
29
+ WebDAV.find(url + "testcase/") do |item|
30
+ webpage = item
31
+ end
32
+ assert webpage.content =~ /one 2 three/
33
+
34
+ end
35
+
36
+ def test_find
37
+ url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/"
38
+ items = WebDAV.find(url)
39
+ assert(items.size > 10 )
40
+
41
+ antall = items.size
42
+ WebDAV.cd(url)
43
+ items = WebDAV.find()
44
+ assert_equal(antall, items.size )
45
+
46
+ assert_raise RuntimeError do
47
+ WebDAV.CWURL = nil
48
+ items = WebDAV.find()
49
+ end
50
+
51
+ items = WebDAV.find(url, :type => "collection")
52
+ assert( items.size > 9 )
53
+
54
+ counter = 0
55
+ WebDAV.find(url, :type => "collection") do |item|
56
+ counter += 1
57
+ end
58
+ assert(counter > 9 )
59
+
60
+ counter = 0
61
+ WebDAV.find(url + "2008/", :type => "collection", :recursive => true) do |item|
62
+ counter += 1
63
+ end
64
+ assert(counter > 9 )
65
+ end
66
+
67
+ def test_propfind
68
+ url = "https://vortex-dav.uio.no/prosjekter/it-avisa/nyheter/"
69
+ item = WebDAV.propfind(url, :xml => true)
70
+ assert(item.class == String)
71
+ # puts "DEBUG:: " + item
72
+
73
+ item = WebDAV.propfind(url)
74
+ assert(item.class != String)
75
+ assert_equal(url, item.href)
76
+ assert_equal("Nyheter", item.title)
77
+
78
+ assert_nil(item.denne_finnes_virkelig_ikke)
79
+
80
+ # Properties should be readable with minor misspellings like wrong casing
81
+ assert(item.property("v:resourceType") ) # CamelCased
82
+ assert(item.property("v:resourcetype") ) # Downcase
83
+
84
+ end
85
+
86
+ 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,2 @@
1
+ $LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
2
+
@@ -0,0 +1,12 @@
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'
12
+ require 'tc_property_file.rb'
data/todo ADDED
@@ -0,0 +1,32 @@
1
+ TODO
2
+
3
+ DavClient - Add new functionality
4
+ =================================
5
+
6
+ - Read options from config file, like default homepage url.
7
+ Make 'dav ls' go to some sort of homepage. Use .davclient
8
+
9
+
10
+ - PUT
11
+ - put *.html
12
+ - put -s "<html>..</html>" filename.html
13
+
14
+ - GET
15
+ - get remote_file.html
16
+ - get remote_collection
17
+
18
+ - More authentication options than using the ~/.netrc file.
19
+
20
+ - Implement these WebDAV functions
21
+
22
+ - COPY
23
+ - MOVE
24
+ - LOCK
25
+ - UNLOCK
26
+
27
+ - Other commands implemented in cadaver: http://linux.die.net/man/1/cadaver
28
+
29
+ - propnames
30
+ - propset prop value
31
+
32
+
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fernyb_davclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Flemming
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-15 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: echoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Command line WebDAV client and Ruby library.
26
+ email: thomasfl@usit.uio.no
27
+ executables:
28
+ - dav
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - bin/dav
33
+ - lib/davclient/curl_commands.rb
34
+ - lib/davclient/dav-ls.rb
35
+ - lib/davclient/dav-propfind.rb
36
+ - lib/davclient/dav-put.rb
37
+ - lib/davclient/davcli.rb
38
+ - lib/davclient/hpricot_extensions.rb
39
+ - lib/davclient/simple.rb
40
+ - lib/davclient/termutil.rb
41
+ - lib/davclient/util.rb
42
+ - lib/davclient.rb
43
+ - LICENSE
44
+ - README.rdoc
45
+ files:
46
+ - bin/dav
47
+ - examples/clean_files.rb
48
+ - examples/meta_tags_in_use.rb
49
+ - examples/remove_ds_store.rb
50
+ - examples/scrape_site.rb
51
+ - examples/simple_find.rb
52
+ - fernyb_davclient.gemspec
53
+ - lib/davclient/curl_commands.rb
54
+ - lib/davclient/dav-ls.rb
55
+ - lib/davclient/dav-propfind.rb
56
+ - lib/davclient/dav-put.rb
57
+ - lib/davclient/davcli.rb
58
+ - lib/davclient/hpricot_extensions.rb
59
+ - lib/davclient/simple.rb
60
+ - lib/davclient/termutil.rb
61
+ - lib/davclient/util.rb
62
+ - lib/davclient.rb
63
+ - LICENSE
64
+ - Manifest
65
+ - Rakefile
66
+ - README.rdoc
67
+ - tests/dav.rb
68
+ - tests/tc_dav-cat.rb
69
+ - tests/tc_dav-cd.rb
70
+ - tests/tc_dav-cp.rb
71
+ - tests/tc_dav-delete.rb
72
+ - tests/tc_dav-get.rb
73
+ - tests/tc_dav-ls.rb
74
+ - tests/tc_dav-mkcol.rb
75
+ - tests/tc_dav-mv.rb
76
+ - tests/tc_dav-propfind.rb
77
+ - tests/tc_dav-put.rb
78
+ - tests/tc_util.rb
79
+ - tests/tc_webdav_basic.rb
80
+ - tests/tc_webdav_publish.rb
81
+ - tests/test_helper.rb
82
+ - tests/ts_davclient.rb
83
+ - todo
84
+ has_rdoc: true
85
+ homepage: http://davclient.rubyforge.org/davclient
86
+ licenses: []
87
+
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --line-numbers
91
+ - --inline-source
92
+ - --title
93
+ - Fernyb_davclient
94
+ - --main
95
+ - README.rdoc
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0"
103
+ version:
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: "1.2"
109
+ version:
110
+ requirements: []
111
+
112
+ rubyforge_project: fernyb_davclient
113
+ rubygems_version: 1.3.5
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Command line WebDAV client and Ruby library.
117
+ test_files: []
118
+