tilia-vobject 4.0.0.pre.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rubocop.yml +32 -0
  4. data/.simplecov +4 -0
  5. data/.travis.yml +3 -0
  6. data/CHANGELOG.sabre.md +626 -0
  7. data/CONTRIBUTING.md +25 -0
  8. data/Gemfile +17 -0
  9. data/Gemfile.lock +68 -0
  10. data/LICENSE +27 -0
  11. data/LICENSE.sabre +27 -0
  12. data/README.md +63 -0
  13. data/Rakefile +17 -0
  14. data/bin/vobject +7 -0
  15. data/lib/tilia/v_object/birthday_calendar_generator.rb +142 -0
  16. data/lib/tilia/v_object/cli.rb +582 -0
  17. data/lib/tilia/v_object/component/available.rb +107 -0
  18. data/lib/tilia/v_object/component/v_alarm.rb +114 -0
  19. data/lib/tilia/v_object/component/v_availability.rb +128 -0
  20. data/lib/tilia/v_object/component/v_calendar.rb +468 -0
  21. data/lib/tilia/v_object/component/v_card.rb +457 -0
  22. data/lib/tilia/v_object/component/v_event.rb +127 -0
  23. data/lib/tilia/v_object/component/v_free_busy.rb +81 -0
  24. data/lib/tilia/v_object/component/v_journal.rb +75 -0
  25. data/lib/tilia/v_object/component/v_time_zone.rb +51 -0
  26. data/lib/tilia/v_object/component/v_todo.rb +147 -0
  27. data/lib/tilia/v_object/component.rb +591 -0
  28. data/lib/tilia/v_object/date_time_parser.rb +486 -0
  29. data/lib/tilia/v_object/document.rb +218 -0
  30. data/lib/tilia/v_object/element_list.rb +18 -0
  31. data/lib/tilia/v_object/eof_exception.rb +8 -0
  32. data/lib/tilia/v_object/free_busy_data.rb +149 -0
  33. data/lib/tilia/v_object/free_busy_generator.rb +465 -0
  34. data/lib/tilia/v_object/i_tip/broker.rb +909 -0
  35. data/lib/tilia/v_object/i_tip/i_tip_exception.rb +9 -0
  36. data/lib/tilia/v_object/i_tip/message.rb +109 -0
  37. data/lib/tilia/v_object/i_tip/same_organizer_for_all_components_exception.rb +13 -0
  38. data/lib/tilia/v_object/i_tip.rb +10 -0
  39. data/lib/tilia/v_object/node.rb +192 -0
  40. data/lib/tilia/v_object/parameter.rb +327 -0
  41. data/lib/tilia/v_object/parse_exception.rb +7 -0
  42. data/lib/tilia/v_object/parser/json.rb +149 -0
  43. data/lib/tilia/v_object/parser/mime_dir.rb +543 -0
  44. data/lib/tilia/v_object/parser/parser.rb +61 -0
  45. data/lib/tilia/v_object/parser/xml/element/key_value.rb +60 -0
  46. data/lib/tilia/v_object/parser/xml/element.rb +11 -0
  47. data/lib/tilia/v_object/parser/xml.rb +322 -0
  48. data/lib/tilia/v_object/parser.rb +10 -0
  49. data/lib/tilia/v_object/property/binary.rb +96 -0
  50. data/lib/tilia/v_object/property/boolean.rb +57 -0
  51. data/lib/tilia/v_object/property/flat_text.rb +52 -0
  52. data/lib/tilia/v_object/property/float_value.rb +107 -0
  53. data/lib/tilia/v_object/property/i_calendar/cal_address.rb +49 -0
  54. data/lib/tilia/v_object/property/i_calendar/date.rb +15 -0
  55. data/lib/tilia/v_object/property/i_calendar/date_time.rb +330 -0
  56. data/lib/tilia/v_object/property/i_calendar/duration.rb +65 -0
  57. data/lib/tilia/v_object/property/i_calendar/period.rb +124 -0
  58. data/lib/tilia/v_object/property/i_calendar/recur.rb +173 -0
  59. data/lib/tilia/v_object/property/i_calendar.rb +14 -0
  60. data/lib/tilia/v_object/property/integer_value.rb +60 -0
  61. data/lib/tilia/v_object/property/text.rb +352 -0
  62. data/lib/tilia/v_object/property/time.rb +85 -0
  63. data/lib/tilia/v_object/property/unknown.rb +30 -0
  64. data/lib/tilia/v_object/property/uri.rb +78 -0
  65. data/lib/tilia/v_object/property/utc_offset.rb +56 -0
  66. data/lib/tilia/v_object/property/v_card/date.rb +31 -0
  67. data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +343 -0
  68. data/lib/tilia/v_object/property/v_card/date_time.rb +22 -0
  69. data/lib/tilia/v_object/property/v_card/language_tag.rb +41 -0
  70. data/lib/tilia/v_object/property/v_card/time_stamp.rb +74 -0
  71. data/lib/tilia/v_object/property/v_card.rb +13 -0
  72. data/lib/tilia/v_object/property.rb +532 -0
  73. data/lib/tilia/v_object/reader.rb +73 -0
  74. data/lib/tilia/v_object/recur/event_iterator.rb +417 -0
  75. data/lib/tilia/v_object/recur/no_instances_exception.rb +11 -0
  76. data/lib/tilia/v_object/recur/r_date_iterator.rb +138 -0
  77. data/lib/tilia/v_object/recur/r_rule_iterator.rb +717 -0
  78. data/lib/tilia/v_object/recur.rb +10 -0
  79. data/lib/tilia/v_object/settings.rb +32 -0
  80. data/lib/tilia/v_object/splitter/i_calendar.rb +95 -0
  81. data/lib/tilia/v_object/splitter/splitter_interface.rb +31 -0
  82. data/lib/tilia/v_object/splitter/v_card.rb +56 -0
  83. data/lib/tilia/v_object/splitter.rb +9 -0
  84. data/lib/tilia/v_object/string_util.rb +58 -0
  85. data/lib/tilia/v_object/time_zone_data/exchange_zones.rb +96 -0
  86. data/lib/tilia/v_object/time_zone_data/lotus_zones.rb +104 -0
  87. data/lib/tilia/v_object/time_zone_data/php_zones.rb +49 -0
  88. data/lib/tilia/v_object/time_zone_data/windows_zones.rb +121 -0
  89. data/lib/tilia/v_object/time_zone_data.rb +10 -0
  90. data/lib/tilia/v_object/time_zone_util.rb +213 -0
  91. data/lib/tilia/v_object/uuid_util.rb +51 -0
  92. data/lib/tilia/v_object/v_card_converter.rb +354 -0
  93. data/lib/tilia/v_object/version.rb +9 -0
  94. data/lib/tilia/v_object/writer.rb +56 -0
  95. data/lib/tilia/v_object.rb +45 -0
  96. data/lib/tilia/vobject.rb +1 -0
  97. data/resources/schema/xcal.rng +1192 -0
  98. data/resources/schema/xcard.rng +388 -0
  99. data/test/test_helper.rb +56 -0
  100. data/test/v_object/attach_issue_test.rb +19 -0
  101. data/test/v_object/birthday_calendar_generator_test.rb +463 -0
  102. data/test/v_object/cli_mock.rb +19 -0
  103. data/test/v_object/cli_test.rb +460 -0
  104. data/test/v_object/component/available_test.rb +59 -0
  105. data/test/v_object/component/v_alarm_test.rb +160 -0
  106. data/test/v_object/component/v_availability_test.rb +388 -0
  107. data/test/v_object/component/v_calendar_test.rb +646 -0
  108. data/test/v_object/component/v_card_test.rb +258 -0
  109. data/test/v_object/component/v_event_test.rb +85 -0
  110. data/test/v_object/component/v_free_busy_test.rb +59 -0
  111. data/test/v_object/component/v_journal_test.rb +85 -0
  112. data/test/v_object/component/v_time_zone_test.rb +47 -0
  113. data/test/v_object/component/v_todo_test.rb +172 -0
  114. data/test/v_object/component_test.rb +419 -0
  115. data/test/v_object/date_time_parser_test.rb +526 -0
  116. data/test/v_object/document_test.rb +71 -0
  117. data/test/v_object/element_list_test.rb +27 -0
  118. data/test/v_object/em_client_test.rb +53 -0
  119. data/test/v_object/empty_parameter_test.rb +65 -0
  120. data/test/v_object/empty_value_issue_test.rb +25 -0
  121. data/test/v_object/fake_component.rb +21 -0
  122. data/test/v_object/free_busy_data_test.rb +285 -0
  123. data/test/v_object/free_busy_generator_test.rb +637 -0
  124. data/test/v_object/google_colon_escaping_test.rb +27 -0
  125. data/test/v_object/i_calendar/attach_parse_test.rb +24 -0
  126. data/test/v_object/i_tip/broker_attendee_reply_test.rb +1042 -0
  127. data/test/v_object/i_tip/broker_delete_event_test.rb +175 -0
  128. data/test/v_object/i_tip/broker_new_event_test.rb +440 -0
  129. data/test/v_object/i_tip/broker_process_message_test.rb +153 -0
  130. data/test/v_object/i_tip/broker_process_reply_test.rb +402 -0
  131. data/test/v_object/i_tip/broker_tester.rb +71 -0
  132. data/test/v_object/i_tip/broker_update_event_test.rb +763 -0
  133. data/test/v_object/i_tip/evolution_test.rb +2644 -0
  134. data/test/v_object/i_tip/message_test.rb +25 -0
  135. data/test/v_object/issue153.vcf +352 -0
  136. data/test/v_object/issue153_test.rb +12 -0
  137. data/test/v_object/issue26_test.rb +25 -0
  138. data/test/v_object/issue36_work_around_test.rb +37 -0
  139. data/test/v_object/issue40_test.rb +26 -0
  140. data/test/v_object/issue64.vcf +351 -0
  141. data/test/v_object/issue64_test.rb +17 -0
  142. data/test/v_object/issue96_test.rb +22 -0
  143. data/test/v_object/issue_undefined_index_test.rb +24 -0
  144. data/test/v_object/j_cal_test.rb +150 -0
  145. data/test/v_object/j_card_test.rb +192 -0
  146. data/test/v_object/line_folding_issue_test.rb +19 -0
  147. data/test/v_object/mock_document.rb +6 -0
  148. data/test/v_object/parameter_test.rb +109 -0
  149. data/test/v_object/parser/json_test.rb +370 -0
  150. data/test/v_object/parser/mime_dir_test.rb +14 -0
  151. data/test/v_object/parser/quoted_printable_test.rb +78 -0
  152. data/test/v_object/parser/xml_test.rb +2563 -0
  153. data/test/v_object/property/binary_test.rb +12 -0
  154. data/test/v_object/property/boolean_test.rb +18 -0
  155. data/test/v_object/property/compound_test.rb +43 -0
  156. data/test/v_object/property/float_test.rb +20 -0
  157. data/test/v_object/property/i_calendar/cal_address_test.rb +26 -0
  158. data/test/v_object/property/i_calendar/date_time_test.rb +303 -0
  159. data/test/v_object/property/i_calendar/duration_test.rb +14 -0
  160. data/test/v_object/property/i_calendar/recur_test.rb +39 -0
  161. data/test/v_object/property/text_test.rb +81 -0
  162. data/test/v_object/property/v_card/date_and_or_time_test.rb +205 -0
  163. data/test/v_object/property/v_card/language_tag_test.rb +35 -0
  164. data/test/v_object/property_test.rb +338 -0
  165. data/test/v_object/reader_test.rb +403 -0
  166. data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +52 -0
  167. data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +55 -0
  168. data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +109 -0
  169. data/test/v_object/recur/event_iterator/fifth_tuesday_problem_test.rb +45 -0
  170. data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +53 -0
  171. data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +75 -0
  172. data/test/v_object/recur/event_iterator/issue48_test.rb +43 -0
  173. data/test/v_object/recur/event_iterator/issue50_test.rb +123 -0
  174. data/test/v_object/recur/event_iterator/main_test.rb +1222 -0
  175. data/test/v_object/recur/event_iterator/missing_overridden_test.rb +55 -0
  176. data/test/v_object/recur/event_iterator/no_instances_test.rb +32 -0
  177. data/test/v_object/recur/event_iterator/override_first_event_test.rb +106 -0
  178. data/test/v_object/recur/r_date_iterator_test.rb +44 -0
  179. data/test/v_object/recur/r_rule_iterator_test.rb +608 -0
  180. data/test/v_object/recurrence_iterator/UntilRespectsTimezoneTest.ics +39 -0
  181. data/test/v_object/slash_r_test.rb +15 -0
  182. data/test/v_object/splitter/i_calendar_test.rb +299 -0
  183. data/test/v_object/splitter/v_card_test.rb +173 -0
  184. data/test/v_object/string_util_test.rb +37 -0
  185. data/test/v_object/test_case.rb +42 -0
  186. data/test/v_object/time_zone_util_test.rb +271 -0
  187. data/test/v_object/uuid_util_test.rb +18 -0
  188. data/test/v_object/v_card21_test.rb +43 -0
  189. data/test/v_object/v_card_converter_test.rb +419 -0
  190. data/test/v_object/version_test.rb +15 -0
  191. data/test/v_object/writer_test.rb +33 -0
  192. data/tilia-vobject.gemspec +17 -0
  193. metadata +308 -0
