rubysync 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/.DS_Store +0 -0
  2. data/.project +17 -0
  3. data/COPYING +339 -0
  4. data/HISTORY.txt +8 -0
  5. data/Manifest.txt +218 -0
  6. data/README.txt +67 -0
  7. data/Rakefile +31 -0
  8. data/bin/.DS_Store +0 -0
  9. data/bin/rubysync +19 -12
  10. data/examples/.DS_Store +0 -0
  11. data/examples/ar_client_webapp/log/development.log +753 -0
  12. data/examples/ar_client_webapp/log/production.log +0 -0
  13. data/examples/ar_client_webapp/log/server.log +0 -0
  14. data/examples/ar_client_webapp/log/test.log +0 -0
  15. data/examples/ar_client_webapp/public/.htaccess +40 -0
  16. data/examples/ar_client_webapp/tmp/sessions/ruby_sess.e2e3c63a67baef6d +0 -0
  17. data/examples/ar_webapp/.DS_Store +0 -0
  18. data/examples/ar_webapp/app/.DS_Store +0 -0
  19. data/examples/ar_webapp/app/views/.DS_Store +0 -0
  20. data/examples/ar_webapp/app/views/people/.DS_Store +0 -0
  21. data/examples/ar_webapp/log/development.log +5518 -0
  22. data/examples/ar_webapp/log/production.log +0 -0
  23. data/examples/ar_webapp/log/server.log +0 -0
  24. data/examples/ar_webapp/log/test.log +2178 -0
  25. data/examples/ar_webapp/public/.htaccess +40 -0
  26. data/examples/ar_webapp/tmp/sessions/ruby_sess.2295696b0af5f6dd +0 -0
  27. data/examples/ar_webapp/tmp/sessions/ruby_sess.26687aeb19c87669 +0 -0
  28. data/examples/ar_webapp/tmp/sessions/ruby_sess.2855a3b0c8ea840b +0 -0
  29. data/examples/ar_webapp/tmp/sessions/ruby_sess.45d2d48a8330ff28 +0 -0
  30. data/examples/ar_webapp/tmp/sessions/ruby_sess.7366b840f4ce9f12 +0 -0
  31. data/examples/ar_webapp/tmp/sessions/ruby_sess.b2fc3f2e6d8ae555 +0 -0
  32. data/examples/ar_webapp/tmp/sessions/ruby_sess.b6bf8470a62c02b0 +0 -0
  33. data/examples/my_ims/.DS_Store +0 -0
  34. data/gemspec +48 -0
  35. data/lib/.DS_Store +0 -0
  36. data/lib/net/.DS_Store +0 -0
  37. data/lib/ruby_sync/connectors/active_record_association_handler.rb +66 -0
  38. data/lib/ruby_sync/connectors/active_record_connector.rb +14 -62
  39. data/lib/ruby_sync/connectors/active_record_event_handler.rb +47 -0
  40. data/lib/ruby_sync/connectors/base_connector.rb +139 -36
  41. data/lib/ruby_sync/connectors/connector_event_processing.rb +18 -0
  42. data/lib/ruby_sync/connectors/csv_file_connector.rb +3 -0
  43. data/lib/ruby_sync/connectors/file_connector.rb +1 -0
  44. data/lib/ruby_sync/connectors/memory_connector.rb +2 -104
  45. data/lib/ruby_sync/connectors/xml_connector.rb +98 -0
  46. data/lib/ruby_sync/event.rb +7 -1
  47. data/lib/ruby_sync/util/utilities.rb +27 -16
  48. data/lib/ruby_sync.rb +10 -1
  49. data/lib/rubysync.rb +19 -0
  50. data/nbproject/private/private.properties +3 -0
  51. data/nbproject/project.properties +8 -0
  52. data/nbproject/project.xml +16 -0
  53. data/rubysync.tmproj +348 -0
  54. data/test/.DS_Store +0 -0
  55. data/test/ruby_sync_test.rb +8 -1
  56. data/test/tc_xml_connectors.rb +47 -0
  57. data/test/test_active_record_vault.rb +17 -14
  58. data/test/test_base_connector.rb +38 -0
  59. data/test/test_ldap_changelog.rb +97 -0
  60. data/test/test_ldap_connector.rb +2 -48
  61. data/test/test_memory_connectors.rb +8 -3
  62. data/test/test_rubysync.rb +28 -0
  63. data/test/ts_rubysync.rb +5 -3
  64. metadata +129 -169
