sabredav_client 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -3
  3. data/.rspec +1 -1
  4. data/CHANGELOG.rdoc +8 -8
  5. data/Gemfile +3 -3
  6. data/Gemfile.lock +38 -39
  7. data/README.md +49 -49
  8. data/Rakefile +5 -5
  9. data/lib/sabredav_client.rb +10 -10
  10. data/lib/sabredav_client/calendar.rb +174 -171
  11. data/lib/sabredav_client/client.rb +57 -57
  12. data/lib/sabredav_client/errors/errors.rb +41 -41
  13. data/lib/sabredav_client/events.rb +106 -106
  14. data/lib/sabredav_client/net.rb +15 -15
  15. data/lib/sabredav_client/principal.rb +51 -51
  16. data/lib/sabredav_client/request.rb +97 -97
  17. data/lib/sabredav_client/version.rb +3 -3
  18. data/lib/sabredav_client/xml_request_builder.rb +7 -7
  19. data/lib/sabredav_client/xml_request_builder/base.rb +17 -17
  20. data/lib/sabredav_client/xml_request_builder/mkcalendar.rb +25 -25
  21. data/lib/sabredav_client/xml_request_builder/mkcol_principal.rb +28 -28
  22. data/lib/sabredav_client/xml_request_builder/post_sharing.rb +41 -41
  23. data/lib/sabredav_client/xml_request_builder/propfind_calendar.rb +41 -41
  24. data/lib/sabredav_client/xml_request_builder/propfind_invite.rb +19 -19
  25. data/lib/sabredav_client/xml_request_builder/propfind_owner.rb +19 -19
  26. data/lib/sabredav_client/xml_request_builder/proppatch_calendar.rb +25 -25
  27. data/lib/sabredav_client/xml_request_builder/proppatch_events_owner.rb +23 -23
  28. data/lib/sabredav_client/xml_request_builder/proppatch_principal.rb +25 -25
  29. data/lib/sabredav_client/xml_request_builder/report_event_changes.rb +22 -22
  30. data/lib/sabredav_client/xml_request_builder/report_vevent.rb +30 -30
  31. data/lib/sabredav_client/xml_request_builder/report_vtodo.rb +20 -20
  32. data/sabredav_client.gemspec +31 -31
  33. data/spec/fixtures/calendar_fetch_changes.xml +26 -26
  34. data/spec/fixtures/calendar_info.xml +14 -14
  35. data/spec/fixtures/calendar_sharees.xml +35 -35
  36. data/spec/fixtures/calendar_sharees_without_common_name.xml +26 -26
  37. data/spec/fixtures/event.ics +23 -23
  38. data/spec/fixtures/events_find_multiple.xml +51 -51
  39. data/spec/fixtures/events_owner.xml +12 -12
  40. data/spec/fixtures/xml_request_builder/mkcalendar.xml +9 -9
  41. data/spec/fixtures/xml_request_builder/mkcol_principal.xml +12 -12
  42. data/spec/fixtures/xml_request_builder/post_sharing.xml +18 -18
  43. data/spec/fixtures/xml_request_builder/propfind_calendar/all_properties.xml +8 -8
  44. data/spec/fixtures/xml_request_builder/propfind_invite.xml +6 -6
  45. data/spec/fixtures/xml_request_builder/propfind_owner.xml +6 -6
  46. data/spec/fixtures/xml_request_builder/proppatch_calendar.xml +9 -9
  47. data/spec/fixtures/xml_request_builder/proppatch_events_owner.xml +8 -8
  48. data/spec/fixtures/xml_request_builder/proppatch_principal.xml +9 -9
  49. data/spec/fixtures/xml_request_builder/report_event_changes.xml +8 -8
  50. data/spec/sabredav_client/calendar_spec.rb +142 -142
  51. data/spec/sabredav_client/client_spec.rb +41 -41
  52. data/spec/sabredav_client/events_spec.rb +119 -119
  53. data/spec/sabredav_client/principal_spec.rb +51 -51
  54. data/spec/sabredav_client/request_spec.rb +55 -55
  55. data/spec/sabredav_client/xml_request_builder_specs/base_spec.rb +30 -30
  56. data/spec/sabredav_client/xml_request_builder_specs/mkcalendar_spec.rb +13 -13
  57. data/spec/sabredav_client/xml_request_builder_specs/mkcol_principal_spec.rb +13 -13
  58. data/spec/sabredav_client/xml_request_builder_specs/post_sharing_spec.rb +15 -15
  59. data/spec/sabredav_client/xml_request_builder_specs/propfind_calendar_spec.rb +24 -24
  60. data/spec/sabredav_client/xml_request_builder_specs/propfind_invite_spec.rb +14 -14
  61. data/spec/sabredav_client/xml_request_builder_specs/propfind_owner_spec.rb +14 -14
  62. data/spec/sabredav_client/xml_request_builder_specs/proppatch_calendar.rb +15 -15
  63. data/spec/sabredav_client/xml_request_builder_specs/proppatch_events_owner_spec.rb +14 -14
  64. data/spec/sabredav_client/xml_request_builder_specs/proppatch_principal_spec.rb +24 -24
  65. data/spec/sabredav_client/xml_request_builder_specs/report_event_changes_spec.rb +15 -15
  66. data/spec/spec.opts +4 -4
  67. data/spec/spec_helper.rb +8 -8
  68. metadata +6 -5
@@ -1,51 +1,51 @@
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 "create" 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
-
39
- describe "update" do
40
-
41
- it "updates email and displayname" do
42
- email = "update@test.de"
43
- displayname = "David B."
44
- FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/principals/user/", status: ["207", "OK"])
45
-
46
- result = principal.update(email: email, displayname: displayname)
47
- expect(result).to be
48
-
49
- end
50
- end
51
- end
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 "create" 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
+
39
+ describe "update" do
40
+
41
+ it "updates email and displayname" do
42
+ email = "update@test.de"
43
+ displayname = "David B."
44
+ FakeWeb.register_uri(:proppatch, "http://user@localhost:5232/user/principals/user/", status: ["207", "OK"])
45
+
46
+ result = principal.update(email: email, displayname: displayname)
47
+ expect(result).to be
48
+
49
+ end
50
+ end
51
+ end
@@ -1,55 +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
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
@@ -1,30 +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
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
@@ -1,13 +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
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
@@ -1,13 +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
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
@@ -1,15 +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
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
@@ -1,24 +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
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
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe SabredavClient::XmlRequestBuilder::PropfindInvite 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_invite.xml') }
9
-
10
- it "returns a valid xml" do
11
- expect(propfind.to_xml).to eq(expected_xml)
12
- end
13
- end
14
- end
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SabredavClient::XmlRequestBuilder::PropfindInvite 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_invite.xml') }
9
+
10
+ it "returns a valid xml" do
11
+ expect(propfind.to_xml).to eq(expected_xml)
12
+ end
13
+ end
14
+ end
@@ -1,14 +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
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