zuul 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/zuul/orm_helpers.rb +21 -0
- data/lib/generators/zuul/permission_generator.rb +57 -0
- data/lib/generators/zuul/permission_role_generator.rb +40 -0
- data/lib/generators/zuul/permission_subject_generator.rb +40 -0
- data/lib/generators/zuul/role_generator.rb +58 -0
- data/lib/generators/zuul/role_subject_generator.rb +40 -0
- data/lib/generators/zuul/subject_generator.rb +39 -0
- data/lib/generators/zuul/templates/permission.rb +18 -0
- data/lib/generators/zuul/templates/permission_existing.rb +25 -0
- data/lib/generators/zuul/templates/permission_role.rb +17 -0
- data/lib/generators/zuul/templates/permission_role_existing.rb +24 -0
- data/lib/generators/zuul/templates/permission_subject.rb +17 -0
- data/lib/generators/zuul/templates/permission_subject_existing.rb +24 -0
- data/lib/generators/zuul/templates/role.rb +20 -0
- data/lib/generators/zuul/templates/role_existing.rb +27 -0
- data/lib/generators/zuul/templates/role_subject.rb +17 -0
- data/lib/generators/zuul/templates/role_subject_existing.rb +24 -0
- data/lib/tasks/zuul.rake +56 -0
- data/lib/zuul.rb +14 -5
- data/lib/zuul/action_controller.rb +108 -0
- data/lib/zuul/action_controller/dsl.rb +384 -0
- data/lib/zuul/action_controller/evaluators.rb +60 -0
- data/lib/zuul/active_record.rb +338 -0
- data/lib/zuul/active_record/context.rb +38 -0
- data/lib/zuul/active_record/permission.rb +31 -0
- data/lib/zuul/active_record/permission_role.rb +29 -0
- data/lib/zuul/active_record/permission_subject.rb +29 -0
- data/lib/zuul/active_record/role.rb +117 -0
- data/lib/zuul/active_record/role_subject.rb +29 -0
- data/lib/zuul/active_record/scope.rb +71 -0
- data/lib/zuul/active_record/subject.rb +239 -0
- data/lib/zuul/configuration.rb +149 -0
- data/lib/zuul/context.rb +53 -0
- data/lib/zuul/exceptions.rb +3 -0
- data/lib/zuul/exceptions/access_denied.rb +9 -0
- data/lib/zuul/exceptions/invalid_context.rb +9 -0
- data/lib/zuul/exceptions/undefined_scope.rb +9 -0
- data/lib/zuul/railtie.rb +5 -0
- data/lib/zuul/version.rb +3 -0
- data/lib/zuul_viz.rb +195 -0
- data/spec/db/schema.rb +172 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/capture_stdout.rb +12 -0
- data/spec/support/models.rb +167 -0
- data/spec/zuul/active_record/context_spec.rb +55 -0
- data/spec/zuul/active_record/permission_role_spec.rb +84 -0
- data/spec/zuul/active_record/permission_spec.rb +174 -0
- data/spec/zuul/active_record/permission_subject_spec.rb +84 -0
- data/spec/zuul/active_record/role_spec.rb +694 -0
- data/spec/zuul/active_record/role_subject_spec.rb +84 -0
- data/spec/zuul/active_record/scope_spec.rb +75 -0
- data/spec/zuul/active_record/subject_spec.rb +1186 -0
- data/spec/zuul/active_record_spec.rb +624 -0
- data/spec/zuul/configuration_spec.rb +254 -0
- data/spec/zuul/context_spec.rb +128 -0
- data/spec/zuul_spec.rb +15 -0
- metadata +181 -70
- data/.document +0 -5
- data/.gitignore +0 -23
- data/LICENSE +0 -20
- data/README.rdoc +0 -65
- data/Rakefile +0 -54
- data/VERSION +0 -1
- data/lib/zuul/restrict_access.rb +0 -104
- data/lib/zuul/valid_roles.rb +0 -37
- data/spec/rails_root/app/controllers/application_controller.rb +0 -2
- data/spec/rails_root/app/models/user.rb +0 -8
- data/spec/rails_root/config/boot.rb +0 -110
- data/spec/rails_root/config/database.yml +0 -5
- data/spec/rails_root/config/environment.rb +0 -7
- data/spec/rails_root/config/environments/test.rb +0 -7
- data/spec/rails_root/config/initializers/session_store.rb +0 -15
- data/spec/rails_root/config/routes.rb +0 -4
- data/spec/rails_root/db/test.sqlite3 +0 -0
- data/spec/rails_root/log/test.log +0 -5388
- data/spec/rails_root/spec/controllers/require_user_spec.rb +0 -138
- data/spec/rails_root/spec/controllers/restrict_access_spec.rb +0 -64
- data/spec/rails_root/spec/models/user_spec.rb +0 -37
- data/spec/rails_root/spec/spec_helper.rb +0 -34
- data/zuul.gemspec +0 -78
@@ -0,0 +1,254 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Zuul::Configuration" do
|
4
|
+
before(:each) do
|
5
|
+
@config = Zuul::Configuration.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should provide constants defining default attributes and values" do
|
9
|
+
expect { Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES }.to_not raise_exception
|
10
|
+
expect { Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES }.to_not raise_exception
|
11
|
+
expect { Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES }.to_not raise_exception
|
12
|
+
expect { Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS }.to_not raise_exception
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should ensure all defined defaults are accessible attributes" do
|
16
|
+
[Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES, Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS].each do |opts|
|
17
|
+
opts.each do |key,val|
|
18
|
+
@config.should respond_to(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should initialize with defaults from the defined constants" do
|
24
|
+
[Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES, Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS].each do |opts|
|
25
|
+
opts.each do |key,val|
|
26
|
+
@config.send(key).should == val
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "PRIMARY_AUTHORIZATION_CLASSES" do
|
32
|
+
it "should define the :subject_class option" do
|
33
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES.has_key?(:subject_class).should be_true
|
34
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES[:subject_class].should == :user
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should define the :role_class option" do
|
38
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES.has_key?(:role_class).should be_true
|
39
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES[:role_class].should == :role
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should define the :permission_class option" do
|
43
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES.has_key?(:permission_class).should be_true
|
44
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES[:permission_class].should == :permission
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "AUTHORIZATION_JOIN_CLASSES" do
|
49
|
+
it "should define the :role_subject_class option" do
|
50
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES.has_key?(:role_subject_class).should be_true
|
51
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES[:role_subject_class].should == :role_user
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should define the :permission_role_class option" do
|
55
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES.has_key?(:permission_role_class).should be_true
|
56
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES[:permission_role_class].should == :permission_role
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should define the :permission_subject_class option" do
|
60
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES.has_key?(:permission_subject_class).should be_true
|
61
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES[:permission_subject_class].should == :permission_user
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "DEFAULT_AUTHORIZATION_CLASSES" do
|
66
|
+
it "should combine the PRIMARY_AUTHORIZATION_CLASSES and AUTHORIZATION_JOIN_CLASSES" do
|
67
|
+
[Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES, Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES].each do |classes|
|
68
|
+
classes.each do |key,val|
|
69
|
+
Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES.has_key?(key).should be_true
|
70
|
+
Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES[key].should == val
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "DEFAULT_CONFIGURATION_OPTIONS" do
|
77
|
+
it "should define the :acl_default option" do
|
78
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS.has_key?(:acl_default).should be_true
|
79
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS[:acl_default].should == :deny
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should define the :subject_method option" do
|
83
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS.has_key?(:subject_method).should be_true
|
84
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS[:subject_method].should == :current_user
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should define the :with_permissions option" do
|
88
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS.has_key?(:with_permissions).should be_true
|
89
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS[:with_permissions].should == true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should define the :force_context option" do
|
93
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS.has_key?(:force_context).should be_true
|
94
|
+
Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS[:force_context].should == false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#configure" do
|
99
|
+
context "with a hash" do
|
100
|
+
it "should use the hash keys/vals to set instance variables" do
|
101
|
+
@config.configure(:subject_class => :custom_subject, :acl_default => :allow)
|
102
|
+
@config.subject_class.should == :custom_subject
|
103
|
+
@config.acl_default.should == :allow
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should not allow setting instance variables that are not defined as defaults" do
|
107
|
+
@config.configure(:bad_key => :bad_value)
|
108
|
+
@config.should_not respond_to(:bad_key)
|
109
|
+
@config.instance_eval do
|
110
|
+
@bad_key.should == nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "with a block" do
|
116
|
+
it "should allow setting config vars via the passed config object" do
|
117
|
+
@config.configure do |config|
|
118
|
+
config.subject_method = :config_current_user
|
119
|
+
end
|
120
|
+
@config.subject_method.should == :config_current_user
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should allow setting config vars via instance variables" do
|
124
|
+
@config.configure do
|
125
|
+
@subject_method = :ivar_current_user
|
126
|
+
end
|
127
|
+
@config.subject_method.should == :ivar_current_user
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should allow setting config vars via self" do
|
131
|
+
@config.configure do
|
132
|
+
self.subject_method = :self_current_user
|
133
|
+
end
|
134
|
+
@config.subject_method.should == :self_current_user
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with a hash and a block" do
|
139
|
+
it "should use both the hash and block for configuration" do
|
140
|
+
@config.configure(:subject_class => :custom_subject) do |config|
|
141
|
+
config.role_class = :custom_role
|
142
|
+
end
|
143
|
+
@config.subject_class.should == :custom_subject
|
144
|
+
@config.role_class.should == :custom_role
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should override hash values with values set in the block" do
|
148
|
+
@config.configure(:role_class => :hash_role) do |config|
|
149
|
+
config.role_class = :block_role
|
150
|
+
end
|
151
|
+
@config.role_class.should == :block_role
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should redefine the join classes when custom classes are provided" do
|
156
|
+
@config.configure(:subject_class => :soldier, :role_class => :rank, :permission_class => :skill)
|
157
|
+
@config.role_subject_class.should == "RankSoldier"
|
158
|
+
@config.permission_subject_class.should == "SkillSoldier"
|
159
|
+
@config.permission_role_class.should == "RankSkill"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should not override join classes if they were provided" do
|
163
|
+
@config.configure(:role_subject_class => :special_role_user, :role_class => :rank)
|
164
|
+
@config.role_subject_class.should == :special_role_user
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "#to_hash" do
|
169
|
+
it "should return a hash with all the configuration keys" do
|
170
|
+
[Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES, Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS].each do |opts|
|
171
|
+
opts.keys.each do |key|
|
172
|
+
@config.to_hash.has_key?(key).should be_true
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should populate values with the current configuration values" do
|
178
|
+
[Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES, Zuul::Configuration::DEFAULT_CONFIGURATION_OPTIONS].each do |opts|
|
179
|
+
opts.keys.each do |key|
|
180
|
+
@config.to_hash[key].should == @config.send(key)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "#classes" do
|
187
|
+
it "should return a ClassStruct" do
|
188
|
+
@config.classes.class.ancestors.should include(Zuul::Configuration::ClassStruct)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should return a ClassStruct of all the default configuration classes" do
|
192
|
+
Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES.keys.each do |key|
|
193
|
+
@config.classes.should respond_to(key)
|
194
|
+
end
|
195
|
+
@config.classes.keys.each do |key|
|
196
|
+
Zuul::Configuration::DEFAULT_AUTHORIZATION_CLASSES.has_key?(key).should be_true
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "#primary_classes" do
|
202
|
+
it "should return a ClassStruct" do
|
203
|
+
@config.classes.class.ancestors.should include(Zuul::Configuration::ClassStruct)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should return a ClassStruct of all the default configuration classes" do
|
207
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES.keys.each do |key|
|
208
|
+
@config.primary_classes.should respond_to(key)
|
209
|
+
end
|
210
|
+
@config.primary_classes.keys.each do |key|
|
211
|
+
Zuul::Configuration::PRIMARY_AUTHORIZATION_CLASSES.has_key?(key).should be_true
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe "#join_classes" do
|
217
|
+
it "should return a ClassStruct" do
|
218
|
+
@config.join_classes.class.ancestors.should include(Zuul::Configuration::ClassStruct)
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should return a ClassStruct of all the default configuration join classes" do
|
222
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES.keys.each do |key|
|
223
|
+
@config.join_classes.should respond_to(key)
|
224
|
+
end
|
225
|
+
@config.join_classes.keys.each do |key|
|
226
|
+
Zuul::Configuration::AUTHORIZATION_JOIN_CLASSES.has_key?(key).should be_true
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "Zuul::Configuration::ClassStruct" do
|
232
|
+
it "should inherit from Struct" do
|
233
|
+
Zuul::Configuration::ClassStruct.ancestors.should include(Struct)
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "#keys" do
|
237
|
+
it "should return an array of keys" do
|
238
|
+
Zuul::Configuration::ClassStruct.new(:key1, :key2, :key3).new.keys.should == [:key1, :key2, :key3]
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "#to_array" do
|
243
|
+
it "should return an array of values" do
|
244
|
+
Zuul::Configuration::ClassStruct.new(:key1, :key2, :key3).new(:val1, :val2, :val3).to_array.should == [:val1, :val2, :val3]
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "#to_hash" do
|
249
|
+
it "should return a hash of key/value pairs" do
|
250
|
+
Zuul::Configuration::ClassStruct.new(:key1, :key2, :key3).new(:val1, :val2, :val3).to_hash.should == {:key1 => :val1, :key2 => :val2, :key3 => :val3}
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Zuul::Context" do
|
4
|
+
|
5
|
+
describe "parse" do
|
6
|
+
it "should allow passing nil" do
|
7
|
+
expect { Zuul::Context.parse(nil) }.to_not raise_exception
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should allow passing a class" do
|
11
|
+
expect { Zuul::Context.parse(Context) }.to_not raise_exception
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should allow passing an instance" do
|
15
|
+
context = Context.create(:name => "Test Context")
|
16
|
+
expect { Zuul::Context.parse(context) }.to_not raise_exception
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should allow passing another context" do
|
20
|
+
expect { Zuul::Context.parse(Zuul::Context.new) }.to_not raise_exception
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should allow passing a class_name and id" do
|
24
|
+
expect { Zuul::Context.parse('Context', 1) }.to_not raise_exception
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return an Zuul::Context object with the context broken into it's two parts" do
|
28
|
+
parsed = Zuul::Context.parse(nil)
|
29
|
+
parsed.should be_an_instance_of(Zuul::Context)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return a nil context context for nil" do
|
33
|
+
parsed = Zuul::Context.parse(nil)
|
34
|
+
parsed.class_name.should be_nil
|
35
|
+
parsed.id.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return a context with class_name set to the class name for class context" do
|
39
|
+
parsed = Zuul::Context.parse(Context)
|
40
|
+
parsed.class_name.should == 'Context'
|
41
|
+
parsed.id.should be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a context with class_name and id set for an instance context" do
|
45
|
+
context = Context.create(:name => "Test Context")
|
46
|
+
parsed = Zuul::Context.parse(context)
|
47
|
+
parsed.class_name.should == 'Context'
|
48
|
+
parsed.id.should == context.id
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#to_context" do
|
53
|
+
it "should return nil for a nil context" do
|
54
|
+
Zuul::Context.new.to_context.should be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return the class for a class context" do
|
58
|
+
Zuul::Context.new('Context', nil).to_context.should == Context
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return the instance for an instance context" do
|
62
|
+
obj = Context.create(:name => "Test Context")
|
63
|
+
context = Zuul::Context.new('Context', obj.id).to_context
|
64
|
+
context.should be_an_instance_of(Context)
|
65
|
+
context.id.should == obj.id
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#instance?" do
|
70
|
+
it "should return false for a nil context" do
|
71
|
+
Zuul::Context.new.instance?.should be_false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return false for a class context" do
|
75
|
+
Zuul::Context.new('Context', nil).instance?.should be_false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return true for an instance context" do
|
79
|
+
obj = Context.create(:name => "Test Context")
|
80
|
+
Zuul::Context.new('Context', obj.id).instance?.should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#class?" do
|
85
|
+
it "should return false for a nil context" do
|
86
|
+
Zuul::Context.new.class?.should be_false
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return true for a class context" do
|
90
|
+
Zuul::Context.new('Context', nil).class?.should be_true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return false for an instance context" do
|
94
|
+
obj = Context.create(:name => "Test Context")
|
95
|
+
Zuul::Context.new('Context', obj.id).class?.should be_false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#nil?" do
|
100
|
+
it "should return true for a nil context" do
|
101
|
+
Zuul::Context.new.nil?.should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return false for a class context" do
|
105
|
+
Zuul::Context.new('Context', nil).nil?.should be_false
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return false for an instance context" do
|
109
|
+
obj = Context.create(:name => "Test Context")
|
110
|
+
Zuul::Context.new('Context', obj.id).nil?.should be_false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#type" do
|
115
|
+
it "should return :nil for a nil context" do
|
116
|
+
Zuul::Context.new.type.should == :nil
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should return :class for a class context" do
|
120
|
+
Zuul::Context.new('Context', nil).type.should == :class
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return :instance for an instance context" do
|
124
|
+
obj = Context.create(:name => "Test Context")
|
125
|
+
Zuul::Context.new('Context', obj.id).type.should == :instance
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
data/spec/zuul_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Zuul" do
|
4
|
+
it "should possess a readable configuration object" do
|
5
|
+
Zuul.configuration.should be_an_instance_of(Zuul::Configuration)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should forward calls to configure on to the configuration object" do
|
9
|
+
Zuul.should respond_to(:configure)
|
10
|
+
Zuul.configure do |config|
|
11
|
+
config.should == Zuul.configuration
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
metadata
CHANGED
@@ -1,87 +1,198 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuul
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
7
|
+
authors:
|
8
|
+
- Mark Rebec
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activerecord
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: actionpack
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sqlite3
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
16
79
|
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
17
86
|
type: :development
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
description:
|
26
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Flexible, configurable authorization system for ActiveRecord and an access
|
95
|
+
control DSL for ActionController.
|
96
|
+
email:
|
97
|
+
- mark@markrebec.com
|
27
98
|
executables: []
|
28
|
-
|
29
99
|
extensions: []
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
|
35
|
-
- .
|
36
|
-
- .
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- lib/tasks/zuul.rake
|
103
|
+
- lib/zuul_viz.rb
|
104
|
+
- lib/zuul/action_controller/evaluators.rb
|
105
|
+
- lib/zuul/action_controller/dsl.rb
|
106
|
+
- lib/zuul/active_record/scope.rb
|
107
|
+
- lib/zuul/active_record/role.rb
|
108
|
+
- lib/zuul/active_record/permission_role.rb
|
109
|
+
- lib/zuul/active_record/context.rb
|
110
|
+
- lib/zuul/active_record/permission.rb
|
111
|
+
- lib/zuul/active_record/subject.rb
|
112
|
+
- lib/zuul/active_record/role_subject.rb
|
113
|
+
- lib/zuul/active_record/permission_subject.rb
|
114
|
+
- lib/zuul/active_record.rb
|
115
|
+
- lib/zuul/railtie.rb
|
116
|
+
- lib/zuul/action_controller.rb
|
117
|
+
- lib/zuul/configuration.rb
|
118
|
+
- lib/zuul/version.rb
|
119
|
+
- lib/zuul/context.rb
|
120
|
+
- lib/zuul/exceptions.rb
|
121
|
+
- lib/zuul/exceptions/undefined_scope.rb
|
122
|
+
- lib/zuul/exceptions/access_denied.rb
|
123
|
+
- lib/zuul/exceptions/invalid_context.rb
|
124
|
+
- lib/generators/zuul/permission_subject_generator.rb
|
125
|
+
- lib/generators/zuul/role_subject_generator.rb
|
126
|
+
- lib/generators/zuul/subject_generator.rb
|
127
|
+
- lib/generators/zuul/role_generator.rb
|
128
|
+
- lib/generators/zuul/permission_generator.rb
|
129
|
+
- lib/generators/zuul/templates/role_subject_existing.rb
|
130
|
+
- lib/generators/zuul/templates/role.rb
|
131
|
+
- lib/generators/zuul/templates/permission_role.rb
|
132
|
+
- lib/generators/zuul/templates/permission_subject_existing.rb
|
133
|
+
- lib/generators/zuul/templates/permission_existing.rb
|
134
|
+
- lib/generators/zuul/templates/permission.rb
|
135
|
+
- lib/generators/zuul/templates/role_subject.rb
|
136
|
+
- lib/generators/zuul/templates/role_existing.rb
|
137
|
+
- lib/generators/zuul/templates/permission_role_existing.rb
|
138
|
+
- lib/generators/zuul/templates/permission_subject.rb
|
139
|
+
- lib/generators/zuul/orm_helpers.rb
|
140
|
+
- lib/generators/zuul/permission_role_generator.rb
|
41
141
|
- lib/zuul.rb
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
|
46
|
-
|
142
|
+
- spec/db/schema.rb
|
143
|
+
- spec/zuul_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- spec/support/models.rb
|
146
|
+
- spec/support/capture_stdout.rb
|
147
|
+
- spec/zuul/configuration_spec.rb
|
148
|
+
- spec/zuul/active_record/role_spec.rb
|
149
|
+
- spec/zuul/active_record/subject_spec.rb
|
150
|
+
- spec/zuul/active_record/scope_spec.rb
|
151
|
+
- spec/zuul/active_record/permission_spec.rb
|
152
|
+
- spec/zuul/active_record/context_spec.rb
|
153
|
+
- spec/zuul/active_record/role_subject_spec.rb
|
154
|
+
- spec/zuul/active_record/permission_role_spec.rb
|
155
|
+
- spec/zuul/active_record/permission_subject_spec.rb
|
156
|
+
- spec/zuul/context_spec.rb
|
157
|
+
- spec/zuul/active_record_spec.rb
|
158
|
+
homepage: http://github.com/markrebec/zuul
|
47
159
|
licenses: []
|
48
|
-
|
49
160
|
post_install_message:
|
50
|
-
rdoc_options:
|
51
|
-
|
52
|
-
require_paths:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
53
163
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
66
176
|
requirements: []
|
67
|
-
|
68
177
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
178
|
+
rubygems_version: 1.8.24
|
70
179
|
signing_key:
|
71
180
|
specification_version: 3
|
72
|
-
summary:
|
73
|
-
test_files:
|
74
|
-
- spec/
|
75
|
-
- spec/
|
76
|
-
- spec/
|
77
|
-
- spec/
|
78
|
-
- spec/
|
79
|
-
- spec/
|
80
|
-
- spec/
|
81
|
-
- spec/
|
82
|
-
- spec/
|
83
|
-
- spec/
|
84
|
-
- spec/
|
85
|
-
- spec/
|
86
|
-
- spec/
|
87
|
-
- spec/
|
181
|
+
summary: Authorizaion and ACL for Activerecord and ActionController.
|
182
|
+
test_files:
|
183
|
+
- spec/db/schema.rb
|
184
|
+
- spec/zuul_spec.rb
|
185
|
+
- spec/spec_helper.rb
|
186
|
+
- spec/support/models.rb
|
187
|
+
- spec/support/capture_stdout.rb
|
188
|
+
- spec/zuul/configuration_spec.rb
|
189
|
+
- spec/zuul/active_record/role_spec.rb
|
190
|
+
- spec/zuul/active_record/subject_spec.rb
|
191
|
+
- spec/zuul/active_record/scope_spec.rb
|
192
|
+
- spec/zuul/active_record/permission_spec.rb
|
193
|
+
- spec/zuul/active_record/context_spec.rb
|
194
|
+
- spec/zuul/active_record/role_subject_spec.rb
|
195
|
+
- spec/zuul/active_record/permission_role_spec.rb
|
196
|
+
- spec/zuul/active_record/permission_subject_spec.rb
|
197
|
+
- spec/zuul/context_spec.rb
|
198
|
+
- spec/zuul/active_record_spec.rb
|