data/rubysync.tmproj ADDED
@@ -0,0 +1,348 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>currentDocument</key>
6
+ <string>test/test_ldap_connector.rb</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string>rubysync</string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>sourceDirectory</key>
17
+ <string></string>
18
+ </dict>
19
+ <dict>
20
+ <key>children</key>
21
+ <array>
22
+ <dict>
23
+ <key>name</key>
24
+ <string>ar_webapp</string>
25
+ <key>regexFolderFilter</key>
26
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
27
+ <key>sourceDirectory</key>
28
+ <string>examples/ar_webapp</string>
29
+ </dict>
30
+ </array>
31
+ <key>name</key>
32
+ <string>ar_webapp</string>
33
+ </dict>
34
+ </array>
35
+ <key>fileHierarchyDrawerWidth</key>
36
+ <integer>431</integer>
37
+ <key>metaData</key>
38
+ <dict>
39
+ <key>bin/rubysync</key>
40
+ <dict>
41
+ <key>caret</key>
42
+ <dict>
43
+ <key>column</key>
44
+ <integer>3</integer>
45
+ <key>line</key>
46
+ <integer>304</integer>
47
+ </dict>
48
+ <key>firstVisibleColumn</key>
49
+ <integer>0</integer>
50
+ <key>firstVisibleLine</key>
51
+ <integer>277</integer>
52
+ </dict>
53
+ <key>examples/ar_webapp/db/migrate/009_create_ruby_sync_states.rb</key>
54
+ <dict>
55
+ <key>caret</key>
56
+ <dict>
57
+ <key>column</key>
58
+ <integer>41</integer>
59
+ <key>line</key>
60
+ <integer>2</integer>
61
+ </dict>
62
+ <key>firstVisibleColumn</key>
63
+ <integer>0</integer>
64
+ <key>firstVisibleLine</key>
65
+ <integer>0</integer>
66
+ </dict>
67
+ <key>lib/ruby_sync.rb</key>
68
+ <dict>
69
+ <key>caret</key>
70
+ <dict>
71
+ <key>column</key>
72
+ <integer>0</integer>
73
+ <key>line</key>
74
+ <integer>67</integer>
75
+ </dict>
76
+ <key>firstVisibleColumn</key>
77
+ <integer>0</integer>
78
+ <key>firstVisibleLine</key>
79
+ <integer>48</integer>
80
+ </dict>
81
+ <key>lib/ruby_sync/connectors/active_record_association_handler.rb</key>
82
+ <dict>
83
+ <key>caret</key>
84
+ <dict>
85
+ <key>column</key>
86
+ <integer>3</integer>
87
+ <key>line</key>
88
+ <integer>45</integer>
89
+ </dict>
90
+ <key>firstVisibleColumn</key>
91
+ <integer>0</integer>
92
+ <key>firstVisibleLine</key>
93
+ <integer>28</integer>
94
+ </dict>
95
+ <key>lib/ruby_sync/connectors/active_record_connector.rb</key>
96
+ <dict>
97
+ <key>caret</key>
98
+ <dict>
99
+ <key>column</key>
100
+ <integer>38</integer>
101
+ <key>line</key>
102
+ <integer>87</integer>
103
+ </dict>
104
+ <key>firstVisibleColumn</key>
105
+ <integer>0</integer>
106
+ <key>firstVisibleLine</key>
107
+ <integer>19</integer>
108
+ </dict>
109
+ <key>lib/ruby_sync/connectors/active_record_event_handler.rb</key>
110
+ <dict>
111
+ <key>caret</key>
112
+ <dict>
113
+ <key>column</key>
114
+ <integer>30</integer>
115
+ <key>line</key>
116
+ <integer>24</integer>
117
+ </dict>
118
+ <key>firstVisibleColumn</key>
119
+ <integer>0</integer>
120
+ <key>firstVisibleLine</key>
121
+ <integer>9</integer>
122
+ </dict>
123
+ <key>lib/ruby_sync/connectors/base_connector.rb</key>
124
+ <dict>
125
+ <key>caret</key>
126
+ <dict>
127
+ <key>column</key>
128
+ <integer>0</integer>
129
+ <key>line</key>
130
+ <integer>93</integer>
131
+ </dict>
132
+ <key>firstVisibleColumn</key>
133
+ <integer>0</integer>
134
+ <key>firstVisibleLine</key>
135
+ <integer>392</integer>
136
+ </dict>
137
+ <key>lib/ruby_sync/connectors/connector_event_processing.rb</key>
138
+ <dict>
139
+ <key>caret</key>
140
+ <dict>
141
+ <key>column</key>
142
+ <integer>0</integer>
143
+ <key>line</key>
144
+ <integer>46</integer>
145
+ </dict>
146
+ <key>columnSelection</key>
147
+ <false/>
148
+ <key>firstVisibleColumn</key>
149
+ <integer>0</integer>
150
+ <key>firstVisibleLine</key>
151
+ <integer>33</integer>
152
+ <key>selectFrom</key>
153
+ <dict>
154
+ <key>column</key>
155
+ <integer>0</integer>
156
+ <key>line</key>
157
+ <integer>45</integer>
158
+ </dict>
159
+ <key>selectTo</key>
160
+ <dict>
161
+ <key>column</key>
162
+ <integer>0</integer>
163
+ <key>line</key>
164
+ <integer>46</integer>
165
+ </dict>
166
+ </dict>
167
+ <key>lib/ruby_sync/connectors/ldap_connector.rb</key>
168
+ <dict>
169
+ <key>caret</key>
170
+ <dict>
171
+ <key>column</key>
172
+ <integer>19</integer>
173
+ <key>line</key>
174
+ <integer>287</integer>
175
+ </dict>
176
+ <key>firstVisibleColumn</key>
177
+ <integer>0</integer>
178
+ <key>firstVisibleLine</key>
179
+ <integer>0</integer>
180
+ </dict>
181
+ <key>lib/ruby_sync/connectors/memory_connector.rb</key>
182
+ <dict>
183
+ <key>caret</key>
184
+ <dict>
185
+ <key>column</key>
186
+ <integer>0</integer>
187
+ <key>line</key>
188
+ <integer>27</integer>
189
+ </dict>
190
+ <key>firstVisibleColumn</key>
191
+ <integer>0</integer>
192
+ <key>firstVisibleLine</key>
193
+ <integer>14</integer>
194
+ </dict>
195
+ <key>lib/ruby_sync/connectors/xml_connector.rb</key>
196
+ <dict>
197
+ <key>caret</key>
198
+ <dict>
199
+ <key>column</key>
200
+ <integer>0</integer>
201
+ <key>line</key>
202
+ <integer>0</integer>
203
+ </dict>
204
+ <key>firstVisibleColumn</key>
205
+ <integer>0</integer>
206
+ <key>firstVisibleLine</key>
207
+ <integer>14</integer>
208
+ </dict>
209
+ <key>lib/ruby_sync/event.rb</key>
210
+ <dict>
211
+ <key>caret</key>
212
+ <dict>
213
+ <key>column</key>
214
+ <integer>26</integer>
215
+ <key>line</key>
216
+ <integer>117</integer>
217
+ </dict>
218
+ <key>firstVisibleColumn</key>
219
+ <integer>0</integer>
220
+ <key>firstVisibleLine</key>
221
+ <integer>88</integer>
222
+ </dict>
223
+ <key>lib/ruby_sync/util/utilities.rb</key>
224
+ <dict>
225
+ <key>caret</key>
226
+ <dict>
227
+ <key>column</key>
228
+ <integer>17</integer>
229
+ <key>line</key>
230
+ <integer>94</integer>
231
+ </dict>
232
+ <key>firstVisibleColumn</key>
233
+ <integer>0</integer>
234
+ <key>firstVisibleLine</key>
235
+ <integer>75</integer>
236
+ </dict>
237
+ <key>test/ruby_sync_test.rb</key>
238
+ <dict>
239
+ <key>caret</key>
240
+ <dict>
241
+ <key>column</key>
242
+ <integer>14</integer>
243
+ <key>line</key>
244
+ <integer>42</integer>
245
+ </dict>
246
+ <key>firstVisibleColumn</key>
247
+ <integer>0</integer>
248
+ <key>firstVisibleLine</key>
249
+ <integer>15</integer>
250
+ </dict>
251
+ <key>test/test_active_record_vault.rb</key>
252
+ <dict>
253
+ <key>caret</key>
254
+ <dict>
255
+ <key>column</key>
256
+ <integer>2</integer>
257
+ <key>line</key>
258
+ <integer>86</integer>
259
+ </dict>
260
+ <key>firstVisibleColumn</key>
261
+ <integer>0</integer>
262
+ <key>firstVisibleLine</key>
263
+ <integer>76</integer>
264
+ </dict>
265
+ <key>test/test_base_pipeline.rb</key>
266
+ <dict>
267
+ <key>caret</key>
268
+ <dict>
269
+ <key>column</key>
270
+ <integer>15</integer>
271
+ <key>line</key>
272
+ <integer>28</integer>
273
+ </dict>
274
+ <key>firstVisibleColumn</key>
275
+ <integer>0</integer>
276
+ <key>firstVisibleLine</key>
277
+ <integer>10</integer>
278
+ </dict>
279
+ <key>test/test_ldap_changelog.rb</key>
280
+ <dict>
281
+ <key>caret</key>
282
+ <dict>
283
+ <key>column</key>
284
+ <integer>0</integer>
285
+ <key>line</key>
286
+ <integer>41</integer>
287
+ </dict>
288
+ <key>firstVisibleColumn</key>
289
+ <integer>0</integer>
290
+ <key>firstVisibleLine</key>
291
+ <integer>59</integer>
292
+ </dict>
293
+ <key>test/test_ldap_connector.rb</key>
294
+ <dict>
295
+ <key>caret</key>
296
+ <dict>
297
+ <key>column</key>
298
+ <integer>15</integer>
299
+ <key>line</key>
300
+ <integer>85</integer>
301
+ </dict>
302
+ <key>firstVisibleColumn</key>
303
+ <integer>0</integer>
304
+ <key>firstVisibleLine</key>
305
+ <integer>64</integer>
306
+ </dict>
307
+ <key>test/test_memory_connectors.rb</key>
308
+ <dict>
309
+ <key>caret</key>
310
+ <dict>
311
+ <key>column</key>
312
+ <integer>14</integer>
313
+ <key>line</key>
314
+ <integer>42</integer>
315
+ </dict>
316
+ <key>firstVisibleColumn</key>
317
+ <integer>0</integer>
318
+ <key>firstVisibleLine</key>
319
+ <integer>7</integer>
320
+ </dict>
321
+ </dict>
322
+ <key>openDocuments</key>
323
+ <array>
324
+ <string>lib/ruby_sync/connectors/xml_connector.rb</string>
325
+ <string>lib/ruby_sync/connectors/active_record_connector.rb</string>
326
+ <string>lib/ruby_sync/connectors/active_record_event_handler.rb</string>
327
+ <string>lib/ruby_sync/connectors/active_record_association_handler.rb</string>
328
+ <string>test/test_active_record_vault.rb</string>
329
+ <string>test/test_ldap_connector.rb</string>
330
+ <string>test/test_ldap_changelog.rb</string>
331
+ <string>test/ruby_sync_test.rb</string>
332
+ <string>test/test_base_pipeline.rb</string>
333
+ <string>lib/ruby_sync/util/utilities.rb</string>
334
+ <string>lib/ruby_sync/event.rb</string>
335
+ <string>bin/rubysync</string>
336
+ <string>lib/ruby_sync.rb</string>
337
+ <string>lib/ruby_sync/connectors/ldap_connector.rb</string>
338
+ <string>lib/ruby_sync/connectors/base_connector.rb</string>
339
+ <string>lib/ruby_sync/connectors/memory_connector.rb</string>
340
+ <string>test/test_memory_connectors.rb</string>
341
+ <string>lib/ruby_sync/connectors/connector_event_processing.rb</string>
342
+ </array>
343
+ <key>showFileHierarchyDrawer</key>
344
+ <true/>
345
+ <key>windowFrame</key>
346
+ <string>{{480, 51}, {795, 725}}</string>
347
+ </dict>
348
+ </plist>
data/test/.DS_Store ADDED
Binary file
@@ -38,7 +38,14 @@ module RubySyncTest
38
38
  @vault = @pipeline.vault
