sabredav_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +46 -0
- data/README.md +131 -0
- data/Rakefile +6 -0
- data/lib/sabredav_client/calendar.rb +111 -0
- data/lib/sabredav_client/client.rb +57 -0
- data/lib/sabredav_client/errors/errors.rb +38 -0
- data/lib/sabredav_client/events.rb +97 -0
- data/lib/sabredav_client/format.rb +54 -0
- data/lib/sabredav_client/net.rb +15 -0
- data/lib/sabredav_client/principal.rb +36 -0
- data/lib/sabredav_client/request.rb +97 -0
- data/lib/sabredav_client/version.rb +3 -0
- data/lib/sabredav_client/xml_request_builder/base.rb +17 -0
- data/lib/sabredav_client/xml_request_builder/mkcalendar.rb +25 -0
- data/lib/sabredav_client/xml_request_builder/mkcol_principal.rb +28 -0
- data/lib/sabredav_client/xml_request_builder/post_sharing.rb +41 -0
- data/lib/sabredav_client/xml_request_builder/propfind_calendar.rb +41 -0
- data/lib/sabredav_client/xml_request_builder/propfind_owner.rb +19 -0
- data/lib/sabredav_client/xml_request_builder/proppatch_owner.rb +23 -0
- data/lib/sabredav_client/xml_request_builder/report_event_changes.rb +22 -0
- data/lib/sabredav_client/xml_request_builder/report_vevent.rb +30 -0
- data/lib/sabredav_client/xml_request_builder/report_vtodo.rb +20 -0
- data/lib/sabredav_client/xml_request_builder.rb +6 -0
- data/lib/sabredav_client.rb +12 -0
- data/sabredav_client.gemspec +33 -0
- data/spec/fixtures/calendar_fetch_changes.xml +26 -0
- data/spec/fixtures/calendar_info.xml +14 -0
- data/spec/fixtures/event.ics +23 -0
- data/spec/fixtures/events_find_multiple.xml +51 -0
- data/spec/fixtures/events_owner.xml +12 -0
- data/spec/fixtures/xml_request_builder/mkcalendar.xml +9 -0
- data/spec/fixtures/xml_request_builder/mkcol_principal.xml +12 -0
- data/spec/fixtures/xml_request_builder/post_sharing.xml +18 -0
- data/spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml +8 -0
- data/spec/fixtures/xml_request_builder/propfind_owner.xml +6 -0
- data/spec/fixtures/xml_request_builder/proppatch_owner.xml +8 -0
- data/spec/fixtures/xml_request_builder/report_event_changes.xml +8 -0
- data/spec/sabredav_client/calendar_spec.rb +101 -0
- data/spec/sabredav_client/client_spec.rb +41 -0
- data/spec/sabredav_client/events_spec.rb +91 -0
- data/spec/sabredav_client/principal_spec.rb +38 -0
- data/spec/sabredav_client/request_spec.rb +55 -0
- data/spec/sabredav_client/xml_request_builder_specs/base_spec.rb +30 -0
- data/spec/sabredav_client/xml_request_builder_specs/mkcalendar_spec.rb +13 -0
- data/spec/sabredav_client/xml_request_builder_specs/mkcol_principal_spec.rb +13 -0
- data/spec/sabredav_client/xml_request_builder_specs/post_sharing_spec.rb +15 -0
- data/spec/sabredav_client/xml_request_builder_specs/propfind_calendar_spec.rb +24 -0
- data/spec/sabredav_client/xml_request_builder_specs/propfind_owner_spec.rb +14 -0
- data/spec/sabredav_client/xml_request_builder_specs/proppatch_owner_spec.rb +14 -0
- data/spec/sabredav_client/xml_request_builder_specs/report_event_changes_spec.rb +15 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +8 -0
- metadata +185 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Calendar do
|
4
|
+
|
5
|
+
let(:calendar) { SabredavClient::Calendar.new(:uri => "http://localhost:5232/user/calendar", :user => "user" , :password => "") }
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "check Class of new calendar" do
|
10
|
+
expect(calendar).to be_a(SabredavClient::Calendar)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "request configuration is available" do
|
14
|
+
expect(calendar.client).to be_a(SabredavClient::Client)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "events" do
|
20
|
+
|
21
|
+
it "events returns Events class" do
|
22
|
+
expect(calendar.events).to be_a(SabredavClient::Events)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "calendar" do
|
27
|
+
|
28
|
+
it "create" do
|
29
|
+
displayname = "Test Calendar"
|
30
|
+
ctag = "http://sabre.io/ns/sync/15"
|
31
|
+
sync_token = ctag
|
32
|
+
|
33
|
+
FakeWeb.register_uri(:mkcalendar, %r{http://user@localhost:5232/user/calendar}, status: ["201", "Created"])
|
34
|
+
FakeWeb.register_uri(:propfind, %r{http://user@localhost:5232/user/calendar}, status: ["200", "OK"], body: File.open("spec/fixtures/calendar_info.xml"))
|
35
|
+
|
36
|
+
r = calendar.create(displayname: displayname)
|
37
|
+
|
38
|
+
expect(r[:displayname]).to eq(displayname)
|
39
|
+
expect(r[:ctag]).to eq(ctag)
|
40
|
+
expect(r[:sync_token]).to eq(sync_token)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "delete" do
|
44
|
+
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/",
|
45
|
+
[{status: ["204", "No Content"]}, {status: ["404", "Not Found"]}])
|
46
|
+
r = calendar.delete
|
47
|
+
expect(r).to be(true)
|
48
|
+
|
49
|
+
expect {
|
50
|
+
calendar.delete
|
51
|
+
}.to raise_error(SabredavClient::Errors::NotFoundError)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "shares" do
|
56
|
+
FakeWeb.register_uri(:post, "http://user@localhost:5232/user/calendar/", [{status: ["200", "OK"]},
|
57
|
+
{status: ["200", "OK"]}])
|
58
|
+
it "is type email" do
|
59
|
+
type = :email
|
60
|
+
r = calendar.share adds: ["test@test.de"], privilege: "write-read"
|
61
|
+
expect(r).to be(true)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "is not type email" do
|
65
|
+
type = :other
|
66
|
+
expect {
|
67
|
+
calendar.share adds: ["test@test.de"], privilege: "write-read", type: type
|
68
|
+
}.to raise_error(SabredavClient::Errors::ShareeTypeNotSupportedError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "add one share" do
|
72
|
+
r = calendar.share(adds: ["test@test.de"], privilege: "write-read")
|
73
|
+
expect(r).to be(true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "info" do
|
78
|
+
it "fetches the calendar info" do
|
79
|
+
FakeWeb.register_uri(:propfind, "http://user@localhost:5232/user/calendar/", body: File.open('spec/fixtures/calendar_info.xml') )
|
80
|
+
info = calendar.info
|
81
|
+
|
82
|
+
expect(info[:displayname]).to eq("Test Calendar")
|
83
|
+
expect(info[:ctag]).to eq("http://sabre.io/ns/sync/15")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "fetch changes" do
|
88
|
+
new_sync_token = "http://sabredav.org/ns/sync/5001"
|
89
|
+
deletions = [ "deletedevent.ics" ]
|
90
|
+
changes = [ {uri: "newevent.ics", etag: "\"1\""}, {uri: "updatedevent.ics", etag: "\"2\""}]
|
91
|
+
|
92
|
+
it "got two changes and one deletion" do
|
93
|
+
FakeWeb.register_uri(:report, "http://user@localhost:5232/user/calendar/", body: File.open('spec/fixtures/calendar_fetch_changes.xml') )
|
94
|
+
result = calendar.fetch_changes("random_token")
|
95
|
+
expect(result[:deletions]).to eq deletions
|
96
|
+
expect(result[:changes]).to eq changes
|
97
|
+
expect(result[:sync_token]).to eq new_sync_token
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Client do
|
4
|
+
|
5
|
+
let!(:client) { SabredavClient::Client.new(:uri => "http://localhost:5232/user/principals/user", :user => "user" , :password => "" ) }
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "no encryption and basic_auth" do
|
10
|
+
#TODO
|
11
|
+
end
|
12
|
+
|
13
|
+
it "with ssl and basic authentification" do
|
14
|
+
client = SabredavClient::Client.new(:uri => "https://localhost:5232/user/principals/user", :user => "user" , :password => "" )
|
15
|
+
|
16
|
+
expect(client.host).to be
|
17
|
+
expect(client.port).to be
|
18
|
+
expect(client.user).to be
|
19
|
+
expect(client.base_path).to be
|
20
|
+
expect(client.ssl).to be
|
21
|
+
expect(client.password).to be
|
22
|
+
expect(client.authtype).to eq("basic")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "proxy usage" do
|
26
|
+
#TODO
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "create_request" do
|
31
|
+
|
32
|
+
it " with header and body" do
|
33
|
+
method = :report
|
34
|
+
body = "xml_file"
|
35
|
+
header = {content_type: "application/xml"}
|
36
|
+
res = client.create_request(method, header: header, body: body)
|
37
|
+
expect(res.request.body).to eq(body)
|
38
|
+
expect(res.request.to_hash).to include("content-type" => ["application/xml"])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Events do
|
4
|
+
client = SabredavClient::Client.new(uri: "http://localhost:5232/user/calendar", user: "user", password: "")
|
5
|
+
let!(:events) { described_class.new(client = client) }
|
6
|
+
|
7
|
+
describe "initialization" do
|
8
|
+
|
9
|
+
it "client" do
|
10
|
+
|
11
|
+
expect(events.client).to be_a(SabredavClient::Client)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "delete" do
|
16
|
+
|
17
|
+
it "one event" do
|
18
|
+
uri = "event.ics"
|
19
|
+
FakeWeb.register_uri(:delete, "http://user@localhost:5232/user/calendar/#{uri}",
|
20
|
+
[{:body => "1 deleted.", :status => ["200", "OK"]},
|
21
|
+
{:body => "not found", :status => ["404", "Not Found"]}])
|
22
|
+
r = events.delete(uri)
|
23
|
+
|
24
|
+
expect(r).to be(true)
|
25
|
+
expect {
|
26
|
+
events.delete(uri)
|
27
|
+
}.to raise_error(SabredavClient::Errors::NotFoundError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "find one event" do
|
32
|
+
|
33
|
+
it "one event" do
|
34
|
+
uid = "47732F70-1793-47B3-80FA-57E3C5ECA0E5"
|
35
|
+
uri = "#{uid}.ics"
|
36
|
+
FakeWeb.register_uri(:get, "http://user@localhost:5232/user/calendar/#{uri}", :body => File.open("spec/fixtures/event.ics"))
|
37
|
+
r = events.find(uri)
|
38
|
+
|
39
|
+
expect(r).to be_a(String)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "two events" do
|
43
|
+
FakeWeb.register_uri(:report, "http://user@localhost:5232/user/calendar/", body: File.open('spec/fixtures/events_find_multiple.xml'))
|
44
|
+
r = events.find_multiple(starts: "2001-02-02 07:00", ends: "2000-02-03 23:59")
|
45
|
+
|
46
|
+
expect(r.first).to be_a(Icalendar::Event)
|
47
|
+
expect(r.length).to eq 2
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "create_update" do
|
52
|
+
etag = "123"
|
53
|
+
uri = "event.ics"
|
54
|
+
event_ics = File.open('spec/fixtures/event.ics')
|
55
|
+
|
56
|
+
it "create event" do
|
57
|
+
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {etag: etag, status: ["201", "OK"]})
|
58
|
+
r = events.create_update(uri, event_ics.to_s)
|
59
|
+
|
60
|
+
expect(r).to eq etag
|
61
|
+
end
|
62
|
+
|
63
|
+
it "update event" do
|
64
|
+
new_etag = "124"
|
65
|
+
FakeWeb.register_uri(:put, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], etag: new_etag})
|
66
|
+
r = events.create_update(uri, event_ics.to_s, etag )
|
67
|
+
|
68
|
+
expect(r).not_to eq etag
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "owner" do
|
73
|
+
uri = "event.ics"
|
74
|
+
|
75
|
+
it "find" do
|
76
|
+
owner = "principals/usertest"
|
77
|
+
FakeWeb.register_uri(:propfind, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"], body: File.open("spec/fixtures/events_owner.xml")})
|
78
|
+
r = events.owner(uri)
|
79
|
+
|
80
|
+
expect(r).to eq(owner)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "update" do
|
84
|
+
FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/calendar/#{uri}", {status: ["200", "OK"]})
|
85
|
+
r = events.update_owner(uri, "principals/usertest")
|
86
|
+
|
87
|
+
expect(r).to be
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::Client do
|
4
|
+
|
5
|
+
let(:principal) { SabredavClient::Principal.new(:uri => "http://localhost:5232/user/principals/user", :user => "user" , :password => "") }
|
6
|
+
|
7
|
+
|
8
|
+
describe "initialization" do
|
9
|
+
|
10
|
+
it "client available" do
|
11
|
+
expect(principal.client).to be_a(SabredavClient::Client)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "principal" do
|
16
|
+
email = "test@mail.de"
|
17
|
+
description = "a random description"
|
18
|
+
|
19
|
+
it "create with description" do
|
20
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
21
|
+
result = principal.create(email, description)
|
22
|
+
expect(result).to be
|
23
|
+
end
|
24
|
+
|
25
|
+
it "create without description" do
|
26
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["201", "Created"])
|
27
|
+
result = principal.create(email)
|
28
|
+
expect(result).to be
|
29
|
+
end
|
30
|
+
|
31
|
+
it "create fails because resource already exists" do
|
32
|
+
FakeWeb.register_uri(:mkcol, "http://user@localhost:5232/user/principals/user/", status: ["405", "Method not allowed"])
|
33
|
+
expect {
|
34
|
+
principal.create(email)
|
35
|
+
}.to raise_error(SabredavClient::Errors::NotAllowedError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::Request do
|
4
|
+
let!(:client) { SabredavClient::Client.new(:uri => "http://localhost:5232/user/calendar", :user => "user" , :password => "") }
|
5
|
+
path = ""
|
6
|
+
|
7
|
+
describe "initialize" do
|
8
|
+
let!(:request) { SabredavClient::Request.new(:get, client, path) }
|
9
|
+
|
10
|
+
it "tests supported http methods" do
|
11
|
+
methods = [:put, :get, :post, :mkcalendar, :propfind, :proppatch, :report, :delete, :mkcol]
|
12
|
+
methods.each do |method|
|
13
|
+
res = SabredavClient::Request.new(method, client, path)
|
14
|
+
expect(res).to be_a SabredavClient::Request
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises error if method not supported" do
|
19
|
+
method = :foobar
|
20
|
+
expect { res = SabredavClient::Request.new(method, client, path)
|
21
|
+
}.to raise_error SabredavClient::Errors::HTTPMethodNotSupportedError
|
22
|
+
end
|
23
|
+
|
24
|
+
it "testes existence of http object" do
|
25
|
+
expect(request.http).to be_a Net::HTTP
|
26
|
+
end
|
27
|
+
|
28
|
+
it "tests existence of path" do
|
29
|
+
expect(request.path).to be
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "add" do
|
34
|
+
let!(:request) { SabredavClient::Request.new(:put, client, path: "random.ics") }
|
35
|
+
|
36
|
+
it "header attributes" do
|
37
|
+
request.add_header(content_type: "application/xml",
|
38
|
+
content_length: "xxxx",
|
39
|
+
if_match: "etag",
|
40
|
+
dav: "resource-must-be-null")
|
41
|
+
req = request.request.to_hash
|
42
|
+
expect(req["content-type"]).to include "application/xml"
|
43
|
+
expect(req["content-length"]).to include "xxxx"
|
44
|
+
expect(req["if-match"]).to include "etag"
|
45
|
+
expect(req["dav"]).to include "resource-must-be-null"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "body" do
|
49
|
+
body = "some content"
|
50
|
+
request.add_body(body)
|
51
|
+
expect(request.request.body).to eq body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::XmlRequestBuilder::Base do
|
4
|
+
|
5
|
+
let(:base) { described_class.new() }
|
6
|
+
|
7
|
+
describe "module constants" do
|
8
|
+
|
9
|
+
it "to be there" do
|
10
|
+
NAMESPACE = {"xmlns:d" => 'DAV:'}
|
11
|
+
C_NAMESPACES = {"xmlns:d" => 'DAV:', "xmlns:c" => "urn:ietf:params:xml:ns:caldav"}
|
12
|
+
CS_NAMESPACES = {"xmlns:d" => 'DAV:', "xmlns:cs" => "http://calendarserver.org/ns/"}
|
13
|
+
SB_NAMESPACES = {"xmlns:d" => 'DAV:', "xmlns:sb" => "http://sabredav.org/ns"}
|
14
|
+
|
15
|
+
expect(SabredavClient::XmlRequestBuilder::NAMESPACE).to eq NAMESPACE
|
16
|
+
expect(SabredavClient::XmlRequestBuilder::C_NAMESPACES).to eq C_NAMESPACES
|
17
|
+
expect(SabredavClient::XmlRequestBuilder::CS_NAMESPACES).to eq CS_NAMESPACES
|
18
|
+
expect(SabredavClient::XmlRequestBuilder::SB_NAMESPACES).to eq SB_NAMESPACES
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "initialization" do
|
23
|
+
indent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kind_of?>Builder::XmlMarkup</kind_of?>\n<indent/>\n"
|
24
|
+
|
25
|
+
it "xml indent is correct" do
|
26
|
+
expect(base.xml).to be_a Builder::XmlMarkup
|
27
|
+
expect(base.xml.indent).to eq indent
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::Mkcalendar do
|
4
|
+
let(:mkcalendar) { described_class.new(displayname = "name", description = "description") }
|
5
|
+
|
6
|
+
describe "#to_xml" do
|
7
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/mkcalendar.xml') }
|
8
|
+
|
9
|
+
it "returns a valid xml" do
|
10
|
+
expect(mkcalendar.to_xml).to eq(expected_xml)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::MkcolPrincipal do
|
4
|
+
let(:mkcol) { described_class.new(email = "test@test.de", displayname = "usertest") }
|
5
|
+
|
6
|
+
describe "#to_xml" do
|
7
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/mkcol_principal.xml') }
|
8
|
+
|
9
|
+
it "returns a valid xml with displayname" do
|
10
|
+
expect(mkcol.to_xml).to eq(expected_xml)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::PostSharing do
|
4
|
+
let(:post) { described_class.new(adds = ["add1@test.de", "add2@test.de"],
|
5
|
+
summary = "title", common_name = "common_name", privilege = "read-write",
|
6
|
+
removes = ["remove@test.de"]) }
|
7
|
+
|
8
|
+
describe "#to_xml" do
|
9
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/post_sharing.xml') }
|
10
|
+
|
11
|
+
it "returns a valid xml" do
|
12
|
+
expect(post.to_xml).to eq(expected_xml)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::PROPFINDCalendar do
|
4
|
+
let(:propfind) { described_class.new(properties: [:displayname, :getctag, :sync_token]) }
|
5
|
+
|
6
|
+
describe "#to_xml" do
|
7
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml') }
|
8
|
+
|
9
|
+
it "returns a valid xml" do
|
10
|
+
expect(propfind.to_xml).to eq(expected_xml)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "error" do
|
14
|
+
let(:propfind) { described_class.new(properties: [:displayname, :etag, :sync_token]) }
|
15
|
+
|
16
|
+
it "raises an error if the not supported properties are selected" do
|
17
|
+
expect {
|
18
|
+
propfind.to_xml
|
19
|
+
}.to raise_error(SabredavClient::Errors::PropertyNotSupportedError)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::PropfindOwner do
|
4
|
+
|
5
|
+
let(:propfind) { described_class.new }
|
6
|
+
|
7
|
+
describe "#to_xml" do
|
8
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/propfind_owner.xml') }
|
9
|
+
|
10
|
+
it "returns a valid xml" do
|
11
|
+
expect(propfind.to_xml).to eq(expected_xml)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SabredavClient::XmlRequestBuilder::ProppatchOwner do
|
4
|
+
|
5
|
+
let(:proppatch) { described_class.new(owner = "principals/usertest") }
|
6
|
+
|
7
|
+
describe "#to_xml" do
|
8
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/proppatch_owner.xml') }
|
9
|
+
|
10
|
+
it "returns a valid xml" do
|
11
|
+
expect(proppatch.to_xml).to eq(expected_xml)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SabredavClient::XmlRequestBuilder::ReportEventChanges do
|
4
|
+
|
5
|
+
let(:report) { described_class.new(sync_token = "token-1234") }
|
6
|
+
|
7
|
+
describe "#to_xml" do
|
8
|
+
let(:expected_xml) { File.read('spec/fixtures/xml_request_builder/report_event_changes.xml') }
|
9
|
+
|
10
|
+
it "returns a valid xml with displayname" do
|
11
|
+
expect(report.to_xml).to eq(expected_xml)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sabredav_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolas Schwartau
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: icalendar
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: uuid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: builder
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: net-http-digest_auth
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakeweb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
97
|
+
description: " sabredav_client is a great Ruby client for SabreDAV servers. It is
|
98
|
+
based on the agcaldav gem.\n"
|
99
|
+
email:
|
100
|
+
- n.schwartau@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- CHANGELOG.rdoc
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/sabredav_client.rb
|
113
|
+
- lib/sabredav_client/calendar.rb
|
114
|
+
- lib/sabredav_client/client.rb
|
115
|
+
- lib/sabredav_client/errors/errors.rb
|
116
|
+
- lib/sabredav_client/events.rb
|
117
|
+
- lib/sabredav_client/format.rb
|
118
|
+
- lib/sabredav_client/net.rb
|
119
|
+
- lib/sabredav_client/principal.rb
|
120
|
+
- lib/sabredav_client/request.rb
|
121
|
+
- lib/sabredav_client/version.rb
|
122
|
+
- lib/sabredav_client/xml_request_builder.rb
|
123
|
+
- lib/sabredav_client/xml_request_builder/base.rb
|
124
|
+
- lib/sabredav_client/xml_request_builder/mkcalendar.rb
|
125
|
+
- lib/sabredav_client/xml_request_builder/mkcol_principal.rb
|
126
|
+
- lib/sabredav_client/xml_request_builder/post_sharing.rb
|
127
|
+
- lib/sabredav_client/xml_request_builder/propfind_calendar.rb
|
128
|
+
- lib/sabredav_client/xml_request_builder/propfind_owner.rb
|
129
|
+
- lib/sabredav_client/xml_request_builder/proppatch_owner.rb
|
130
|
+
- lib/sabredav_client/xml_request_builder/report_event_changes.rb
|
131
|
+
- lib/sabredav_client/xml_request_builder/report_vevent.rb
|
132
|
+
- lib/sabredav_client/xml_request_builder/report_vtodo.rb
|
133
|
+
- sabredav_client.gemspec
|
134
|
+
- spec/fixtures/calendar_fetch_changes.xml
|
135
|
+
- spec/fixtures/calendar_info.xml
|
136
|
+
- spec/fixtures/event.ics
|
137
|
+
- spec/fixtures/events_find_multiple.xml
|
138
|
+
- spec/fixtures/events_owner.xml
|
139
|
+
- spec/fixtures/xml_request_builder/mkcalendar.xml
|
140
|
+
- spec/fixtures/xml_request_builder/mkcol_principal.xml
|
141
|
+
- spec/fixtures/xml_request_builder/post_sharing.xml
|
142
|
+
- spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml
|
143
|
+
- spec/fixtures/xml_request_builder/propfind_owner.xml
|
144
|
+
- spec/fixtures/xml_request_builder/proppatch_owner.xml
|
145
|
+
- spec/fixtures/xml_request_builder/report_event_changes.xml
|
146
|
+
- spec/sabredav_client/calendar_spec.rb
|
147
|
+
- spec/sabredav_client/client_spec.rb
|
148
|
+
- spec/sabredav_client/events_spec.rb
|
149
|
+
- spec/sabredav_client/principal_spec.rb
|
150
|
+
- spec/sabredav_client/request_spec.rb
|
151
|
+
- spec/sabredav_client/xml_request_builder_specs/base_spec.rb
|
152
|
+
- spec/sabredav_client/xml_request_builder_specs/mkcalendar_spec.rb
|
153
|
+
- spec/sabredav_client/xml_request_builder_specs/mkcol_principal_spec.rb
|
154
|
+
- spec/sabredav_client/xml_request_builder_specs/post_sharing_spec.rb
|
155
|
+
- spec/sabredav_client/xml_request_builder_specs/propfind_calendar_spec.rb
|
156
|
+
- spec/sabredav_client/xml_request_builder_specs/propfind_owner_spec.rb
|
157
|
+
- spec/sabredav_client/xml_request_builder_specs/proppatch_owner_spec.rb
|
158
|
+
- spec/sabredav_client/xml_request_builder_specs/report_event_changes_spec.rb
|
159
|
+
- spec/spec.opts
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
homepage: https://github.com/njiuko/sabredav_client
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.9.2
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.5.1
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Ruby SabreDAV client
|
185
|
+
test_files: []
|