rubysync 0.0.1
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.
- data/bin/rubysync +312 -0
- data/examples/ar_client_webapp/README +182 -0
- data/examples/ar_client_webapp/Rakefile +10 -0
- data/examples/ar_client_webapp/app/controllers/application.rb +7 -0
- data/examples/ar_client_webapp/app/controllers/user_controller.rb +5 -0
- data/examples/ar_client_webapp/app/helpers/application_helper.rb +3 -0
- data/examples/ar_client_webapp/app/helpers/user_helper.rb +2 -0
- data/examples/ar_client_webapp/app/models/user.rb +2 -0
- data/examples/ar_client_webapp/config/boot.rb +45 -0
- data/examples/ar_client_webapp/config/database.yml +36 -0
- data/examples/ar_client_webapp/config/environment.rb +60 -0
- data/examples/ar_client_webapp/config/environments/development.rb +21 -0
- data/examples/ar_client_webapp/config/environments/production.rb +18 -0
- data/examples/ar_client_webapp/config/environments/test.rb +19 -0
- data/examples/ar_client_webapp/config/routes.rb +23 -0
- data/examples/ar_client_webapp/db/migrate/001_create_users.rb +13 -0
- data/examples/ar_client_webapp/db/schema.rb +13 -0
- data/examples/ar_client_webapp/doc/README_FOR_APP +2 -0
- data/examples/ar_client_webapp/public/404.html +30 -0
- data/examples/ar_client_webapp/public/500.html +30 -0
- data/examples/ar_client_webapp/public/dispatch.cgi +10 -0
- data/examples/ar_client_webapp/public/dispatch.fcgi +24 -0
- data/examples/ar_client_webapp/public/dispatch.rb +10 -0
- data/examples/ar_client_webapp/public/favicon.ico +0 -0
- data/examples/ar_client_webapp/public/images/rails.png +0 -0
- data/examples/ar_client_webapp/public/index.html +277 -0
- data/examples/ar_client_webapp/public/javascripts/application.js +2 -0
- data/examples/ar_client_webapp/public/javascripts/controls.js +833 -0
- data/examples/ar_client_webapp/public/javascripts/dragdrop.js +942 -0
- data/examples/ar_client_webapp/public/javascripts/effects.js +1088 -0
- data/examples/ar_client_webapp/public/javascripts/prototype.js +2515 -0
- data/examples/ar_client_webapp/public/robots.txt +1 -0
- data/examples/ar_client_webapp/script/about +3 -0
- data/examples/ar_client_webapp/script/breakpointer +3 -0
- data/examples/ar_client_webapp/script/console +3 -0
- data/examples/ar_client_webapp/script/destroy +3 -0
- data/examples/ar_client_webapp/script/generate +3 -0
- data/examples/ar_client_webapp/script/performance/benchmarker +3 -0
- data/examples/ar_client_webapp/script/performance/profiler +3 -0
- data/examples/ar_client_webapp/script/plugin +3 -0
- data/examples/ar_client_webapp/script/process/inspector +3 -0
- data/examples/ar_client_webapp/script/process/reaper +3 -0
- data/examples/ar_client_webapp/script/process/spawner +3 -0
- data/examples/ar_client_webapp/script/runner +3 -0
- data/examples/ar_client_webapp/script/server +3 -0
- data/examples/ar_client_webapp/test/fixtures/users.yml +5 -0
- data/examples/ar_client_webapp/test/functional/user_controller_test.rb +18 -0
- data/examples/ar_client_webapp/test/test_helper.rb +28 -0
- data/examples/ar_client_webapp/test/unit/user_test.rb +10 -0
- data/examples/ar_webapp/README +1 -0
- data/examples/ar_webapp/Rakefile +10 -0
- data/examples/ar_webapp/app/controllers/application.rb +7 -0
- data/examples/ar_webapp/app/controllers/hobbies_controller.rb +10 -0
- data/examples/ar_webapp/app/controllers/interests_controller.rb +9 -0
- data/examples/ar_webapp/app/controllers/people_controller.rb +14 -0
- data/examples/ar_webapp/app/controllers/ruby_sync_associations_controller.rb +10 -0
- data/examples/ar_webapp/app/helpers/application_helper.rb +3 -0
- data/examples/ar_webapp/app/models/hobby.rb +5 -0
- data/examples/ar_webapp/app/models/interest.rb +6 -0
- data/examples/ar_webapp/app/models/person.rb +9 -0
- data/examples/ar_webapp/app/models/ruby_sync_association.rb +5 -0
- data/examples/ar_webapp/app/models/ruby_sync_event.rb +9 -0
- data/examples/ar_webapp/app/models/ruby_sync_observer.rb +28 -0
- data/examples/ar_webapp/app/models/ruby_sync_operation.rb +20 -0
- data/examples/ar_webapp/app/models/ruby_sync_state.rb +2 -0
- data/examples/ar_webapp/app/models/ruby_sync_value.rb +7 -0
- data/examples/ar_webapp/app/views/layouts/application.rhtml +19 -0
- data/examples/ar_webapp/app/views/people/show.rhtml +18 -0
- data/examples/ar_webapp/config/boot.rb +45 -0
- data/examples/ar_webapp/config/database.yml +36 -0
- data/examples/ar_webapp/config/environment.rb +61 -0
- data/examples/ar_webapp/config/environments/development.rb +21 -0
- data/examples/ar_webapp/config/environments/production.rb +18 -0
- data/examples/ar_webapp/config/environments/test.rb +19 -0
- data/examples/ar_webapp/config/routes.rb +23 -0
- data/examples/ar_webapp/db/migrate/001_create_people.rb +12 -0
- data/examples/ar_webapp/db/migrate/002_create_interests.rb +12 -0
- data/examples/ar_webapp/db/migrate/003_create_hobbies.rb +11 -0
- data/examples/ar_webapp/db/migrate/004_create_ruby_sync_associations.rb +18 -0
- data/examples/ar_webapp/db/migrate/005_create_ruby_sync_events.rb +16 -0
- data/examples/ar_webapp/db/migrate/006_create_ruby_sync_operations.rb +15 -0
- data/examples/ar_webapp/db/migrate/007_create_ruby_sync_values.rb +12 -0
- data/examples/ar_webapp/db/migrate/008_ruby_sync_tracking.rb +16 -0
- data/examples/ar_webapp/db/migrate/009_create_ruby_sync_states.rb +10 -0
- data/examples/ar_webapp/db/schema.rb +56 -0
- data/examples/ar_webapp/doc/README_FOR_APP +2 -0
- data/examples/ar_webapp/public/404.html +30 -0
- data/examples/ar_webapp/public/500.html +30 -0
- data/examples/ar_webapp/public/dispatch.cgi +10 -0
- data/examples/ar_webapp/public/dispatch.fcgi +24 -0
- data/examples/ar_webapp/public/dispatch.rb +10 -0
- data/examples/ar_webapp/public/favicon.ico +0 -0
- data/examples/ar_webapp/public/images/rails.png +0 -0
- data/examples/ar_webapp/public/index.html +277 -0
- data/examples/ar_webapp/public/javascripts/application.js +2 -0
- data/examples/ar_webapp/public/javascripts/controls.js +833 -0
- data/examples/ar_webapp/public/javascripts/dragdrop.js +942 -0
- data/examples/ar_webapp/public/javascripts/effects.js +1088 -0
- data/examples/ar_webapp/public/javascripts/prototype.js +2515 -0
- data/examples/ar_webapp/public/robots.txt +1 -0
- data/examples/ar_webapp/script/about +3 -0
- data/examples/ar_webapp/script/breakpointer +3 -0
- data/examples/ar_webapp/script/console +3 -0
- data/examples/ar_webapp/script/destroy +3 -0
- data/examples/ar_webapp/script/generate +3 -0
- data/examples/ar_webapp/script/performance/benchmarker +3 -0
- data/examples/ar_webapp/script/performance/profiler +3 -0
- data/examples/ar_webapp/script/plugin +3 -0
- data/examples/ar_webapp/script/process/inspector +3 -0
- data/examples/ar_webapp/script/process/reaper +3 -0
- data/examples/ar_webapp/script/process/spawner +3 -0
- data/examples/ar_webapp/script/runner +3 -0
- data/examples/ar_webapp/script/server +3 -0
- data/examples/ar_webapp/test/fixtures/association_keys.yml +5 -0
- data/examples/ar_webapp/test/fixtures/hobbies.yml +5 -0
- data/examples/ar_webapp/test/fixtures/interests.yml +5 -0
- data/examples/ar_webapp/test/fixtures/people.yml +9 -0
- data/examples/ar_webapp/test/fixtures/ruby_sync_events.yml +5 -0
- data/examples/ar_webapp/test/fixtures/ruby_sync_operations.yml +5 -0
- data/examples/ar_webapp/test/fixtures/ruby_sync_states.yml +5 -0
- data/examples/ar_webapp/test/fixtures/ruby_sync_values.yml +5 -0
- data/examples/ar_webapp/test/test_helper.rb +28 -0
- data/examples/ar_webapp/test/unit/association_key_test.rb +8 -0
- data/examples/ar_webapp/test/unit/hobby_test.rb +10 -0
- data/examples/ar_webapp/test/unit/interest_test.rb +10 -0
- data/examples/ar_webapp/test/unit/person_test.rb +10 -0
- data/examples/ar_webapp/test/unit/ruby_sync_event_test.rb +12 -0
- data/examples/ar_webapp/test/unit/ruby_sync_observer_test.rb +57 -0
- data/examples/ar_webapp/test/unit/ruby_sync_operation_test.rb +10 -0
- data/examples/ar_webapp/test/unit/ruby_sync_state_test.rb +10 -0
- data/examples/ar_webapp/test/unit/ruby_sync_value_test.rb +10 -0
- data/examples/ims2/connectors/hr_db_connector.rb +8 -0
- data/examples/ims2/connectors/my_csv_connector.rb +12 -0
- data/examples/ims2/pipelines/hr_import_pipeline.rb +33 -0
- data/examples/my_ims/connectors/corp_directory_connector.rb +12 -0
- data/examples/my_ims/connectors/finance_connector.rb +7 -0
- data/examples/my_ims/connectors/hr_db_connector.rb +7 -0
- data/examples/my_ims/pipelines/finance_pipeline.rb +33 -0
- data/examples/my_ims/pipelines/hr_import_pipeline.rb +29 -0
- data/lib/ruby_sync/connectors/active_record_connector.rb +198 -0
- data/lib/ruby_sync/connectors/base_connector.rb +317 -0
- data/lib/ruby_sync/connectors/connector_event_processing.rb +78 -0
- data/lib/ruby_sync/connectors/csv_file_connector.rb +95 -0
- data/lib/ruby_sync/connectors/file_connector.rb +74 -0
- data/lib/ruby_sync/connectors/ldap_connector.rb +192 -0
- data/lib/ruby_sync/connectors/memory_connector.rb +185 -0
- data/lib/ruby_sync/event.rb +220 -0
- data/lib/ruby_sync/operation.rb +82 -0
- data/lib/ruby_sync/pipelines/base_pipeline.rb +360 -0
- data/lib/ruby_sync/util/metaid.rb +24 -0
- data/lib/ruby_sync/util/utilities.rb +115 -0
- data/lib/ruby_sync.rb +81 -0
- data/test/hashlike_tests.rb +111 -0
- data/test/ruby_sync_test.rb +48 -0
- data/test/test_active_record_vault.rb +113 -0
- data/test/test_csv_file_connector.rb +75 -0
- data/test/test_event.rb +40 -0
- data/test/test_ldap_connector.rb +89 -0
- data/test/test_memory_connectors.rb +40 -0
- data/test/ts_rubysync.rb +20 -0
- metadata +316 -0
@@ -0,0 +1,48 @@
|
|
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'
|
21
|
+
require 'test/unit'
|
22
|
+
|
23
|
+
module RubySyncTest
|
24
|
+
|
25
|
+
|
26
|
+
def initialize(test)
|
27
|
+
super(test)
|
28
|
+
@bob_details = {'givenName'=>['Robert'],
|
29
|
+
'sn'=>['Smith'],
|
30
|
+
'interests'=>['music', 'makeup']
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def setup
|
36
|
+
@pipeline = TestPipeline.new
|
37
|
+
@client = @pipeline.client
|
38
|
+
@vault = @pipeline.vault
|
39
|
+
@client.delete(client_path) if @client[client_path]
|
40
|
+
@vault.delete(vault_path) if @vault[vault_path]
|
41
|
+
end
|
42
|
+
|
43
|
+
def banner(label)
|
44
|
+
puts '*' * 10 + " #{label} " + '*' * 10
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,113 @@
|
|
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
|
+
|
22
|
+
class MyActiveRecordConnector < RubySync::Connectors::ActiveRecordConnector
|
23
|
+
options(
|
24
|
+
:model=>:person,
|
25
|
+
:application=>"#{File.dirname(__FILE__)}/../examples/ar_webapp"
|
26
|
+
)
|
27
|
+
end
|
28
|
+
class MyMemoryConnector < RubySync::Connectors::MemoryConnector; end
|
29
|
+
|
30
|
+
class TestPipeline < RubySync::Pipelines::BasePipeline
|
31
|
+
client :my_memory
|
32
|
+
vault :my_active_record
|
33
|
+
|
34
|
+
allow_in :first_name, :last_name
|
35
|
+
allow_out :first_name, :last_name
|
36
|
+
|
37
|
+
map_client_to_vault :givenName => :first_name,
|
38
|
+
:sn => :last_name
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class TestActiveRecordVault < Test::Unit::TestCase
|
44
|
+
|
45
|
+
include RubySyncTest
|
46
|
+
|
47
|
+
def client_path
|
48
|
+
'bob'
|
49
|
+
end
|
50
|
+
|
51
|
+
def vault_path
|
52
|
+
@vault.path_for_association(RubySync::Association.new(@pipeline.association_context, self.client_path))
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(test)
|
56
|
+
super(test)
|
57
|
+
end
|
58
|
+
|
59
|
+
def start
|
60
|
+
# Wipe existing database content
|
61
|
+
# TODO: Find out how rails does this.
|
62
|
+
::RubySyncAssociation.delete_all
|
63
|
+
::Person.delete_all
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_client_to_vault
|
67
|
+
banner "test_client_to_vault"
|
68
|
+
@client.add client_path, @client.create_operations_for(@bob_details)
|
69
|
+
assert_nil find_bob, "Vault already contains bob"
|
70
|
+
@pipeline.run_once
|
71
|
+
assert_not_nil find_bob, "#{vault_path} wasn't created on the vault"
|
72
|
+
#assert_equal @bob_details, @vault[vault_path].reject {|k,v| [:modifier,:association].include? k}
|
73
|
+
if @client.respond_to? :delete
|
74
|
+
@client.delete client_path
|
75
|
+
# assert_equal @bob_details, @vault[vault_path].reject {|k,v| [:modifier,:association].include? k}
|
76
|
+
assert_nil @client[client_path], "Bob wasn't deleted from the client"
|
77
|
+
@pipeline.run_once
|
78
|
+
assert_nil @client[client_path], "Bob reappeared on the client"
|
79
|
+
assert_nil find_bob, "Bob wasn't deleted from the vault"
|
80
|
+
@pipeline.run_once # run again in case of echoes
|
81
|
+
assert_nil @client[client_path], "Bob reappeared on the client"
|
82
|
+
assert_nil find_bob, "Bob reappeared in the vault. He may have been created by an echoed add event"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_vault_to_client
|
87
|
+
# Turn on the RubySyncObserver to track the changes to people
|
88
|
+
#ActiveRecord::Base.observers = ::RubySyncObserver
|
89
|
+
::RubySyncObserver.observe ::Person
|
90
|
+
::RubySyncObserver.instance
|
91
|
+
assert_nil ::RubySyncEvent.find(:first), "Pre-existing events in queue"
|
92
|
+
person = Person.create :first_name=>"Ritchie", :last_name=>"Young"
|
93
|
+
assert_not_nil ::RubySyncEvent.find_by_event_type('add'), "No add event generated"
|
94
|
+
@pipeline.run_once
|
95
|
+
# Find the association and use the key to look up the record on the client
|
96
|
+
key = @vault.association_key_for @pipeline.association_context, person.id
|
97
|
+
assert_not_nil key, "No association seems to have been created"
|
98
|
+
c_person = @client.entry_for_own_association_key key
|
99
|
+
assert_not_nil c_person, "Person wasn't created on client from vault; key='#{key}'\nClient contains:\n#{@client.inspect}"
|
100
|
+
assert_equal "Ritchie", c_person['givenName'][0]
|
101
|
+
assert_equal "Young", c_person['sn'][0]
|
102
|
+
ActiveRecord::Base.observers = [] # Stop tracking changes to people
|
103
|
+
end
|
104
|
+
|
105
|
+
def find_bob
|
106
|
+
Person.find_by_first_name "Robert"
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_fields
|
110
|
+
assert_equal(%w{first_name last_name}.sort, ::MyActiveRecordConnector.fields.sort)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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
|
+
lib_path = File.dirname(__FILE__) + '/../lib'
|
17
|
+
$:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
|
18
|
+
|
19
|
+
require 'ruby_sync_test'
|
20
|
+
require 'ruby_sync/connectors/csv_file_connector'
|
21
|
+
require 'ruby_sync/connectors/memory_connector'
|
22
|
+
require 'csv'
|
23
|
+
|
24
|
+
|
25
|
+
class TestCsvFileConnector < RubySync::Connectors::CsvFileConnector
|
26
|
+
end
|
27
|
+
|
28
|
+
class TestMemoryConnector < RubySync::Connectors::MemoryConnector
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
class TestPipeline < RubySync::Pipelines::BasePipeline
|
33
|
+
client :test_csv_file,
|
34
|
+
:field_names => ['id', 'given name', 'last name', 'email'],
|
35
|
+
:path_field => 'id',
|
36
|
+
:in_path => File.expand_path("~/rubysync/csv_test/in"),
|
37
|
+
:out_path => File.expand_path("~/rubysync/csv_test/out")
|
38
|
+
|
39
|
+
vault :test_memory
|
40
|
+
|
41
|
+
map_client_to_vault 'id'=>:cn,
|
42
|
+
'given name'=>:givenName,
|
43
|
+
'last name'=>:sn,
|
44
|
+
"email"=>:mail
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
class TestCsvConnector < Test::Unit::TestCase
|
49
|
+
|
50
|
+
include RubySyncTest
|
51
|
+
|
52
|
+
def setup
|
53
|
+
@pipeline = TestPipeline.new
|
54
|
+
@client = @pipeline.client
|
55
|
+
@vault = @pipeline.vault
|
56
|
+
@filename = "#{@client.in_path}/client_to_vault.csv"
|
57
|
+
@pipeline.run_once # create the in and out directories if necessary
|
58
|
+
File.delete @filename if File.exists? @filename
|
59
|
+
@bob_details = {:cn=>'bob', :givenName=>"Robert", :sn=>"Smith", :mail=>'bob@thecure.com'}
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_client_to_vault
|
63
|
+
banner :test_client_to_vault
|
64
|
+
CSV.open(@filename, 'w') do |csv|
|
65
|
+
csv << [:cn, :givenName, :sn, :mail].collect {|key| @bob_details[key]}
|
66
|
+
end
|
67
|
+
assert_nil @vault["bob"], "Vault already contains bob"
|
68
|
+
@pipeline.run_once
|
69
|
+
assert_not_nil @vault["bob"], "Bob wasn't created in vault"
|
70
|
+
modded_bob={}; @bob_details.each_pair {|k,v| modded_bob[k]=v.as_array}
|
71
|
+
assert_equal modded_bob, @vault["bob"].reject {|k,v| ['modifier',:association].include? k}
|
72
|
+
@pipeline.run_once
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/test/test_event.rb
ADDED
@@ -0,0 +1,40 @@
|
|
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 TestEvent < Test::Unit::TestCase
|
24
|
+
|
25
|
+
def setup
|
26
|
+
payload = [
|
27
|
+
RubySync::Operation.add("name", "Matthew"),
|
28
|
+
RubySync::Operation.add(:modifier, "rubysync")
|
29
|
+
]
|
30
|
+
@connector = RubySync::Connectors::MemoryConnector.new :name=>"Test"
|
31
|
+
@event = RubySync::Event.modify @connector, 'source_path', nil, payload
|
32
|
+
puts @event.to_yaml
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_sets_value?
|
36
|
+
assert @event.sets_value?(:modifier, "rubysync")
|
37
|
+
assert !@event.sets_value?(:modifier, "Matthew")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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/memory_connector'
|
24
|
+
|
25
|
+
|
26
|
+
class MyLdapConnector < RubySync::Connectors::LdapConnector; end
|
27
|
+
class MyMemoryConnector < RubySync::Connectors::MemoryConnector; end
|
28
|
+
|
29
|
+
class TestPipeline < RubySync::Pipelines::BasePipeline
|
30
|
+
|
31
|
+
client :my_ldap,
|
32
|
+
:host=>'localhost',
|
33
|
+
:port=>10389,
|
34
|
+
:username=>'uid=admin,ou=system',
|
35
|
+
:password=>'secret',
|
36
|
+
:search_filter=>"cn=*",
|
37
|
+
:search_base=>"dc=example,dc=com"
|
38
|
+
|
39
|
+
vault :my_memory
|
40
|
+
|
41
|
+
allow_out :cn, :givenName, :sn
|
42
|
+
|
43
|
+
out_transform do
|
44
|
+
if type == :add or type == :modify
|
45
|
+
each_operation_on("givenName") { |operation| append operation.same_but_on('cn') }
|
46
|
+
append RubySync::Operation.new(:add, "objectclass", ['inetOrgPerson'])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
class TestLdapConnector < Test::Unit::TestCase
|
54
|
+
|
55
|
+
include RubySyncTest
|
56
|
+
include HashlikeTests
|
57
|
+
|
58
|
+
def unsynchable
|
59
|
+
[:objectclass, :interests, :cn, :dn]
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def vault_path
|
64
|
+
# TODO: Try using a different path for the vault that's derived from the client source path
|
65
|
+
'cn=bob,dc=example,dc=com'
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def client_path
|
70
|
+
'cn=bob,dc=example,dc=com'
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def test_ldap_add
|
75
|
+
assert_nil @client[client_path], "#{client_path} already exists on client"
|
76
|
+
ldap_attr = {
|
77
|
+
"objectclass"=>['inetOrgPerson'],
|
78
|
+
"cn"=>'bob',
|
79
|
+
"sn"=>'roberts',
|
80
|
+
"mail"=>"bob@roberts.com"
|
81
|
+
}
|
82
|
+
@client.add client_path, @client.create_operations_for(ldap_attr)
|
83
|
+
assert_not_nil @client[client_path], "#{client_path} wasn't created"
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_client_to_vault
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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/memory_connector'
|
25
|
+
|
26
|
+
|
27
|
+
class TestConnector < RubySync::Connectors::MemoryConnector
|
28
|
+
end
|
29
|
+
|
30
|
+
class TestPipeline < RubySync::Pipelines::BasePipeline
|
31
|
+
client :test
|
32
|
+
vault :test
|
33
|
+
end
|
34
|
+
|
35
|
+
class TestMemoryConnectors < Test::Unit::TestCase
|
36
|
+
|
37
|
+
include RubySyncTest
|
38
|
+
include HashlikeTests
|
39
|
+
|
40
|
+
end
|
data/test/ts_rubysync.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
require 'test/unit'
|
17
|
+
require 'test_memory_connectors'
|
18
|
+
require 'test_csv_file_connector'
|
19
|
+
require 'test_ldap_connector'
|
20
|
+
require 'test_active_record_connector'
|