39
39
  @client.delete(client_path) if @client[client_path]
40
40
  @vault.delete(vault_path) if @vault[vault_path]
41
- end
41
+ @client.clean
42
+ @vault.clean
43
+ end
44
+
45
+ def teardown
46
+ @vault.clean
47
+ @client.clean
48
+ end
42
49
 
43
50
  def banner(label)
44
51
  puts '*' * 10 + " #{label} " + '*' * 10
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2007 Ritchie Young. All rights reserved.
4
+ #
5
+ # This file is part of RubySync.
6
+ #
7
+ # RubySync is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # RubySync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11
+ # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along with RubySync; if not, write to the
14
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15
+
16
+ #
17
+ # Performs end-to-end tests of the memory based testing connectors.
18
+ #
19
+ [File.dirname(__FILE__) + '/../lib', File.dirname(__FILE__)].each do |lib_path|
20
+ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
21
+ end
22
+ require 'ruby_sync_test'
23
+ require 'hashlike_tests'
24
+ require 'ruby_sync/connectors/xml_connector'
25
+
26
+
27
+ class TestAConnector < RubySync::Connectors::XmlConnector
28
+ dbm_path "/tmp/rubysync_a"
29
+ filename "/tmp/rubysync_a.xml"
30
+ end
31
+
32
+ class TestBConnector < RubySync::Connectors::XmlConnector
33
+ dbm_path "/tmp/rubysync_b"
34
+ filename "/tmp/rubysync_b.xml"
35
+ end
36
+
37
+ class TestPipeline < RubySync::Pipelines::BasePipeline
38
+ client :test_a
39
+ vault :test_b
40
+ end
41
+
42
+ class TestMemoryConnectors < Test::Unit::TestCase
43
+
44
+ include RubySyncTest
45
+ include HashlikeTests
46
+
47
+ end
@@ -22,9 +22,12 @@ require 'ruby_sync_test'
22
22
  class MyActiveRecordConnector < RubySync::Connectors::ActiveRecordConnector
