ad-framework 0.1.0
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/.gitignore +6 -0
- data/Gemfile +12 -0
- data/README.markdown +36 -0
- data/Rakefile +19 -0
- data/ad-framework.gemspec +25 -0
- data/doc/open_ldap_server.markdown +17 -0
- data/extras/adtest.schema +304 -0
- data/extras/slapd.conf +10 -0
- data/lib/ad-framework.rb +53 -0
- data/lib/ad-framework/attribute.rb +35 -0
- data/lib/ad-framework/attribute_type.rb +133 -0
- data/lib/ad-framework/auxiliary_class.rb +24 -0
- data/lib/ad-framework/config.rb +72 -0
- data/lib/ad-framework/config/attribute_definition.rb +18 -0
- data/lib/ad-framework/config/mapping.rb +26 -0
- data/lib/ad-framework/exceptions.rb +17 -0
- data/lib/ad-framework/fields.rb +44 -0
- data/lib/ad-framework/patterns/callbacks.rb +47 -0
- data/lib/ad-framework/patterns/has_schema.rb +127 -0
- data/lib/ad-framework/patterns/persistence.rb +67 -0
- data/lib/ad-framework/patterns/searchable.rb +117 -0
- data/lib/ad-framework/patterns/validations.rb +50 -0
- data/lib/ad-framework/schema.rb +118 -0
- data/lib/ad-framework/structural_class.rb +61 -0
- data/lib/ad-framework/utilities/entry_builder.rb +77 -0
- data/lib/ad-framework/utilities/transaction.rb +32 -0
- data/lib/ad-framework/utilities/validator.rb +26 -0
- data/lib/ad-framework/version.rb +5 -0
- data/test/helper.rb +71 -0
- data/test/integration/defined_array_test.rb +49 -0
- data/test/integration/defined_integer_test.rb +48 -0
- data/test/integration/defined_string_test.rb +48 -0
- data/test/integration/defined_top_test.rb +101 -0
- data/test/integration/defined_user_test.rb +140 -0
- data/test/irb.rb +2 -0
- data/test/support/factory.rb +67 -0
- data/test/support/ldap.yml +6 -0
- data/test/support/schema/attribute_types.rb +67 -0
- data/test/support/schema/attributes.rb +10 -0
- data/test/support/schema/auxiliary_classes.rb +12 -0
- data/test/support/schema/structural_classes.rb +46 -0
- data/test/support/seed.rb +28 -0
- data/test/support/state.rb +29 -0
- data/test/unit/ad-framework/attribute_test.rb +84 -0
- data/test/unit/ad-framework/attribute_type/class_methods_test.rb +146 -0
- data/test/unit/ad-framework/attribute_type_test.rb +114 -0
- data/test/unit/ad-framework/auxiliary_class_test.rb +39 -0
- data/test/unit/ad-framework/config/attribute_definition_test.rb +26 -0
- data/test/unit/ad-framework/config/mapping_test.rb +41 -0
- data/test/unit/ad-framework/config_test.rb +121 -0
- data/test/unit/ad-framework/fields_test.rb +44 -0
- data/test/unit/ad-framework/patterns/callbacks_test.rb +90 -0
- data/test/unit/ad-framework/patterns/has_schema/class_methods_test.rb +214 -0
- data/test/unit/ad-framework/patterns/has_schema_test.rb +96 -0
- data/test/unit/ad-framework/patterns/persistence_test.rb +126 -0
- data/test/unit/ad-framework/patterns/searchable_test.rb +201 -0
- data/test/unit/ad-framework/patterns/validations_test.rb +113 -0
- data/test/unit/ad-framework/schema_test.rb +268 -0
- data/test/unit/ad-framework/structural_class_test.rb +64 -0
- data/test/unit/ad-framework/utilities/entry_builder_test.rb +107 -0
- data/test/unit/ad-framework/utilities/transaction_test.rb +50 -0
- data/test/unit/ad-framework/utilities/validator_test.rb +46 -0
- data/test/unit/ad-framework_test.rb +116 -0
- metadata +225 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'assert'
|
2
|
+
|
3
|
+
class AD::Framework::Utilities::Transaction
|
4
|
+
|
5
|
+
class BaseTest < Assert::Context
|
6
|
+
desc "a transaction"
|
7
|
+
setup do
|
8
|
+
@structural_class = Factory.structural_class do
|
9
|
+
attr_accessor :count, :before_called, :after_called, :main_called
|
10
|
+
before_create :set_before_called
|
11
|
+
after_create :set_after_called
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
self.count = 0
|
16
|
+
self.before_called = nil
|
17
|
+
self.main_called = nil
|
18
|
+
self.after_called = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def set_before_called
|
24
|
+
self.count += 1
|
25
|
+
self.before_called = self.count
|
26
|
+
end
|
27
|
+
def set_after_called
|
28
|
+
self.count += 1
|
29
|
+
self.after_called = self.count
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@instance = @structural_class.new
|
33
|
+
@transaction = AD::Framework::Utilities::Transaction.new(:create, @instance) do
|
34
|
+
self.count += 1
|
35
|
+
self.main_called = self.count
|
36
|
+
end
|
37
|
+
end
|
38
|
+
subject{ @transaction }
|
39
|
+
|
40
|
+
should have_instance_methods :run
|
41
|
+
|
42
|
+
should "call the before callbacks, then the block, then the after callbacks" do
|
43
|
+
subject.run
|
44
|
+
assert_equal 1, @instance.before_called
|
45
|
+
assert_equal 2, @instance.main_called
|
46
|
+
assert_equal 3, @instance.after_called
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'assert'
|
2
|
+
|
3
|
+
class AD::Framework::Utilities::Validator
|
4
|
+
|
5
|
+
class BaseTest < Assert::Context
|
6
|
+
desc "validator"
|
7
|
+
setup do
|
8
|
+
@structural_class = Factory.structural_class do
|
9
|
+
attributes :name
|
10
|
+
must_set :name
|
11
|
+
end
|
12
|
+
@instance = @structural_class.new
|
13
|
+
@validator = AD::Framework::Utilities::Validator.new(@instance)
|
14
|
+
end
|
15
|
+
subject{ @validator }
|
16
|
+
|
17
|
+
should have_accessors :entry
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class WithAttributeSetTest < BaseTest
|
22
|
+
desc "with attributes set the errors method"
|
23
|
+
setup do
|
24
|
+
@instance.attributes = { :name => "not nil" }
|
25
|
+
end
|
26
|
+
|
27
|
+
should "return an empty hash" do
|
28
|
+
assert_instance_of Hash, subject.errors
|
29
|
+
assert_empty subject.errors
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class WithoutAttributeSetTest < BaseTest
|
34
|
+
desc "with no attributes set the errors method"
|
35
|
+
setup do
|
36
|
+
@instance.attributes = { :name => nil }
|
37
|
+
end
|
38
|
+
|
39
|
+
should "return a hash containing errors for the unset attributes" do
|
40
|
+
assert_instance_of Hash, subject.errors
|
41
|
+
assert_not_empty subject.errors
|
42
|
+
assert_equal "was not set", subject.errors["name"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'assert'
|
2
|
+
|
3
|
+
module AD::Framework
|
4
|
+
|
5
|
+
class BaseTest < Assert::Context
|
6
|
+
desc "the AD::Framework module"
|
7
|
+
setup do
|
8
|
+
State.preserve
|
9
|
+
@module = AD::Framework
|
10
|
+
end
|
11
|
+
subject{ @module }
|
12
|
+
|
13
|
+
should have_instance_methods :configure, :config, :connection, :defined_attributes
|
14
|
+
should have_instance_methods :register_attributes, :defined_attribute_types
|
15
|
+
should have_instance_methods :register_attribute_type, :defined_object_classes
|
16
|
+
should have_instance_methods :register_structural_class, :register_auxiliary_class
|
17
|
+
|
18
|
+
should "return an instance of AD::Framework::Config with #config" do
|
19
|
+
assert_instance_of AD::Framework::Config, subject.config
|
20
|
+
end
|
21
|
+
should "return the config's adapter with #connection" do
|
22
|
+
assert_equal subject.config.adapter, subject.connection
|
23
|
+
end
|
24
|
+
should "return the config's attributes with #defined_attributes" do
|
25
|
+
assert_equal subject.config.attributes, subject.defined_attributes
|
26
|
+
end
|
27
|
+
should "return the config's attribute_types with #defined_attribute_types" do
|
28
|
+
assert_equal subject.config.attribute_types, subject.defined_attribute_types
|
29
|
+
end
|
30
|
+
should "return the config's object_classes with #defined_object_classes" do
|
31
|
+
assert_equal subject.config.object_classes, subject.defined_object_classes
|
32
|
+
end
|
33
|
+
|
34
|
+
teardown do
|
35
|
+
State.restore
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class ConfigureTest < BaseTest
|
40
|
+
desc "configure method"
|
41
|
+
setup do
|
42
|
+
yielded = nil
|
43
|
+
@module.configure{|config| yielded = config }
|
44
|
+
@yielded = yielded
|
45
|
+
end
|
46
|
+
|
47
|
+
should "yield the config" do
|
48
|
+
assert_equal subject.config, @yielded
|
49
|
+
end
|
50
|
+
should "return the config with no block" do
|
51
|
+
assert_equal subject.config, subject.configure
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class RegisterAttributesTest < BaseTest
|
56
|
+
desc "register_attributes method"
|
57
|
+
setup do
|
58
|
+
@definition = { :name => "super_name", :ldap_name => "supersupername", :type => "string" }
|
59
|
+
@module.register_attributes([ @definition ])
|
60
|
+
@stored = @module.defined_attributes[:super_name]
|
61
|
+
end
|
62
|
+
subject{ @stored }
|
63
|
+
|
64
|
+
should "store attributes" do
|
65
|
+
assert_equal @definition[:name], subject.name
|
66
|
+
assert_equal @definition[:ldap_name], subject.ldap_name
|
67
|
+
assert_equal @definition[:type], subject.type
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class RegisterAttributeTypeTest < BaseTest
|
72
|
+
desc "register_attribute_type method"
|
73
|
+
setup do
|
74
|
+
@attribute_type = mock()
|
75
|
+
@attribute_type.stubs(:key).returns("super_attribute_type")
|
76
|
+
@module.register_attribute_type(@attribute_type)
|
77
|
+
@stored = @module.defined_attribute_types[@attribute_type.key]
|
78
|
+
end
|
79
|
+
subject{ @stored }
|
80
|
+
|
81
|
+
should "store an attribute type" do
|
82
|
+
assert_equal @attribute_type, subject
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class RegisterStructuralClassTest < BaseTest
|
87
|
+
desc "register_structural_class method"
|
88
|
+
setup do
|
89
|
+
@structural_class = mock()
|
90
|
+
@structural_class.stubs(:ldap_name).returns("super_structural_class")
|
91
|
+
@module.register_structural_class(@structural_class)
|
92
|
+
@stored = @module.defined_object_classes[@structural_class.ldap_name]
|
93
|
+
end
|
94
|
+
subject{ @stored }
|
95
|
+
|
96
|
+
should "store a structural class" do
|
97
|
+
assert_equal @structural_class, @stored
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class RegisterAuxiliaryClassTest < BaseTest
|
102
|
+
desc "register_auxiliary_class method"
|
103
|
+
setup do
|
104
|
+
@auxiliary_class = mock()
|
105
|
+
@auxiliary_class.stubs(:ldap_name).returns("super_auxiliary_class")
|
106
|
+
@module.register_auxiliary_class(@auxiliary_class)
|
107
|
+
@stored = @module.defined_object_classes[@auxiliary_class.ldap_name]
|
108
|
+
end
|
109
|
+
subject{ @stored }
|
110
|
+
|
111
|
+
should "store an auxiliary class" do
|
112
|
+
assert_equal @auxiliary_class, subject
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ad-framework
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Collin Redding
|
14
|
+
- Matt McPherson
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-08-29 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 1
|
33
|
+
- 1
|
34
|
+
version: 0.1.1
|
35
|
+
version_requirements: *id001
|
36
|
+
name: ad-ldap
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 19
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 3
|
49
|
+
- 0
|
50
|
+
version: 0.3.0
|
51
|
+
version_requirements: *id002
|
52
|
+
name: assert
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 1
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 1
|
65
|
+
- 9
|
66
|
+
version: 1.1.9
|
67
|
+
version_requirements: *id003
|
68
|
+
name: log4r
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 35
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 9
|
81
|
+
- 12
|
82
|
+
version: 0.9.12
|
83
|
+
version_requirements: *id004
|
84
|
+
name: mocha
|
85
|
+
description: A framework for defining an ActiveDirectory schema in ruby.
|
86
|
+
email:
|
87
|
+
executables: []
|
88
|
+
|
89
|
+
extensions: []
|
90
|
+
|
91
|
+
extra_rdoc_files: []
|
92
|
+
|
93
|
+
files:
|
94
|
+
- .gitignore
|
95
|
+
- Gemfile
|
96
|
+
- README.markdown
|
97
|
+
- Rakefile
|
98
|
+
- ad-framework.gemspec
|
99
|
+
- doc/open_ldap_server.markdown
|
100
|
+
- extras/adtest.schema
|
101
|
+
- extras/slapd.conf
|
102
|
+
- lib/ad-framework.rb
|
103
|
+
- lib/ad-framework/attribute.rb
|
104
|
+
- lib/ad-framework/attribute_type.rb
|
105
|
+
- lib/ad-framework/auxiliary_class.rb
|
106
|
+
- lib/ad-framework/config.rb
|
107
|
+
- lib/ad-framework/config/attribute_definition.rb
|
108
|
+
- lib/ad-framework/config/mapping.rb
|
109
|
+
- lib/ad-framework/exceptions.rb
|
110
|
+
- lib/ad-framework/fields.rb
|
111
|
+
- lib/ad-framework/patterns/callbacks.rb
|
112
|
+
- lib/ad-framework/patterns/has_schema.rb
|
113
|
+
- lib/ad-framework/patterns/persistence.rb
|
114
|
+
- lib/ad-framework/patterns/searchable.rb
|
115
|
+
- lib/ad-framework/patterns/validations.rb
|
116
|
+
- lib/ad-framework/schema.rb
|
117
|
+
- lib/ad-framework/structural_class.rb
|
118
|
+
- lib/ad-framework/utilities/entry_builder.rb
|
119
|
+
- lib/ad-framework/utilities/transaction.rb
|
120
|
+
- lib/ad-framework/utilities/validator.rb
|
121
|
+
- lib/ad-framework/version.rb
|
122
|
+
- test/helper.rb
|
123
|
+
- test/integration/defined_array_test.rb
|
124
|
+
- test/integration/defined_integer_test.rb
|
125
|
+
- test/integration/defined_string_test.rb
|
126
|
+
- test/integration/defined_top_test.rb
|
127
|
+
- test/integration/defined_user_test.rb
|
128
|
+
- test/irb.rb
|
129
|
+
- test/support/factory.rb
|
130
|
+
- test/support/ldap.yml
|
131
|
+
- test/support/schema/attribute_types.rb
|
132
|
+
- test/support/schema/attributes.rb
|
133
|
+
- test/support/schema/auxiliary_classes.rb
|
134
|
+
- test/support/schema/structural_classes.rb
|
135
|
+
- test/support/seed.rb
|
136
|
+
- test/support/state.rb
|
137
|
+
- test/unit/ad-framework/attribute_test.rb
|
138
|
+
- test/unit/ad-framework/attribute_type/class_methods_test.rb
|
139
|
+
- test/unit/ad-framework/attribute_type_test.rb
|
140
|
+
- test/unit/ad-framework/auxiliary_class_test.rb
|
141
|
+
- test/unit/ad-framework/config/attribute_definition_test.rb
|
142
|
+
- test/unit/ad-framework/config/mapping_test.rb
|
143
|
+
- test/unit/ad-framework/config_test.rb
|
144
|
+
- test/unit/ad-framework/fields_test.rb
|
145
|
+
- test/unit/ad-framework/patterns/callbacks_test.rb
|
146
|
+
- test/unit/ad-framework/patterns/has_schema/class_methods_test.rb
|
147
|
+
- test/unit/ad-framework/patterns/has_schema_test.rb
|
148
|
+
- test/unit/ad-framework/patterns/persistence_test.rb
|
149
|
+
- test/unit/ad-framework/patterns/searchable_test.rb
|
150
|
+
- test/unit/ad-framework/patterns/validations_test.rb
|
151
|
+
- test/unit/ad-framework/schema_test.rb
|
152
|
+
- test/unit/ad-framework/structural_class_test.rb
|
153
|
+
- test/unit/ad-framework/utilities/entry_builder_test.rb
|
154
|
+
- test/unit/ad-framework/utilities/transaction_test.rb
|
155
|
+
- test/unit/ad-framework/utilities/validator_test.rb
|
156
|
+
- test/unit/ad-framework_test.rb
|
157
|
+
homepage: http://github.com/teaminsight/ad-framework
|
158
|
+
licenses: []
|
159
|
+
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
hash: 3
|
171
|
+
segments:
|
172
|
+
- 0
|
173
|
+
version: "0"
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
none: false
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
hash: 3
|
180
|
+
segments:
|
181
|
+
- 0
|
182
|
+
version: "0"
|
183
|
+
requirements: []
|
184
|
+
|
185
|
+
rubyforge_project: ad-framework
|
186
|
+
rubygems_version: 1.8.8
|
187
|
+
signing_key:
|
188
|
+
specification_version: 3
|
189
|
+
summary: A framework for defining an ActiveDirectory schema in ruby.
|
190
|
+
test_files:
|
191
|
+
- test/helper.rb
|
192
|
+
- test/integration/defined_array_test.rb
|
193
|
+
- test/integration/defined_integer_test.rb
|
194
|
+
- test/integration/defined_string_test.rb
|
195
|
+
- test/integration/defined_top_test.rb
|
196
|
+
- test/integration/defined_user_test.rb
|
197
|
+
- test/irb.rb
|
198
|
+
- test/support/factory.rb
|
199
|
+
- test/support/ldap.yml
|
200
|
+
- test/support/schema/attribute_types.rb
|
201
|
+
- test/support/schema/attributes.rb
|
202
|
+
- test/support/schema/auxiliary_classes.rb
|
203
|
+
- test/support/schema/structural_classes.rb
|
204
|
+
- test/support/seed.rb
|
205
|
+
- test/support/state.rb
|
206
|
+
- test/unit/ad-framework/attribute_test.rb
|
207
|
+
- test/unit/ad-framework/attribute_type/class_methods_test.rb
|
208
|
+
- test/unit/ad-framework/attribute_type_test.rb
|
209
|
+
- test/unit/ad-framework/auxiliary_class_test.rb
|
210
|
+
- test/unit/ad-framework/config/attribute_definition_test.rb
|
211
|
+
- test/unit/ad-framework/config/mapping_test.rb
|
212
|
+
- test/unit/ad-framework/config_test.rb
|
213
|
+
- test/unit/ad-framework/fields_test.rb
|
214
|
+
- test/unit/ad-framework/patterns/callbacks_test.rb
|
215
|
+
- test/unit/ad-framework/patterns/has_schema/class_methods_test.rb
|
216
|
+
- test/unit/ad-framework/patterns/has_schema_test.rb
|
217
|
+
- test/unit/ad-framework/patterns/persistence_test.rb
|
218
|
+
- test/unit/ad-framework/patterns/searchable_test.rb
|
219
|
+
- test/unit/ad-framework/patterns/validations_test.rb
|
220
|
+
- test/unit/ad-framework/schema_test.rb
|
221
|
+
- test/unit/ad-framework/structural_class_test.rb
|
222
|
+
- test/unit/ad-framework/utilities/entry_builder_test.rb
|
223
|
+
- test/unit/ad-framework/utilities/transaction_test.rb
|
224
|
+
- test/unit/ad-framework/utilities/validator_test.rb
|
225
|
+
- test/unit/ad-framework_test.rb
|