rubysync 0.0.3 → 0.0.4

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 (45) hide show
  1. data/HISTORY.txt +4 -0
  2. data/Manifest.txt +25 -12
  3. data/README.txt +0 -2
  4. data/bin/rubysync +20 -6
  5. data/bin/rubysync.rb +333 -0
  6. data/docs/in_pipeline.graffle +2690 -0
  7. data/docs/init_openldap.ldif +11 -0
  8. data/docs/out_pipeline.graffle +3274 -0
  9. data/docs/schema/99rubysync.ldif +27 -0
  10. data/docs/schema/rubysync.schema +16 -0
  11. data/docs/to_sync.txt +15 -0
  12. data/docs/walkthru.txt +186 -0
  13. data/lib/ruby_sync.rb +7 -29
  14. data/lib/ruby_sync/connectors/base_connector.rb +55 -86
  15. data/lib/ruby_sync/connectors/csv_file_connector.rb +16 -4
  16. data/lib/ruby_sync/connectors/ldap_associations.rb +126 -0
  17. data/lib/ruby_sync/connectors/ldap_changelog_connector.rb +127 -0
  18. data/lib/ruby_sync/connectors/ldap_connector.rb +29 -192
  19. data/lib/ruby_sync/connectors/memory_connector.rb +1 -1
  20. data/lib/ruby_sync/connectors/xml_connector.rb +105 -32
  21. data/lib/ruby_sync/event.rb +40 -12
  22. data/lib/ruby_sync/operation.rb +18 -2
  23. data/lib/ruby_sync/pipelines/base_pipeline.rb +44 -6
  24. data/lib/ruby_sync/util/utilities.rb +97 -4
  25. data/lib/rubysync.rb +1 -1
  26. data/rubysync.tmproj +279 -59
  27. data/test/.LCKts_rubysync.rb~ +1 -0
  28. data/test/ruby_sync_test.rb +9 -4
  29. data/test/{test_active_record_vault.rb → tc_active_record_connector.rb} +11 -7
  30. data/test/{test_base_connector.rb → tc_base_connector.rb} +1 -1
  31. data/test/{test_base_pipeline.rb → tc_base_pipeline.rb} +1 -1
  32. data/test/tc_changelog_ldap_connector.rb +93 -0
  33. data/test/{test_csv_file_connector.rb → tc_csv_file_connector.rb} +14 -5
  34. data/test/{test_event.rb → tc_event.rb} +1 -1
  35. data/test/{test_ldap_changelog.rb → tc_ldap_changelog.rb} +1 -1
  36. data/test/{test_ldap_connector.rb → tc_ldap_connector.rb} +20 -22
  37. data/test/{test_ldap_vault.rb → tc_ldap_vault.rb} +2 -2
  38. data/test/{test_ldif.rb → tc_ldif.rb} +1 -1
  39. data/test/{test_memory_connectors.rb → tc_memory_connectors.rb} +10 -6
  40. data/test/{test_rubysync.rb → tc_rubysync.rb} +4 -4
  41. data/test/tc_transformation.rb +71 -0
  42. data/test/{test_utilities.rb → tc_utilities.rb} +28 -1
  43. data/test/tc_xml_connectors.rb +107 -6
  44. data/test/ts_rubysync.rb +11 -6
  45. metadata +33 -28
@@ -0,0 +1 @@
1
+ /Users/ritchiey/Projects/rubysync/test/.LCKts_rubysync.rb~
@@ -22,10 +22,12 @@ require 'test/unit'
22
22
 
23
23
  module RubySyncTest
24
24
 
25
+
26
+ include RubySync::Utilities
25
27
 
26
28
  def initialize(test)
27
29
  super(test)