23
23
  model :person
24
24
  application "#{File.dirname(__FILE__)}/../examples/ar_webapp"
25
+ dbm_path "/tmp/rubysync_ar_test"
25
26
  end
26
27
 
27
- class MyMemoryConnector < RubySync::Connectors::MemoryConnector; end
28
+ class MyMemoryConnector < RubySync::Connectors::MemoryConnector
29
+ dbm_path "/tmp/rubysync_memory_test"
30
+ end
28
31
 
29
32
  class TestPipeline < RubySync::Pipelines::BasePipeline
30
33
  client :my_memory
@@ -85,20 +88,20 @@ class TestActiveRecordVault < Test::Unit::TestCase
85
88
  def test_vault_to_client
86
89
  # Turn on the RubySyncObserver to track the changes to people
87
90
  #ActiveRecord::Base.observers = ::RubySyncObserver
88
- ::RubySyncObserver.observe ::Person
89
- ::RubySyncObserver.instance
90
- assert_nil ::RubySyncEvent.find(:first), "Pre-existing events in queue"
91
- person = Person.create :first_name=>"Ritchie", :last_name=>"Young"
92
- assert_not_nil ::RubySyncEvent.find_by_event_type('add'), "No add event generated"
93
- @pipeline.run_once
91
+ # ::RubySyncObserver.observe ::Person
92
+ # ::RubySyncObserver.instance
93
+ # assert_nil ::RubySyncEvent.find(:first), "Pre-existing events in queue"
94
+ # person = Person.create :first_name=>"Ritchie", :last_name=>"Young"
95
+ # assert_not_nil ::RubySyncEvent.find_by_event_type('add'), "No add event generated"
96
+ # @pipeline.run_once
94
97
  # Find the association and use the key to look up the record on the client
