ae_declarative_authorization 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +3 -0
- data/Gemfile.lock +44 -44
- data/gemfiles/rails507.gemfile +1 -1
- data/gemfiles/rails507.gemfile.lock +2 -2
- data/gemfiles/rails516.gemfile +1 -1
- data/gemfiles/rails521.gemfile +1 -1
- data/gemfiles/rails521.gemfile.lock +29 -1
- data/lib/declarative_authorization/authorization.rb +5 -6
- data/lib/declarative_authorization/version.rb +1 -1
- data/log/test.log +4952 -0
- data/pkg/ae_declarative_authorization-0.9.0.gem +0 -0
- data/test/authorization_test.rb +76 -8
- data/test/model_test.rb +1 -1
- data/test/profiles/access_checking +2 -0
- metadata +2 -2
Binary file
|
data/test/authorization_test.rb
CHANGED
@@ -387,11 +387,11 @@ class AuthorizationTest < Test::Unit::TestCase
|
|
387
387
|
end
|
388
388
|
}
|
389
389
|
engine = Authorization::Engine.new(reader)
|
390
|
-
assert engine.permit?(:
|
391
|
-
|
390
|
+
assert engine.permit?(:test, context: :permissions, user: MockUser.new(:test_role))
|
391
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
392
392
|
end
|
393
393
|
|
394
|
-
def
|
394
|
+
def test_role_hierarchy__recursive
|
395
395
|
reader = Authorization::Reader::DSLReader.new
|
396
396
|
reader.parse %{
|
397
397
|
authorization do
|
@@ -400,14 +400,61 @@ class AuthorizationTest < Test::Unit::TestCase
|
|
400
400
|
has_permission_on :permissions, :to => :test
|
401
401
|
end
|
402
402
|
role :lower_role do
|
403
|
-
includes :higher_role
|
404
403
|
has_permission_on :permissions, :to => :lower
|
404
|
+
includes :lowest_role
|
405
|
+
end
|
406
|
+
role :lowest_role do
|
407
|
+
has_permission_on :permissions, :to => :lowest
|
405
408
|
end
|
406
409
|
end
|
407
410
|
}
|
408
411
|
engine = Authorization::Engine.new(reader)
|
409
|
-
assert engine.permit?(:
|
410
|
-
|
412
|
+
assert engine.permit?(:test, context: :permissions, user: MockUser.new(:test_role))
|
413
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
414
|
+
assert engine.permit?(:lowest, context: :permissions, user: MockUser.new(:test_role))
|
415
|
+
end
|
416
|
+
|
417
|
+
def test_role_hierarchy__circular
|
418
|
+
reader = Authorization::Reader::DSLReader.new
|
419
|
+
reader.parse %{
|
420
|
+
authorization do
|
421
|
+
role :test_role do
|
422
|
+
includes :lower_role
|
423
|
+
has_permission_on :permissions, :to => :test
|
424
|
+
end
|
425
|
+
role :lower_role do
|
426
|
+
includes :test_role
|
427
|
+
has_permission_on :permissions, :to => :lower
|
428
|
+
end
|
429
|
+
end
|
430
|
+
}
|
431
|
+
engine = Authorization::Engine.new(reader)
|
432
|
+
assert engine.permit?(:test, context: :permissions, user: MockUser.new(:test_role))
|
433
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
434
|
+
end
|
435
|
+
|
436
|
+
def test_role_hierarchy__recursive__circular
|
437
|
+
reader = Authorization::Reader::DSLReader.new
|
438
|
+
reader.parse %{
|
439
|
+
authorization do
|
440
|
+
role :test_role do
|
441
|
+
includes :lower_role
|
442
|
+
has_permission_on :permissions, :to => :test
|
443
|
+
end
|
444
|
+
role :lower_role do
|
445
|
+
includes :lowest_role
|
446
|
+
has_permission_on :permissions, :to => :lower
|
447
|
+
end
|
448
|
+
role :lowest_role do
|
449
|
+
includes :test_role
|
450
|
+
has_permission_on :permissions, :to => :lowest
|
451
|
+
end
|
452
|
+
end
|
453
|
+
}
|
454
|
+
engine = Authorization::Engine.new(reader)
|
455
|
+
assert engine.permit?(:test, context: :permissions, user: MockUser.new(:test_role))
|
456
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
457
|
+
assert engine.permit?(:lowest, context: :permissions, user: MockUser.new(:test_role))
|
411
458
|
end
|
412
459
|
|
413
460
|
def test_privilege_hierarchy
|
@@ -425,8 +472,29 @@ class AuthorizationTest < Test::Unit::TestCase
|
|
425
472
|
end
|
426
473
|
}
|
427
474
|
engine = Authorization::Engine.new(reader)
|
428
|
-
assert engine.permit?(:lower, :
|
429
|
-
|
475
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
476
|
+
end
|
477
|
+
|
478
|
+
def test_privilege_hierarchy__recursive
|
479
|
+
reader = Authorization::Reader::DSLReader.new
|
480
|
+
reader.parse %{
|
481
|
+
privileges do
|
482
|
+
privilege :test, :permissions do
|
483
|
+
includes :lower
|
484
|
+
end
|
485
|
+
privilege :lower, :permissions do
|
486
|
+
includes :lowest
|
487
|
+
end
|
488
|
+
end
|
489
|
+
authorization do
|
490
|
+
role :test_role do
|
491
|
+
has_permission_on :permissions, :to => :test
|
492
|
+
end
|
493
|
+
end
|
494
|
+
}
|
495
|
+
engine = Authorization::Engine.new(reader)
|
496
|
+
assert engine.permit?(:lower, context: :permissions, user: MockUser.new(:test_role))
|
497
|
+
assert engine.permit?(:lowest, context: :permissions, user: MockUser.new(:test_role))
|
430
498
|
end
|
431
499
|
|
432
500
|
def test_privilege_hierarchy_without_context
|
data/test/model_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require File.join(File.dirname(__FILE__), %w{.. lib declarative_authorization in_model})
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w{.. lib declarative_authorization in_model}))
|
3
3
|
|
4
4
|
ActiveRecord::Base.send :include, Authorization::AuthorizationInModel
|
5
5
|
#ActiveRecord::Base.logger = Logger.new(STDOUT)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_declarative_authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AppFolio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blockenspiel
|