28
- @bob_details = {'givenName'=>['Robert'],
30
+ @bob_details = {'givenName'=>['bob'],
29
31
  'sn'=>['Smith'],
30
32
  'interests'=>['music', 'makeup']
31
33
  }
@@ -33,14 +35,17 @@ module RubySyncTest
33
35
 
34
36
 
35
37
  def setup
36
- @pipeline = TestPipeline.new
38
+ @pipeline = testPipeline.new
37
39
  @client = @pipeline.client
38
40
  @vault = @pipeline.vault
39
- @client.delete(client_path) if @client[client_path]
40
- @vault.delete(vault_path) if @vault[vault_path]
41
41
  @client.clean
42
42
  @vault.clean
43
+ @pipeline.started
44
+ @client.delete(client_path) if @client[client_path]
45
+ @vault.delete(vault_path) if @vault[vault_path]
46
+ @pipeline.stopped
43
47
  end
48
+
44
49
 
45
50
  def teardown
46
51
  @vault.clean
@@ -19,19 +19,19 @@ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path
19
19
 
20
20
  require 'ruby_sync_test'
21
21
 
22
- class MyActiveRecordConnector < RubySync::Connectors::ActiveRecordConnector
22
+ class ArActiveRecordConnector < RubySync::Connectors::ActiveRecordConnector
23
23
  model :person
24
24
  application "#{File.dirname(__FILE__)}/../examples/ar_webapp"
25
25
  dbm_path "/tmp/rubysync_ar_test"
26
26
  end
27
27
 
28
- class MyMemoryConnector < RubySync::Connectors::MemoryConnector
28
+ class ArMemoryConnector < RubySync::Connectors::MemoryConnector
29
29
  dbm_path "/tmp/rubysync_memory_test"
30
30
  end
31
31
 
32
- class TestPipeline < RubySync::Pipelines::BasePipeline
33
- client :my_memory
34
- vault :my_active_record
32
+ class ArTestPipeline < RubySync::Pipelines::BasePipeline
33
+ client :ar_memory
34
+ vault :ar_active_record
35
35
 
36
36
  allow_in :first_name, :last_name
37
37
  allow_out :first_name, :last_name
@@ -42,10 +42,14 @@ end
42
42
 
43
43
 
44
44
 
45
- class TestActiveRecordVault < Test::Unit::TestCase
45
+ class TcActiveRecordConnector < Test::Unit::TestCase
46
46
 
47
47
  include RubySyncTest
48
48
 
49
+ def testPipeline
50
+ ArTestPipeline
51
+ end
52
+
49
53
  def client_path
50
54
  'bob'
51
55
  end
@@ -109,7 +113,7 @@ class TestActiveRecordVault < Test::Unit::TestCase
109
113
  end
110
114
 
111
115
  def test_fields
112
- assert_equal(%w{first_name last_name}.sort, ::MyActiveRecordConnector.fields.sort)
116
+ assert_equal(%w{first_name last_name}.sort, ::ArActiveRecordConnector.fields.sort)
113
117
  end
114
118
 
115
119
  end
@@ -24,7 +24,7 @@ class MyConnector < RubySync::Connectors::BaseConnector
24
24
 
25
25
  end
26
26
 
27
- class TestBaseConnector < Base::Test::Unit
27
+ class TcBaseConnector < Base::Test::Unit
28
28
 
29
29
  def setup
30
30
  @c = MyConnector.new
@@ -41,7 +41,7 @@ class TestPipeline < RubySync::Pipelines::BasePipeline
41
41
 
42
42
  end
43
43
 
44
- class TestBasePipeline < Test::Unit::TestCase
44
+ class TcBasePipeline < Test::Unit::TestCase
45
45
 
46
46
 
47
47
  def setup
@@ -0,0 +1,93 @@
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
+ 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/ldap_changelog_connector'
24
+ require 'ruby_sync/connectors/memory_connector'
25
+
26
+
27
+ class MyChangeLogConnector < RubySync::Connectors::LdapChangelogConnector
28
+ host 'changelog_ldap'
29
+ port 389
30
+ username 'cn=directory manager'
31
+ password 'password'
32
+ changelog_dn 'cn=changelog'
33
+ search_filter "cn=*"
34
+ search_base "ou=people,dc=9to5magic,dc=com,dc=au"
35
+ end
36
+
37
+ class MyMemoryConnector < RubySync::Connectors::MemoryConnector; end
38
+
39
+ class TcPipeline < RubySync::Pipelines::BasePipeline
40
+
41
+ client :my_changelog
42
+
43
+ vault :my_memory
44
+
45
+ allow_out :cn, :givenName, :sn
46
+
47
+ out_transform do
48
+ if type == :add or type == :modify
49
+ each_operation_on("givenName") { |operation| append operation.same_but_on('cn') }
50
+ append RubySync::Operation.new(:add, "objectclass", ['inetOrgPerson'])
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+
57
+
58
+ class TestLdapChangelogConnector < Test::Unit::TestCase
59
+
60
+ include RubySyncTest
61
+ include HashlikeTests
62
+
63
+ def unsynchable
64
+ [:objectclass, :interests, :cn, :dn]
65
+ end
66
+
67
+
68
+ def vault_path
69
+ 'uid=bob,ou=People,dc=9to5magic,dc=com,dc=au'
70
+ end
71
+
72
+
73
+ def client_path
74
+ 'uid=bob,ou=People,dc=9to5magic,dc=com,dc=au'
75
+ end
76
+
77
+
78
+ def test_ldap_add
79
+ assert_nil @client[client_path], "#{client_path} already exists on client"
80
+ @client.add client_path, @client.create_operations_for(ldap_attr)
81
+ assert_not_nil @client[client_path], "#{client_path} wasn't created"
82
+ end
83
+
84
+ def test_client_to_vault
85
+ end
86
+
87
+
88
+
89
+ private
90
+
91
+
92
+
93
+ end
@@ -17,23 +17,27 @@ lib_path = File.dirname(__FILE__) + '/../lib'
17
17
  $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
18
18
 
19
19
  require 'ruby_sync_test'
20
+ require 'ruby_sync/connectors/file_connector'
20
21
  require 'ruby_sync/connectors/csv_file_connector'
21
22
  require 'ruby_sync/connectors/memory_connector'
22
23
  require 'csv'
23
24
 
24
25
 
25
26
  class TestCsvFileConnector < RubySync::Connectors::CsvFileConnector
27
+ dbm_path "/tmp/rubysync_csv"
26
28
  field_names ['id', 'given name', 'last name', 'email']
27
29
  path_field 'id'
28
30
  in_path File.expand_path("~/rubysync/csv_test/in")
29
31
  out_path File.expand_path("~/rubysync/csv_test/out")
32
+ header_line false
30
33
  end
31
34
 
32
35
  class TestMemoryConnector < RubySync::Connectors::MemoryConnector
36
+ dbm_path "/tmp/rubysync_memory"
33
37
  end
34
38
 
35
39
 
36
- class TestPipeline < RubySync::Pipelines::BasePipeline
40
+ class CsvTestPipeline < RubySync::Pipelines::BasePipeline
37
41
  client :test_csv_file
38
42
 
39
43
  vault :test_memory
@@ -45,20 +49,25 @@ class TestPipeline < RubySync::Pipelines::BasePipeline
45
49
 
46
50
  end
47
51
 
48
- class TestCsvConnector < Test::Unit::TestCase
52
+ class TcCsvConnector < Test::Unit::TestCase
49
53
 
50
54
  include RubySyncTest
51
55
 
52
56
  def setup
53
- @pipeline = TestPipeline.new
57
+ @pipeline = CsvTestPipeline.new
54
58
  @client = @pipeline.client
55
59
  @vault = @pipeline.vault
56
60
  @filename = "#{@client.in_path}/client_to_vault.csv"
57
- @pipeline.run_once # create the in and out directories if necessary
58
61
  File.delete @filename if File.exists? @filename
62
+ @pipeline.run_once # create the in and out directories if necessary
59
63
  @bob_details = {:cn=>'bob', :givenName=>"Robert", :sn=>"Smith", :mail=>'bob@thecure.com'}
60
64
  end
61
65
 
66
+
67
+ # def testPipeline
68
+ # CsvTestPipeline
69
+ # end
70
+
62
71
  def test_client_to_vault
63
72
  banner :test_client_to_vault
64
73
  CSV.open(@filename, 'w') do |csv|
@@ -67,7 +76,7 @@ class TestCsvConnector < Test::Unit::TestCase
67
76
  assert_nil @vault["bob"], "Vault already contains bob"
68
77
  @pipeline.run_once
69
78
  assert_not_nil @vault["bob"], "Bob wasn't created in vault"
70
- modded_bob={}; @bob_details.each_pair {|k,v| modded_bob[k.to_s]=v.as_array}
79
+ modded_bob={}; @bob_details.each_pair {|k,v| modded_bob[k.to_s]=as_array(v)}
71
80
  assert_equal modded_bob, @vault["bob"].reject {|k,v| ['modifier',:association].include? k}
72
81
  @pipeline.run_once
73
82
  end
@@ -20,7 +20,7 @@ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path
20
20
  require 'ruby_sync'
21
21
  require 'test/unit'
22
22
 
23
- class TestEvent < Test::Unit::TestCase
23
+ class TcEvent < Test::Unit::TestCase
24
24
 
25
25
  def setup
26
26
  payload = [
@@ -33,7 +33,7 @@ class ChangeLogConnector < RubySync::Connectors::LdapConnector
33
33
  search_base "ou=people,dc=9to5magic,dc=com,dc=au"
34
34
  end
35
35
 
36
- class TestLdapChangelog < Test::Unit::TestCase
36
+ class TcLdapChangelog < Test::Unit::TestCase
37
37
 
38
38
  include RubySyncTest
39
39
 
@@ -23,28 +23,18 @@ require 'ruby_sync/connectors/ldap_connector'
23
23
  require 'ruby_sync/connectors/memory_connector'
24
24
 
25
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
26
  class MyLdapConnector < RubySync::Connectors::LdapConnector
37
27
  host 'any_ldap'
38
- port 10389
39
- username 'uid=admin,ou=system'
28
+ port 389
29
+ username 'cn=Manager,dc=my-domain,dc=com'
40
30
  password 'secret'
41
31
  search_filter "cn=*"
42
- search_base "dc=example,dc=com"
32
+ search_base "ou=users,o=my-organization,dc=my-domain,dc=com"
43
33
  end
44
34
 
45
35
  class MyMemoryConnector < RubySync::Connectors::MemoryConnector; end
46
36
 
47
- class TestPipeline < RubySync::Pipelines::BasePipeline
37
+ class LdapTestPipeline < RubySync::Pipelines::BasePipeline
48
38
 
49
39
  client :my_ldap
50
40
 
@@ -62,10 +52,14 @@ class TestPipeline < RubySync::Pipelines::BasePipeline
62
52
  end
63
53
 
64
54
 
65
- class TestLdapConnector < Test::Unit::TestCase
55
+ class TCLdapConnector < Test::Unit::TestCase
66
56
 
67
57
  include RubySyncTest
68
58
  include HashlikeTests
59
+
60
+ def testPipeline
61
+ LdapTestPipeline
62
+ end
69
63
 
70
64
  def unsynchable
71
65
  [:objectclass, :interests, :cn, :dn]
@@ -74,12 +68,12 @@ class TestLdapConnector < Test::Unit::TestCase
74
68
 
75
69
  def vault_path
76
70
  # TODO: Try using a different path for the vault that's derived from the client source path
77
- 'cn=bob,dc=example,dc=com'
71
+ 'cn=bob,ou=users,o=my-organization,dc=my-domain,dc=com'
78
72
  end
79
73
 
80
74
 
81
75
  def client_path
82
- 'cn=bob,dc=example,dc=com'
76
+ 'cn=bob,ou=users,o=my-organization,dc=my-domain,dc=com'
83
77
  end
84
78
 
85
79
 
@@ -92,10 +86,14 @@ class TestLdapConnector < Test::Unit::TestCase
92
86
  def test_client_to_vault
93
87
  end
94
88
 
89
+ private
95
90
 
96
-
97
- private
98
-
99
-
100
-
91
+ def ldap_attr
92
+ {
93
+ "objectclass"=>['inetOrgPerson'],
94
+ "cn"=>'bob',
95
+ "sn"=>'roberts'
96
+ #"mail"=>"bob@roberts.com"
97
+ }
98
+ end
101
99
  end
@@ -62,14 +62,14 @@ class TestPipeline < RubySync::Pipelines::BasePipeline
62
62
  in_transform do
63
63
  if type == :add or type == :modify
64
64
  each_operation_on("givenName") { |operation| append operation.same_but_on('cn') }
65
- append RubySync::Operation.new(:add, "objectclass", ['inetOrgPerson', 'organizationalPerson', 'person', 'top', 'RubySyncSynchable'])
65
+ append RubySync::Operation.new(:add, "objectclass", ['organizationalPerson', 'RubySyncSynchable'])
66
66
  end
67
67
  end
68
68
 
69
69
  end
70
70
 
71
71
 
72
- class TestLdapVault < Test::Unit::TestCase
72
+ class TcLdapVault < Test::Unit::TestCase
73
73
 
74
74
  include RubySyncTest
75
75
  include HashlikeTests
@@ -21,7 +21,7 @@ require 'net/ldif'
21
21
  require 'test/unit'
22
22
 
23
23
  # TODO: Work out a cross platform method for testing file:// URL imports
24
- class TestLDIF < Test::Unit::TestCase
24
+ class TcLDIF < Test::Unit::TestCase
25
25
 
26
26
  def setup
27
27
  @ldif = Net::LDIF
@@ -24,22 +24,26 @@ require 'hashlike_tests'
24
24
  require 'ruby_sync/connectors/memory_connector'
25
25
 
26
26
 
27
- class TestAConnector < RubySync::Connectors::MemoryConnector
27
+ class MemoryTestAConnector < RubySync::Connectors::MemoryConnector
28
28
  dbm_path "/tmp/rubysync_a"
29
29
  end
30
30
 
31
- class TestBConnector < RubySync::Connectors::MemoryConnector
31
+ class MemoryTestBConnector < RubySync::Connectors::MemoryConnector
32
32
  dbm_path "/tmp/rubysync_b"
33
33
  end
34
34
 
35
- class TestPipeline < RubySync::Pipelines::BasePipeline
36
- client :test_a
37
- vault :test_b
35
+ class MemoryTestPipeline < RubySync::Pipelines::BasePipeline
36
+ client :memory_test_a
37
+ vault :memory_test_b
38
38
  end
39
39
 
40
- class TestMemoryConnectors < Test::Unit::TestCase
40
+ class TcMemoryConnectors < Test::Unit::TestCase
41
41
 
42
42
  include RubySyncTest
43
43
  include HashlikeTests
44
44
 
45
+ def testPipeline
46
+ MemoryTestPipeline
47
+ end
48
+
45
49
  end
@@ -20,9 +20,9 @@ $:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path
20
20
  require 'ruby_sync'
21
21
  require 'test/unit'
22
22
 
23
- require 'test_csv_file_connector'
24
- require 'test_memory_connectors'
25
- require 'test_ldif'
26
- require 'test_base_pipeline'
23
+ require 'tc_csv_file_connector'
24
+ require 'tc_memory_connectors'
25
+ require 'tc_ldif'
26
+ require 'tc_base_pipeline'
27
27
  #require 'test_ldap_connector'
28
28
  #require 'test_active_record_connector'