95
- key = @vault.association_key_for @pipeline.association_context, person.id
96
- assert_not_nil key, "No association seems to have been created"
97
- c_person = @client.entry_for_own_association_key key
98
- assert_not_nil c_person, "Person wasn't created on client from vault; key='#{key}'\nClient contains:\n#{@client.inspect}"
99
- assert_equal "Ritchie", c_person['givenName'][0]
100
- assert_equal "Young", c_person['sn'][0]
101
- ActiveRecord::Base.observers = [] # Stop tracking changes to people
98
+ #key = @vault.association_key_for @pipeline.association_context, person.id
99
+ #assert_not_nil key, "No association seems to have been created"
100
+ #c_person = @client.entry_for_own_association_key key
101
+ #assert_not_nil c_person, "Person wasn't created on client from vault; key='#{key}'\nClient contains:\n#{@client.inspect}"
102
+ #assert_equal "Ritchie", c_person['givenName'][0]
103
+ #assert_equal "Young", c_person['sn'][0]
104
+ # ActiveRecord::Base.observers = [] # Stop tracking changes to people
102
105
  end
103
106
 
104
107
  def find_bob
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby -w
2
+ #
3
+ # Copyright (c) 2007 Ritchie Young. All rights reserved.
4
+ #
5
+ # This file is part of RubySync.
6
+ #
7
+ # RubySync is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # RubySync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11
+ # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along with RubySync; if not, write to the
14
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15
+
16
+
17
+ lib_path = File.dirname(__FILE__) + '/../lib'
18
+ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
19
+
20
+ require 'ruby_sync'
21
+ require 'test/unit'
22
+
23
+ class MyConnector < RubySync::Connectors::BaseConnector
24
+
25
+ end
26
+
27
+ class TestBaseConnector < Base::Test::Unit
28
+
29
+ def setup
30
+ @c = MyConnector.new
31
+ @c.clean
32
+ end
33
+
34
+ def test_clean
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby -w
2
+ #
3
+ # Copyright (c) 2007 Ritchie Young. All rights reserved.
4
+ #
5
+ # This file is part of RubySync.
6
+ #
7
+ # RubySync is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # RubySync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11
+ # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along with RubySync; if not, write to the
14
+ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15
+
16
+
17
+ lib_path = File.dirname(__FILE__) + '/../lib'
18
+ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
19
+
20
+ require 'ruby_sync_test'
21
+ require 'hashlike_tests'
22
+ require 'ruby_sync/connectors/ldap_connector'
23
+ require 'ruby_sync/connectors/memory_connector'
24
+
25
+
26
+ class ChangeLogConnector < RubySync::Connectors::LdapConnector
27
+ host 'changelog_ldap'
28
+ port 389
29
+ username 'cn=directory manager'
30
+ password 'password'
31
+ changelog_dn 'cn=changelog'
32
+ search_filter "cn=*"
33
+ search_base "ou=people,dc=9to5magic,dc=com,dc=au"
34
+ end
35
+
36
+ class TestLdapChangelog < Test::Unit::TestCase
37
+
38
+ include RubySyncTest
39
+
40
+ def setup
41
+ end
42
+
43
+ def teardown
44
+ end
45
+
46
+ # Add various types of record and verifies that the appropriate
47
+ # changelog entries appear.
48
+ # Other activity on the LDAP server may interfere with this test.
49
+ def test_get_changes
50
+ banner "test_get_changes"
51
+ c = ChangeLogConnector.new
52
+ path = "cn=bob,#{c.search_base}"
53
+ c.delete(path) if c[path]
54
+ c.each_change do |event|
55
+ end # Ignore up til now
56
+
57
+
58
+ c.add(path, c.create_operations_for(ldap_attr))
59
+ assert_event :add, c, path
60
+
61
+ c.modify(path, [
62
+ RubySync::Operation.replace('mail', "bob@fischer.com"),
63
+ RubySync::Operation.add('givenName', "Robert")
64
+ ])
65
+ event = assert_event :modify, c, path
66
+ puts event.payload.inspect
67
+
68
+ c.delete(path)
69
+ assert_event :delete, c, path
70
+ end
71
+
72
+ private
73
+
74
+ def ldap_attr
75
+ {
76
+ "objectclass"=>['inetOrgPerson'],
77
+ "cn"=>'bob',
78
+ "sn"=>'roberts',
79
+ "mail"=>"bob@roberts.com"
80
+ }
81
+ end
82
+
83
+ def assert_event type, connector, path
84
+ events = 0
85
+ the_event=nil
86
+ connector.each_change do |event|
87
+ the_event = event
88
+ events += 1
89
+ assert_equal type.to_sym, event.type
90
+ assert_equal connector, event.source
91
+ assert_equal path, event.source_path
92
+ end
93
+ assert_equal 1, events, "wrong number of events on #{type.to_s}"
94
+ the_event
95
+ end
96
+
97
+ end
@@ -24,7 +24,7 @@ require 'ruby_sync/connectors/memory_connector'
24
24
 