@@ -0,0 +1,175 @@
1
+ require 'test_helper'
2
+ require 'v_object/i_tip/broker_tester'
3
+
4
+ module Tilia
5
+ module VObject
6
+ class BrokerDeleteEventTest < ITip::BrokerTester
7
+ def test_organizer_delete
8
+ old_message = <<ICS
9
+ BEGIN:VCALENDAR
10
+ VERSION:2.0
11
+ BEGIN:VEVENT
12
+ UID:foobar
13
+ SEQUENCE:1
14
+ SUMMARY:foo
15
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
16
+ ATTENDEE;CN=One:mailto:one@example.org
17
+ ATTENDEE;CN=Two:mailto:two@example.org
18
+ DTSTART:20140716T120000Z
19
+ END:VEVENT
20
+ END:VCALENDAR
21
+ ICS
22
+
23
+ new_message = nil
24
+
25
+ version = Tilia::VObject::Version::VERSION
26
+
27
+ expected = [
28
+ {
29
+ 'uid' => 'foobar',
30
+ 'method' => 'CANCEL',
31
+ 'component' => 'VEVENT',
32
+ 'sender' => 'mailto:strunk@example.org',
33
+ 'sender_name' => 'Strunk',
34
+ 'recipient' => 'mailto:one@example.org',
35
+ 'recipient_name' => 'One',
36
+ 'message' => <<ICS
37
+ BEGIN:VCALENDAR
38
+ VERSION:2.0
39
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
40
+ CALSCALE:GREGORIAN
41
+ METHOD:CANCEL
42
+ BEGIN:VEVENT
43
+ UID:foobar
44
+ SEQUENCE:2
45
+ SUMMARY:foo
46
+ DTSTART:20140716T120000Z
47
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
48
+ ATTENDEE;CN=One:mailto:one@example.org
49
+ END:VEVENT
50
+ END:VCALENDAR
51
+ ICS
52
+ },
53
+ {
54
+ 'uid' => 'foobar',
55
+ 'method' => 'CANCEL',
56
+ 'component' => 'VEVENT',
57
+ 'sender' => 'mailto:strunk@example.org',
58
+ 'sender_name' => 'Strunk',
59
+ 'recipient' => 'mailto:two@example.org',
60
+ 'recipient_name' => 'Two',
61
+ 'message' => <<ICS
62
+ BEGIN:VCALENDAR
63
+ VERSION:2.0
64
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
65
+ CALSCALE:GREGORIAN
66
+ METHOD:CANCEL
67
+ BEGIN:VEVENT
68
+ UID:foobar
69
+ SEQUENCE:2
70
+ SUMMARY:foo
71
+ DTSTART:20140716T120000Z
72
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
73
+ ATTENDEE;CN=Two:mailto:two@example.org
74
+ END:VEVENT
75
+ END:VCALENDAR
76
+ ICS
77
+ }
78
+ ]
79
+
80
+ parse(old_message, new_message, expected, 'mailto:strunk@example.org')
81
+ end
82
+
83
+ def test_attendee_delete
84
+ old_message = <<ICS
85
+ BEGIN:VCALENDAR
86
+ VERSION:2.0
87
+ BEGIN:VEVENT
88
+ UID:foobar
89
+ SEQUENCE:1
90
+ SUMMARY:foo
91
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
92
+ ATTENDEE;CN=One:mailto:one@example.org
93
+ ATTENDEE;CN=Two:mailto:two@example.org
94
+ DTSTART:20140716T120000Z
95
+ END:VEVENT
96
+ END:VCALENDAR
97
+ ICS
98
+
99
+ new_message = nil
100
+
101
+ version = Tilia::VObject::Version::VERSION
102
+
103
+ expected = [
104
+ {
105
+ 'uid' => 'foobar',
106
+ 'method' => 'REPLY',
107
+ 'component' => 'VEVENT',
108
+ 'sender' => 'mailto:one@example.org',
109
+ 'sender_name' => 'One',
110
+ 'recipient' => 'mailto:strunk@example.org',
111
+ 'recipient_name' => 'Strunk',
112
+ 'message' => <<ICS
113
+ BEGIN:VCALENDAR
114
+ VERSION:2.0
115
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
116
+ CALSCALE:GREGORIAN
117
+ METHOD:REPLY
118
+ BEGIN:VEVENT
119
+ UID:foobar
120
+ SEQUENCE:1
121
+ DTSTART:20140716T120000Z
122
+ SUMMARY:foo
123
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
124
+ ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one@example.org
125
+ END:VEVENT
126
+ END:VCALENDAR
127
+ ICS
128
+ }
129
+ ]
130
+
131
+ parse(old_message, new_message, expected, 'mailto:one@example.org')
132
+ end
133
+
134
+ def test_attendee_delete_cancelled_event
135
+ old_message = <<ICS
136
+ BEGIN:VCALENDAR
137
+ VERSION:2.0
138
+ BEGIN:VEVENT
139
+ STATUS:CANCELLED
140
+ UID:foobar
141
+ SEQUENCE:1
142
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
143
+ ATTENDEE;CN=One:mailto:one@example.org
144
+ ATTENDEE;CN=Two:mailto:two@example.org
145
+ DTSTART:20140716T120000Z
146
+ END:VEVENT
147
+ END:VCALENDAR
148
+ ICS
149
+
150
+ new_message = nil
151
+
152
+ expected = []
153
+
154
+ parse(old_message, new_message, expected, 'mailto:one@example.org')
155
+ end
156
+
157
+ def test_no_calendar
158
+ parse(nil, nil, [], 'mailto:one@example.org')
159
+ end
160
+
161
+ def test_v_todo
162
+ old_message = <<ICS
163
+ BEGIN:VCALENDAR
164
+ VERSION:2.0
165
+ BEGIN:VTODO
166
+ UID:foobar
167
+ SEQUENCE:1
168
+ END:VTODO
169
+ END:VCALENDAR
170
+ ICS
171
+ parse(old_message, nil, [], 'mailto:one@example.org')
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,440 @@
1
+ require 'test_helper'
2
+ require 'v_object/i_tip/broker_tester'
3
+
4
+ module Tilia
5
+ module VObject
6
+ class BrokerNewEventTest < ITip::BrokerTester
7
+ # Similar to the one in broker_helper, but not the same
8
+ def local_parse(message, expected = [])
9
+ parse(nil, message, expected, 'mailto:strunk@example.org')
10
+ end
11
+
12
+ def test_no_attendee
13
+ message = <<ICS
14
+ BEGIN:VCALENDAR
15
+ BEGIN:VEVENT
16
+ UID:foobar
17
+ DTSTART:20140811T220000Z
18
+ END:VEVENT
19
+ END:VCALENDAR
20
+ ICS
21
+
22
+ local_parse(message)
23
+ end
24
+
25
+ def test_vtodo
26
+ message = <<ICS
27
+ BEGIN:VCALENDAR
28
+ BEGIN:VTODO
29
+ UID:foobar
30
+ END:VTODO
31
+ END:VCALENDAR
32
+ ICS
33
+
34
+ local_parse(message)
35
+ end
36
+
37
+ def test_simple_invite
38
+ message = <<ICS
39
+ BEGIN:VCALENDAR
40
+ VERSION:2.0
41
+ BEGIN:VEVENT
42
+ UID:foobar
43
+ DTSTART:20140811T220000Z
44
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
45
+ ATTENDEE;CN=White:mailto:white@example.org
46
+ END:VEVENT
47
+ END:VCALENDAR
48
+ ICS
49
+
50
+ version = Tilia::VObject::Version::VERSION
51
+ expected_message = <<ICS
52
+ BEGIN:VCALENDAR
53
+ VERSION:2.0
54
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
55
+ CALSCALE:GREGORIAN
56
+ METHOD:REQUEST
57
+ BEGIN:VEVENT
58
+ UID:foobar
59
+ DTSTART:20140811T220000Z
60
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
61
+ ATTENDEE;CN=White;PARTSTAT=NEEDS-ACTION:mailto:white@example.org
62
+ END:VEVENT
63
+ END:VCALENDAR
64
+ ICS
65
+
66
+ expected = [
67
+ {
68
+ 'uid' => 'foobar',
69
+ 'method' => 'REQUEST',
70
+ 'component' => 'VEVENT',
71
+ 'sender' => 'mailto:strunk@example.org',
72
+ 'sender_name' => 'Strunk',
73
+ 'recipient' => 'mailto:white@example.org',
74
+ 'recipient_name' => 'White',
75
+ 'message' => expected_message
76
+ }
77
+ ]
78
+
79
+ local_parse(message, expected)
80
+ end
81
+
82
+ def test_broken_event_uid_mis_match
83
+ message = <<ICS
84
+ BEGIN:VCALENDAR
85
+ VERSION:2.0
86
+ BEGIN:VEVENT
87
+ UID:foobar
88
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
89
+ ATTENDEE;CN=White:mailto:white@example.org
90
+ END:VEVENT
91
+ BEGIN:VEVENT
92
+ UID:foobar2
93
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
94
+ ATTENDEE;CN=White:mailto:white@example.org
95
+ END:VEVENT
96
+ END:VCALENDAR
97
+ ICS
98
+
99
+ assert_raises(Tilia::VObject::ITip::ITipException) { local_parse(message, []) }
100
+ end
101
+
102
+ def test_broken_event_organizer_mis_match
103
+ message = <<ICS
104
+ BEGIN:VCALENDAR
105
+ VERSION:2.0
106
+ BEGIN:VEVENT
107
+ UID:foobar
108
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
109
+ ATTENDEE;CN=White:mailto:white@example.org
110
+ END:VEVENT
111
+ BEGIN:VEVENT
112
+ UID:foobar
113
+ ORGANIZER:mailto:foo@example.org
114
+ ATTENDEE;CN=White:mailto:white@example.org
115
+ END:VEVENT
116
+ END:VCALENDAR
117
+ ICS
118
+
119
+ assert_raises(Tilia::VObject::ITip::ITipException) { local_parse(message, []) }
120
+ end
121
+
122
+ def test_recurrence_invite
123
+ message = <<ICS
124
+ BEGIN:VCALENDAR
125
+ VERSION:2.0
126
+ BEGIN:VEVENT
127
+ UID:foobar
128
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
129
+ ATTENDEE;CN=One:mailto:one@example.org
130
+ ATTENDEE;CN=Two:mailto:two@example.org
131
+ DTSTART:20140716T120000Z
132
+ RRULE:FREQ=DAILY
133
+ EXDATE:20140717T120000Z
134
+ END:VEVENT
135
+ BEGIN:VEVENT
136
+ UID:foobar
137
+ RECURRENCE-ID:20140718T120000Z
138
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
139
+ ATTENDEE;CN=Two:mailto:two@example.org
140
+ ATTENDEE;CN=Three:mailto:three@example.org
141
+ DTSTART:20140718T120000Z
142
+ END:VEVENT
143
+ END:VCALENDAR
144
+ ICS
145
+
146
+ version = Tilia::VObject::Version::VERSION
147
+
148
+ expected = [
149
+ {
150
+ 'uid' => 'foobar',
151
+ 'method' => 'REQUEST',
152
+ 'component' => 'VEVENT',
153
+ 'sender' => 'mailto:strunk@example.org',
154
+ 'sender_name' => 'Strunk',
155
+ 'recipient' => 'mailto:one@example.org',
156
+ 'recipient_name' => 'One',
157
+ 'message' => <<ICS
158
+ BEGIN:VCALENDAR
159
+ VERSION:2.0
160
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
161
+ CALSCALE:GREGORIAN
162
+ METHOD:REQUEST
163
+ BEGIN:VEVENT
164
+ UID:foobar
165
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
166
+ ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
167
+ ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
168
+ DTSTART:20140716T120000Z
169
+ RRULE:FREQ=DAILY
170
+ EXDATE:20140717T120000Z,20140718T120000Z
171
+ END:VEVENT
172
+ END:VCALENDAR
173
+ ICS
174
+ },
175
+ {
176
+ 'uid' => 'foobar',
177
+ 'method' => 'REQUEST',
178
+ 'component' => 'VEVENT',
179
+ 'sender' => 'mailto:strunk@example.org',
180
+ 'sender_name' => 'Strunk',
181
+ 'recipient' => 'mailto:two@example.org',
182
+ 'recipient_name' => 'Two',
183
+ 'message' => <<ICS
184
+ BEGIN:VCALENDAR
185
+ VERSION:2.0
186
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
187
+ CALSCALE:GREGORIAN
188
+ METHOD:REQUEST
189
+ BEGIN:VEVENT
190
+ UID:foobar
191
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
192
+ ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
193
+ ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
194
+ DTSTART:20140716T120000Z
195
+ RRULE:FREQ=DAILY
196
+ EXDATE:20140717T120000Z
197
+ END:VEVENT
198
+ BEGIN:VEVENT
199
+ UID:foobar
200
+ RECURRENCE-ID:20140718T120000Z
201
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
202
+ ATTENDEE;CN=Two:mailto:two@example.org
203
+ ATTENDEE;CN=Three:mailto:three@example.org
204
+ DTSTART:20140718T120000Z
205
+ END:VEVENT
206
+ END:VCALENDAR
207
+ ICS
208
+ },
209
+ {
210
+ 'uid' => 'foobar',
211
+ 'method' => 'REQUEST',
212
+ 'component' => 'VEVENT',
213
+ 'sender' => 'mailto:strunk@example.org',
214
+ 'sender_name' => 'Strunk',
215
+ 'recipient' => 'mailto:three@example.org',
216
+ 'recipient_name' => 'Three',
217
+ 'message' => <<ICS
218
+ BEGIN:VCALENDAR
219
+ VERSION:2.0
220
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
221
+ CALSCALE:GREGORIAN
222
+ METHOD:REQUEST
223
+ BEGIN:VEVENT
224
+ UID:foobar
225
+ RECURRENCE-ID:20140718T120000Z
226
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
227
+ ATTENDEE;CN=Two:mailto:two@example.org
228
+ ATTENDEE;CN=Three:mailto:three@example.org
229
+ DTSTART:20140718T120000Z
230
+ END:VEVENT
231
+ END:VCALENDAR
232
+ ICS
233
+ }
234
+ ]
235
+
236
+ local_parse(message, expected)
237
+ end
238
+
239
+ def test_recurrence_invite2
240
+ # This method tests a nearly identical path, but in this case the
241
+ # master event does not have an EXDATE.
242
+ message = <<ICS
243
+ BEGIN:VCALENDAR
244
+ VERSION:2.0
245
+ BEGIN:VEVENT
246
+ UID:foobar
247
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
248
+ ATTENDEE;CN=One:mailto:one@example.org
249
+ ATTENDEE;CN=Two:mailto:two@example.org
250
+ DTSTART:20140716T120000Z
251
+ RRULE:FREQ=DAILY
252
+ END:VEVENT
253
+ BEGIN:VEVENT
254
+ UID:foobar
255
+ RECURRENCE-ID:20140718T120000Z
256
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
257
+ ATTENDEE;CN=Two:mailto:two@example.org
258
+ ATTENDEE;CN=Three:mailto:three@example.org
259
+ DTSTART:20140718T120000Z
260
+ END:VEVENT
261
+ END:VCALENDAR
262
+ ICS
263
+
264
+ version = Tilia::VObject::Version::VERSION
265
+
266
+ expected = [
267
+ {
268
+ 'uid' => 'foobar',
269
+ 'method' => 'REQUEST',
270
+ 'component' => 'VEVENT',
271
+ 'sender' => 'mailto:strunk@example.org',
272
+ 'sender_name' => 'Strunk',
273
+ 'recipient' => 'mailto:one@example.org',
274
+ 'recipient_name' => 'One',
275
+ 'message' => <<ICS
276
+ BEGIN:VCALENDAR
277
+ VERSION:2.0
278
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
279
+ CALSCALE:GREGORIAN
280
+ METHOD:REQUEST
281
+ BEGIN:VEVENT
282
+ UID:foobar
283
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
284
+ ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
285
+ ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
286
+ DTSTART:20140716T120000Z
287
+ RRULE:FREQ=DAILY
288
+ EXDATE:20140718T120000Z
289
+ END:VEVENT
290
+ END:VCALENDAR
291
+ ICS
292
+ },
293
+ {
294
+ 'uid' => 'foobar',
295
+ 'method' => 'REQUEST',
296
+ 'component' => 'VEVENT',
297
+ 'sender' => 'mailto:strunk@example.org',
298
+ 'sender_name' => 'Strunk',
299
+ 'recipient' => 'mailto:two@example.org',
300
+ 'recipient_name' => 'Two',
301
+ 'message' => <<ICS
302
+ BEGIN:VCALENDAR
303
+ VERSION:2.0
304
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
305
+ CALSCALE:GREGORIAN
306
+ METHOD:REQUEST
307
+ BEGIN:VEVENT
308
+ UID:foobar
309
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
310
+ ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
311
+ ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
312
+ DTSTART:20140716T120000Z
313
+ RRULE:FREQ=DAILY
314
+ END:VEVENT
315
+ BEGIN:VEVENT
316
+ UID:foobar
317
+ RECURRENCE-ID:20140718T120000Z
318
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
319
+ ATTENDEE;CN=Two:mailto:two@example.org
320
+ ATTENDEE;CN=Three:mailto:three@example.org
321
+ DTSTART:20140718T120000Z
322
+ END:VEVENT
323
+ END:VCALENDAR
324
+ ICS
325
+ },
326
+ {
327
+ 'uid' => 'foobar',
328
+ 'method' => 'REQUEST',
329
+ 'component' => 'VEVENT',
330
+ 'sender' => 'mailto:strunk@example.org',
331
+ 'sender_name' => 'Strunk',
332
+ 'recipient' => 'mailto:three@example.org',
333
+ 'recipient_name' => 'Three',
334
+ 'message' => <<ICS
335
+ BEGIN:VCALENDAR
336
+ VERSION:2.0
337
+ PRODID:-//Tilia//Tilia VObject #{version}//EN
338
+ CALSCALE:GREGORIAN
339
+ METHOD:REQUEST
340
+ BEGIN:VEVENT
341
+ UID:foobar
342
+ RECURRENCE-ID:20140718T120000Z
343
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
344
+ ATTENDEE;CN=Two:mailto:two@example.org
345
+ ATTENDEE;CN=Three:mailto:three@example.org
346
+ DTSTART:20140718T120000Z
347
+ END:VEVENT
348
+ END:VCALENDAR
349
+ ICS
350
+ }
351
+ ]
352
+
353
+ local_parse(message, expected)
354
+ end
355
+
356
+ def test_schedule_agent_client
357
+ message = <<ICS
358
+ BEGIN:VCALENDAR
359
+ VERSION:2.0
360
+ BEGIN:VEVENT
361
+ UID:foobar
362
+ DTSTART:20140811T220000Z
363
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
364
+ ATTENDEE;CN=White;SCHEDULE-AGENT=CLIENT:mailto:white@example.org
365
+ END:VEVENT
366
+ END:VCALENDAR
367
+ ICS
368
+
369
+ expected = []
370
+ local_parse(message, expected)
371
+ end
372
+
373
+ def test_multiple_uid
374
+ message = <<ICS
375
+ BEGIN:VCALENDAR
376
+ VERSION:2.0
377
+ BEGIN:VEVENT
378
+ UID:foobar
379
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
380
+ ATTENDEE;CN=One:mailto:one@example.org
381
+ ATTENDEE;CN=Two:mailto:two@example.org
382
+ DTSTART:20140716T120000Z
383
+ RRULE:FREQ=DAILY
384
+ END:VEVENT
385
+ BEGIN:VEVENT
386
+ UID:foobar2
387
+ RECURRENCE-ID:20140718T120000Z
388
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
389
+ ATTENDEE;CN=Two:mailto:two@example.org
390
+ ATTENDEE;CN=Three:mailto:three@example.org
391
+ DTSTART:20140718T120000Z
392
+ END:VEVENT
393
+ END:VCALENDAR
394
+ ICS
395
+
396
+ assert_raises(Tilia::VObject::ITip::ITipException) { local_parse(message, []) }
397
+ end
398
+
399
+ def test_changing_organizers
400
+ message = <<ICS
401
+ BEGIN:VCALENDAR
402
+ VERSION:2.0
403
+ BEGIN:VEVENT
404
+ UID:foobar
405
+ ORGANIZER;CN=Strunk:mailto:strunk@example.org
406
+ ATTENDEE;CN=One:mailto:one@example.org
407
+ ATTENDEE;CN=Two:mailto:two@example.org
408
+ DTSTART:20140716T120000Z
409
+ RRULE:FREQ=DAILY
410
+ END:VEVENT
411
+ BEGIN:VEVENT
412
+ UID:foobar
413
+ RECURRENCE-ID:20140718T120000Z
414
+ ORGANIZER;CN=Strunk:mailto:ew@example.org
415
+ ATTENDEE;CN=Two:mailto:two@example.org
416
+ ATTENDEE;CN=Three:mailto:three@example.org
417
+ DTSTART:20140718T120000Z
418
+ END:VEVENT
419
+ END:VCALENDAR
420
+ ICS
421
+
422
+ assert_raises(Tilia::VObject::ITip::SameOrganizerForAllComponentsException) { local_parse(message, []) }
423
+ end
424
+
425
+ def test_no_organizer_has_attendee
426
+ message = <<ICS
427
+ BEGIN:VCALENDAR
428
+ BEGIN:VEVENT
429
+ UID:foobar
430
+ DTSTART:20140811T220000Z
431
+ ATTENDEE;CN=Two:mailto:two@example.org
432
+ END:VEVENT
433
+ END:VCALENDAR
434
+ ICS
435
+
436
+ local_parse(message, [])
437
+ end
438
+ end
439
+ end
440
+ end