acl9 2.1.0 → 3.2.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.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +27 -11
- data/Appraisals +13 -6
- data/Gemfile +0 -2
- data/Gemfile.lock +125 -112
- data/README.md +11 -4
- data/Rakefile +0 -2
- data/acl9.gemspec +1 -3
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5.0.gemfile +10 -0
- data/gemfiles/rails_5.1.gemfile +10 -0
- data/gemfiles/{rails_4.0.gemfile → rails_5.2.gemfile} +2 -4
- data/gemfiles/{rails_4.1.gemfile → rails_6.0.gemfile} +2 -4
- data/gemfiles/{rails_4.2.gemfile → rails_6.1.gemfile} +2 -4
- data/lib/acl9.rb +40 -0
- data/lib/acl9/controller_extensions.rb +1 -1
- data/lib/acl9/controller_extensions/dsl_base.rb +8 -7
- data/lib/acl9/controller_extensions/generators.rb +4 -35
- data/lib/acl9/model_extensions.rb +3 -3
- data/lib/acl9/model_extensions/for_subject.rb +52 -31
- data/lib/acl9/version.rb +1 -1
- data/lib/generators/acl9/setup/setup_generator.rb +10 -3
- data/lib/generators/acl9/setup/templates/create_role_tables.rb +10 -1
- data/lib/generators/acl9/setup/templates/role.rb +1 -1
- data/test/controller_extensions/actions_test.rb +1 -1
- data/test/controller_extensions/multiple_role_arguments_test.rb +11 -10
- data/test/controllers/acl_action_override_test.rb +4 -4
- data/test/controllers/acl_helper_method_test.rb +6 -3
- data/test/controllers/acl_ivars_test.rb +2 -2
- data/test/controllers/acl_object_hash_test.rb +1 -1
- data/test/controllers/acl_query_mixin.rb +5 -2
- data/test/controllers/acl_subject_method_test.rb +1 -1
- data/test/controllers/arguments_checking_test.rb +4 -4
- data/test/dummy/app/assets/config/manifest.js +0 -0
- data/test/dummy/app/controllers/acl_action_override.rb +5 -5
- data/test/dummy/app/controllers/acl_boolean_method.rb +6 -6
- data/test/dummy/app/controllers/acl_ivars.rb +3 -3
- data/test/dummy/app/controllers/acl_query_method_named.rb +2 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/empty_controller.rb +1 -1
- data/test/dummy/app/models/string_object_role.rb +3 -0
- data/test/dummy/app/models/string_user.rb +3 -0
- data/test/dummy/app/models/uuid.rb +1 -1
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/config/routes.rb +12 -1
- data/test/dummy/db/migrate/20141117132218_create_tables.rb +68 -18
- data/test/models/roles_test.rb +13 -1
- data/test/test_helper.rb +31 -28
- metadata +26 -29
- data/test/dummy/config/environments/production.rb +0 -78
data/test/models/roles_test.rb
CHANGED
@@ -13,6 +13,14 @@ class RolesTest < ActiveSupport::TestCase
|
|
13
13
|
Acl9.config[:protect_global_roles] = true
|
14
14
|
end
|
15
15
|
|
16
|
+
test "should not set global role with nil object" do
|
17
|
+
|
18
|
+
assert_raise Acl9::NilObjectError do
|
19
|
+
assert @user.has_role! :admin, nil
|
20
|
+
end
|
21
|
+
refute @user.has_role? :admin
|
22
|
+
end
|
23
|
+
|
16
24
|
test "should not have any roles by default" do
|
17
25
|
%w(user manager admin owner).each do |role|
|
18
26
|
refute @user.has_role? role
|
@@ -243,12 +251,16 @@ class RolesTest < ActiveSupport::TestCase
|
|
243
251
|
end
|
244
252
|
|
245
253
|
test "should be able to get users that have a role on a authorized object with text primary key" do
|
254
|
+
|
255
|
+
assert @user = StringUser.create
|
256
|
+
assert @user2 = StringUser.create
|
257
|
+
|
246
258
|
assert uuid = Uuid.create( id: "C41642EE-2780-0001-189F-17F3101B26E0" )
|
247
259
|
|
248
260
|
assert @user.has_role! :owner, uuid
|
249
261
|
assert @user2.has_role! :owner, uuid
|
250
262
|
|
251
|
-
assert_equal 2, uuid.
|
263
|
+
assert_equal 2, uuid.string_users.count
|
252
264
|
end
|
253
265
|
|
254
266
|
test "should accept :symbols as role names" do
|
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
|
-
require "codeclimate-test-reporter"
|
2
|
-
CodeClimate::TestReporter.start
|
3
|
-
|
4
1
|
ENV["RAILS_ENV"] = "test"
|
5
2
|
|
6
3
|
require 'minitest/autorun'
|
7
|
-
require 'minitap'
|
8
|
-
|
9
|
-
if defined? Minitap
|
10
|
-
Minitest.reporter = Minitap::TapY
|
11
|
-
else
|
12
|
-
MiniTest::Unit.runner = MiniTest::TapY.new
|
13
|
-
end
|
14
4
|
|
15
5
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
16
6
|
require "rails/test_help"
|
@@ -18,29 +8,42 @@ require "rails/test_help"
|
|
18
8
|
Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
|
19
9
|
|
20
10
|
ActiveRecord::Migration.verbose = false
|
21
|
-
|
11
|
+
|
12
|
+
if Rails.gem_version >= Gem::Version.new('6.0')
|
13
|
+
ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate', __FILE__), ActiveRecord::SchemaMigration).migrate
|
14
|
+
elsif Rails.gem_version >= Gem::Version.new('5.2.0')
|
15
|
+
ActiveRecord::MigrationContext.new(File.expand_path('../dummy/db/migrate', __FILE__)).migrate
|
16
|
+
else
|
17
|
+
ActiveRecord::Migrator.migrate(File.expand_path('../dummy/db/migrate', __FILE__))
|
18
|
+
end
|
19
|
+
|
20
|
+
$VERBOSE = nil
|
22
21
|
|
23
22
|
class ActionController::TestCase
|
23
|
+
setup do
|
24
|
+
assert Foo.create
|
25
|
+
end
|
26
|
+
|
24
27
|
class << self
|
25
|
-
def test_allowed method, action, params=
|
26
|
-
test "allowed #{
|
28
|
+
def test_allowed method, action, params={}
|
29
|
+
test "allowed #{method} #{action}" do
|
27
30
|
if block_given?
|
28
31
|
yield user = User.create
|
29
|
-
|
32
|
+
params.merge! user_id: user.id
|
30
33
|
end
|
31
|
-
assert send( method, action, params
|
34
|
+
assert send( method, action, params: params )
|
32
35
|
assert_response :ok
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
36
|
-
def test_denied method, action, params=
|
37
|
-
test "denied #{
|
39
|
+
def test_denied method, action, params={}
|
40
|
+
test "denied #{method} #{action}" do
|
38
41
|
assert_raises Acl9::AccessDenied do
|
39
42
|
if block_given?
|
40
43
|
yield user = User.create
|
41
|
-
|
44
|
+
params.merge! user_id: user.id
|
42
45
|
end
|
43
|
-
assert send( method, action, params
|
46
|
+
assert send( method, action, params: params )
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
@@ -57,21 +60,21 @@ module BaseTests
|
|
57
60
|
def self.included(klass)
|
58
61
|
klass.class_eval do
|
59
62
|
test_allowed :get, :index
|
60
|
-
test_allowed :get, :show, :
|
63
|
+
test_allowed :get, :show, id: 1
|
61
64
|
test_denied :get, :new
|
62
|
-
test_denied :get, :edit, :
|
65
|
+
test_denied :get, :edit, id: 1
|
63
66
|
test_denied :post, :create
|
64
|
-
test_denied :put, :update, :
|
65
|
-
test_denied :patch, :update, :
|
66
|
-
test_denied :delete, :destroy, :
|
67
|
+
test_denied :put, :update, id: 1
|
68
|
+
test_denied :patch, :update, id: 1
|
69
|
+
test_denied :delete, :destroy, id: 1
|
67
70
|
|
68
71
|
admin = -> (user) { user.has_role! :admin }
|
69
72
|
test_allowed :get, :new, &admin
|
70
|
-
test_allowed :get, :edit, :
|
73
|
+
test_allowed :get, :edit, id: 1, &admin
|
71
74
|
test_allowed :post, :create, &admin
|
72
|
-
test_allowed :put, :update, :
|
73
|
-
test_allowed :patch, :update, :
|
74
|
-
test_allowed :delete, :destroy, :
|
75
|
+
test_allowed :put, :update, id: 1, &admin
|
76
|
+
test_allowed :patch, :update, id: 1, &admin
|
77
|
+
test_allowed :delete, :destroy, id: 1, &admin
|
75
78
|
end
|
76
79
|
end
|
77
80
|
end
|
metadata
CHANGED
@@ -1,44 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acl9
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oleg dashevskii
|
8
8
|
- Jason King
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '5.0'
|
21
|
+
- - "<"
|
19
22
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
23
|
+
version: '7.0'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '4.0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: codeclimate-test-reporter
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
27
|
requirements:
|
32
28
|
- - ">="
|
33
29
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
30
|
+
version: '5.0'
|
31
|
+
- - "<"
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
33
|
+
version: '7.0'
|
42
34
|
- !ruby/object:Gem::Dependency
|
43
35
|
name: yard
|
44
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,9 +98,12 @@ files:
|
|
106
98
|
- bin/yard
|
107
99
|
- bin/yardoc
|
108
100
|
- bin/yri
|
109
|
-
- gemfiles/
|
110
|
-
- gemfiles/
|
111
|
-
- gemfiles/
|
101
|
+
- gemfiles/.bundle/config
|
102
|
+
- gemfiles/rails_5.0.gemfile
|
103
|
+
- gemfiles/rails_5.1.gemfile
|
104
|
+
- gemfiles/rails_5.2.gemfile
|
105
|
+
- gemfiles/rails_6.0.gemfile
|
106
|
+
- gemfiles/rails_6.1.gemfile
|
112
107
|
- lib/acl9.rb
|
113
108
|
- lib/acl9/controller_extensions.rb
|
114
109
|
- lib/acl9/controller_extensions/dsl_base.rb
|
@@ -150,6 +145,7 @@ files:
|
|
150
145
|
- test/controllers/acl_query_mixin.rb
|
151
146
|
- test/controllers/acl_subject_method_test.rb
|
152
147
|
- test/controllers/arguments_checking_test.rb
|
148
|
+
- test/dummy/app/assets/config/manifest.js
|
153
149
|
- test/dummy/app/controllers/acl_action_override.rb
|
154
150
|
- test/dummy/app/controllers/acl_arguments.rb
|
155
151
|
- test/dummy/app/controllers/acl_block.rb
|
@@ -178,6 +174,8 @@ files:
|
|
178
174
|
- test/dummy/app/models/other/role.rb
|
179
175
|
- test/dummy/app/models/other/user.rb
|
180
176
|
- test/dummy/app/models/role.rb
|
177
|
+
- test/dummy/app/models/string_object_role.rb
|
178
|
+
- test/dummy/app/models/string_user.rb
|
181
179
|
- test/dummy/app/models/user.rb
|
182
180
|
- test/dummy/app/models/uuid.rb
|
183
181
|
- test/dummy/config.ru
|
@@ -186,7 +184,6 @@ files:
|
|
186
184
|
- test/dummy/config/database.yml
|
187
185
|
- test/dummy/config/environment.rb
|
188
186
|
- test/dummy/config/environments/development.rb
|
189
|
-
- test/dummy/config/environments/production.rb
|
190
187
|
- test/dummy/config/environments/test.rb
|
191
188
|
- test/dummy/config/initializers/assets.rb
|
192
189
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
@@ -212,7 +209,7 @@ homepage: http://github.com/be9/acl9
|
|
212
209
|
licenses:
|
213
210
|
- MIT
|
214
211
|
metadata: {}
|
215
|
-
post_install_message:
|
212
|
+
post_install_message:
|
216
213
|
rdoc_options:
|
217
214
|
- "--charset=UTF-8"
|
218
215
|
require_paths:
|
@@ -228,9 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
225
|
- !ruby/object:Gem::Version
|
229
226
|
version: '0'
|
230
227
|
requirements: []
|
231
|
-
|
232
|
-
|
233
|
-
signing_key:
|
228
|
+
rubygems_version: 3.1.4
|
229
|
+
signing_key:
|
234
230
|
specification_version: 4
|
235
231
|
summary: Role-based authorization system for Rails with a concise DSL for securing
|
236
232
|
your Rails application.
|
@@ -262,6 +258,7 @@ test_files:
|
|
262
258
|
- test/controllers/acl_query_mixin.rb
|
263
259
|
- test/controllers/acl_subject_method_test.rb
|
264
260
|
- test/controllers/arguments_checking_test.rb
|
261
|
+
- test/dummy/app/assets/config/manifest.js
|
265
262
|
- test/dummy/app/controllers/acl_action_override.rb
|
266
263
|
- test/dummy/app/controllers/acl_arguments.rb
|
267
264
|
- test/dummy/app/controllers/acl_block.rb
|
@@ -290,6 +287,8 @@ test_files:
|
|
290
287
|
- test/dummy/app/models/other/role.rb
|
291
288
|
- test/dummy/app/models/other/user.rb
|
292
289
|
- test/dummy/app/models/role.rb
|
290
|
+
- test/dummy/app/models/string_object_role.rb
|
291
|
+
- test/dummy/app/models/string_user.rb
|
293
292
|
- test/dummy/app/models/user.rb
|
294
293
|
- test/dummy/app/models/uuid.rb
|
295
294
|
- test/dummy/config.ru
|
@@ -298,7 +297,6 @@ test_files:
|
|
298
297
|
- test/dummy/config/database.yml
|
299
298
|
- test/dummy/config/environment.rb
|
300
299
|
- test/dummy/config/environments/development.rb
|
301
|
-
- test/dummy/config/environments/production.rb
|
302
300
|
- test/dummy/config/environments/test.rb
|
303
301
|
- test/dummy/config/initializers/assets.rb
|
304
302
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
@@ -320,4 +318,3 @@ test_files:
|
|
320
318
|
- test/models/users_roles_and_subjects_with_namespaced_class_names_test.rb
|
321
319
|
- test/test_helper.rb
|
322
320
|
- test/version_test.rb
|
323
|
-
has_rdoc:
|
@@ -1,78 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# Code is not reloaded between requests.
|
5
|
-
config.cache_classes = true
|
6
|
-
|
7
|
-
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both threaded web servers
|
9
|
-
# and those relying on copy on write to perform better.
|
10
|
-
# Rake tasks automatically ignore this option for performance.
|
11
|
-
config.eager_load = true
|
12
|
-
|
13
|
-
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local = false
|
15
|
-
config.action_controller.perform_caching = true
|
16
|
-
|
17
|
-
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
-
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
-
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
-
# config.action_dispatch.rack_cache = true
|
21
|
-
|
22
|
-
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
-
config.serve_static_files = false
|
24
|
-
|
25
|
-
# Compress JavaScripts and CSS.
|
26
|
-
config.assets.js_compressor = :uglifier
|
27
|
-
# config.assets.css_compressor = :sass
|
28
|
-
|
29
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
-
config.assets.compile = false
|
31
|
-
|
32
|
-
# Generate digests for assets URLs.
|
33
|
-
config.assets.digest = true
|
34
|
-
|
35
|
-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
36
|
-
|
37
|
-
# Specifies the header that your server uses for sending files.
|
38
|
-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
39
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
40
|
-
|
41
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
42
|
-
# config.force_ssl = true
|
43
|
-
|
44
|
-
# Set to :debug to see everything in the log.
|
45
|
-
config.log_level = :info
|
46
|
-
|
47
|
-
# Prepend all log lines with the following tags.
|
48
|
-
# config.log_tags = [ :subdomain, :uuid ]
|
49
|
-
|
50
|
-
# Use a different logger for distributed setups.
|
51
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
52
|
-
|
53
|
-
# Use a different cache store in production.
|
54
|
-
# config.cache_store = :mem_cache_store
|
55
|
-
|
56
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
57
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
58
|
-
|
59
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
60
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
61
|
-
# config.action_mailer.raise_delivery_errors = false
|
62
|
-
|
63
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
64
|
-
# the I18n.default_locale when a translation cannot be found).
|
65
|
-
config.i18n.fallbacks = true
|
66
|
-
|
67
|
-
# Send deprecation notices to registered listeners.
|
68
|
-
config.active_support.deprecation = :notify
|
69
|
-
|
70
|
-
# Disable automatic flushing of the log to improve performance.
|
71
|
-
# config.autoflush_log = false
|
72
|
-
|
73
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
74
|
-
config.log_formatter = ::Logger::Formatter.new
|
75
|
-
|
76
|
-
# Do not dump schema after migrations.
|
77
|
-
config.active_record.dump_schema_after_migration = false
|
78
|
-
end
|