25
25
 
26
26
  class ChangeLogConnector < RubySync::Connectors::LdapConnector
27
- host '10.1.1.4'
27
+ host 'changelog_ldap'
28
28
  port 389
29
29
  username 'cn=directory manager'
30
30
  password 'password'
@@ -34,7 +34,7 @@ class ChangeLogConnector < RubySync::Connectors::LdapConnector
34
34
  end
35
35
 
36
36
  class MyLdapConnector < RubySync::Connectors::LdapConnector
37
- host 'localhost'
37
+ host 'any_ldap'
38
38
  port 10389
39
39
  username 'uid=admin,ou=system'
40
40
  password 'secret'
@@ -93,55 +93,9 @@ class TestLdapConnector < Test::Unit::TestCase
93
93
  end
94
94
 
95
95
 
96
- # Add various types of record and verifies that the appropriate
97
- # changelog entries appear.
98
- # Other activity on the LDAP server may interfere with this test.
99
- def test_get_changes
100
- banner "test_get_changes"
101
- c = ChangeLogConnector.new
102
- path = "cn=bob,#{c.search_base}"
103
- c.delete(path) if c[path]
104
- c.each_change do |event|
105
- end # Ignore up til now
106
-
107
-
108
- c.add(path, c.create_operations_for(ldap_attr))
109
- assert_event :add, c, path
110
-
111
- c.modify(path, [
112
- RubySync::Operation.replace('mail', "bob@fischer.com"),
113
- RubySync::Operation.add('givenName', "Robert")
114
- ])
115
- event = assert_event :modify, c, path
116
- puts event.payload.inspect
117
-
118
- c.delete(path)
119
- assert_event :delete, c, path
120
- end
121
96
 
122
97
  private
123
98
 
124
- def ldap_attr
125
- {
126
- "objectclass"=>['inetOrgPerson'],
127
- "cn"=>'bob',
128
- "sn"=>'roberts',
129
- "mail"=>"bob@roberts.com"
130
- }
131
- end
132
99
 
133
- def assert_event type, connector, path
134
- events = 0
135
- the_event=nil
136
- connector.each_change do |event|
137
- the_event = event
138
- events += 1
139
- assert_equal type.to_sym, event.type
140
- assert_equal connector, event.source
141
- assert_equal path, event.source_path
142
- end
143
- assert_equal 1, events, "wrong number of events on #{type.to_s}"
144
- the_event
145
- end
146
100
 
147
101
  end
@@ -24,12 +24,17 @@ require 'hashlike_tests'
24
24
  require 'ruby_sync/connectors/memory_connector'
25
25
 
26
26
 
27
- class TestConnector < RubySync::Connectors::MemoryConnector
27
+ class TestAConnector < RubySync::Connectors::MemoryConnector
28
+ dbm_path "/tmp/rubysync_a"
29
+ end
30
+
31
+ class TestBConnector < RubySync::Connectors::MemoryConnector
32
+ dbm_path "/tmp/rubysync_b"
28
33
  end
29
34
 
30
35
  class TestPipeline < RubySync::Pipelines::BasePipeline
31
- client :test
32
- vault :test
36
+ client :test_a
37
+ vault :test_b
33
38
  end
34
39
 
35
40
  class TestMemoryConnectors < Test::Unit::TestCase