cjbottaro-aegis 1.3.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.
Files changed (53) hide show
  1. data/.gitignore +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +182 -0
  4. data/Rakefile +37 -0
  5. data/VERSION +1 -0
  6. data/aegis.gemspec +117 -0
  7. data/lib/aegis.rb +11 -0
  8. data/lib/aegis/constants.rb +6 -0
  9. data/lib/aegis/has_role.rb +156 -0
  10. data/lib/aegis/meta_class.rb +13 -0
  11. data/lib/aegis/normalization.rb +26 -0
  12. data/lib/aegis/permission_error.rb +5 -0
  13. data/lib/aegis/permission_evaluator.rb +41 -0
  14. data/lib/aegis/permissions.rb +108 -0
  15. data/lib/aegis/role.rb +57 -0
  16. data/lib/aegis/role_assignments.rb +10 -0
  17. data/lib/rails/active_record.rb +5 -0
  18. data/test/app_root/app/controllers/application_controller.rb +2 -0
  19. data/test/app_root/app/models/account.rb +3 -0
  20. data/test/app_root/app/models/forum.rb +8 -0
  21. data/test/app_root/app/models/permissions.rb +70 -0
  22. data/test/app_root/app/models/post.rb +7 -0
  23. data/test/app_root/app/models/soldier.rb +5 -0
  24. data/test/app_root/app/models/user.rb +7 -0
  25. data/test/app_root/config/boot.rb +114 -0
  26. data/test/app_root/config/database.yml +21 -0
  27. data/test/app_root/config/environment.rb +14 -0
  28. data/test/app_root/config/environments/in_memory.rb +0 -0
  29. data/test/app_root/config/environments/mysql.rb +0 -0
  30. data/test/app_root/config/environments/postgresql.rb +0 -0
  31. data/test/app_root/config/environments/sqlite.rb +0 -0
  32. data/test/app_root/config/environments/sqlite3.rb +0 -0
  33. data/test/app_root/config/routes.rb +4 -0
  34. data/test/app_root/db/migrate/20090408115228_create_users.rb +15 -0
  35. data/test/app_root/db/migrate/20090429075648_create_soldiers.rb +16 -0
  36. data/test/app_root/db/migrate/20090903234709_create_role_assignments.rb +16 -0
  37. data/test/app_root/db/migrate/20090903234759_create_accounts.rb +11 -0
  38. data/test/app_root/db/migrate/20090903234821_create_forums.rb +12 -0
  39. data/test/app_root/db/migrate/20090903234828_create_posts.rb +12 -0
  40. data/test/app_root/lib/console_with_fixtures.rb +4 -0
  41. data/test/app_root/log/.gitignore +1 -0
  42. data/test/app_root/script/console +7 -0
  43. data/test/fixtures/accounts.yml +5 -0
  44. data/test/fixtures/forums.yml +11 -0
  45. data/test/fixtures/posts.yml +23 -0
  46. data/test/fixtures/role_assignments.yml +0 -0
  47. data/test/fixtures/users.yml +2 -0
  48. data/test/has_role_options_test.rb +33 -0
  49. data/test/has_role_test.rb +88 -0
  50. data/test/permissions_test.rb +117 -0
  51. data/test/test_helper.rb +44 -0
  52. data/test/validation_test.rb +49 -0
  53. metadata +130 -0
@@ -0,0 +1,44 @@
1
+ # Set the default environment to sqlite3's in_memory database
2
+ ENV['RAILS_ENV'] ||= 'in_memory'
3
+
4
+ # Load the Rails environment and testing framework
5
+ require "#{File.dirname(__FILE__)}/app_root/config/environment"
6
+ require "#{File.dirname(__FILE__)}/../lib/aegis"
7
+ require 'test_help'
8
+ require 'action_view/test_case' # Load additional test classes not done automatically by < Rails 2.2.2
9
+
10
+ require "shoulda"
11
+
12
+ # Undo changes to RAILS_ENV
13
+ silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
14
+
15
+ # Run the migrations
16
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
17
+
18
+ # Set default fixture loading properties
19
+ ActiveSupport::TestCase.class_eval do
20
+ self.use_transactional_fixtures = true
21
+ self.use_instantiated_fixtures = false
22
+ self.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
23
+
24
+ fixtures :all
25
+
26
+ def create_role_assignments
27
+ Aegis::RoleAssignment.create! :actor => users(:with_hierarchy),
28
+ :role_name => "admin",
29
+ :context => accounts(:google)
30
+
31
+ Aegis::RoleAssignment.create! :actor => users(:with_hierarchy),
32
+ :role_name => "writer",
33
+ :context => forums(:searching)
34
+
35
+ Aegis::RoleAssignment.create! :actor => users(:with_hierarchy),
36
+ :role_name => "reader",
37
+ :context => posts(:searching102)
38
+
39
+ Aegis::RoleAssignment.create! :actor => users(:with_hierarchy),
40
+ :role_name => "guest",
41
+ :context => accounts(:yahoo)
42
+ end
43
+
44
+ end
@@ -0,0 +1,49 @@
1
+ require "test/test_helper"
2
+
3
+ class ValidationTest < ActiveSupport::TestCase
4
+
5
+ context "A model that has and validates its role" do
6
+
7
+ setup do
8
+ @user = User.new()
9
+ end
10
+
11
+ context "that has a role_name mapping to a role" do
12
+
13
+ setup do
14
+ @user.role_name = "admin"
15
+ end
16
+
17
+ should "be valid" do
18
+ assert @user.valid?
19
+ end
20
+
21
+ end
22
+
23
+ context "that has a blank role_name" do
24
+
25
+ setup do
26
+ @user.role_name = ""
27
+ end
28
+
29
+ should "not be valid" do
30
+ assert !@user.valid?
31
+ end
32
+
33
+ end
34
+
35
+ context "that has a role_name not mapping to a role" do
36
+
37
+ setup do
38
+ @user.role_name = "nonexisting_role_name"
39
+ end
40
+
41
+ should "not be valid" do
42
+ assert !@user.valid?
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cjbottaro-aegis
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Henning Koch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-07 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Aegis is a role-based permission system, where all users are given a role. It is possible to define detailed and complex permissions for each role very easily.
17
+ email: github@makandra.de
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - .gitignore
26
+ - MIT-LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION
30
+ - aegis.gemspec
31
+ - lib/aegis.rb
32
+ - lib/aegis/constants.rb
33
+ - lib/aegis/has_role.rb
34
+ - lib/aegis/meta_class.rb
35
+ - lib/aegis/normalization.rb
36
+ - lib/aegis/permission_error.rb
37
+ - lib/aegis/permission_evaluator.rb
38
+ - lib/aegis/permissions.rb
39
+ - lib/aegis/role.rb
40
+ - lib/aegis/role_assignments.rb
41
+ - lib/rails/active_record.rb
42
+ - test/app_root/app/controllers/application_controller.rb
43
+ - test/app_root/app/models/account.rb
44
+ - test/app_root/app/models/forum.rb
45
+ - test/app_root/app/models/permissions.rb
46
+ - test/app_root/app/models/post.rb
47
+ - test/app_root/app/models/soldier.rb
48
+ - test/app_root/app/models/user.rb
49
+ - test/app_root/config/boot.rb
50
+ - test/app_root/config/database.yml
51
+ - test/app_root/config/environment.rb
52
+ - test/app_root/config/environments/in_memory.rb
53
+ - test/app_root/config/environments/mysql.rb
54
+ - test/app_root/config/environments/postgresql.rb
55
+ - test/app_root/config/environments/sqlite.rb
56
+ - test/app_root/config/environments/sqlite3.rb
57
+ - test/app_root/config/routes.rb
58
+ - test/app_root/db/migrate/20090408115228_create_users.rb
59
+ - test/app_root/db/migrate/20090429075648_create_soldiers.rb
60
+ - test/app_root/db/migrate/20090903234709_create_role_assignments.rb
61
+ - test/app_root/db/migrate/20090903234759_create_accounts.rb
62
+ - test/app_root/db/migrate/20090903234821_create_forums.rb
63
+ - test/app_root/db/migrate/20090903234828_create_posts.rb
64
+ - test/app_root/lib/console_with_fixtures.rb
65
+ - test/app_root/log/.gitignore
66
+ - test/app_root/script/console
67
+ - test/fixtures/accounts.yml
68
+ - test/fixtures/forums.yml
69
+ - test/fixtures/posts.yml
70
+ - test/fixtures/role_assignments.yml
71
+ - test/fixtures/users.yml
72
+ - test/has_role_options_test.rb
73
+ - test/has_role_test.rb
74
+ - test/permissions_test.rb
75
+ - test/test_helper.rb
76
+ - test/validation_test.rb
77
+ has_rdoc: true
78
+ homepage: http://github.com/makandra/aegis
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --charset=UTF-8
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.2.0
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Role-based permissions for your user models.
103
+ test_files:
104
+ - test/app_root/app/controllers/application_controller.rb
105
+ - test/app_root/app/models/account.rb
106
+ - test/app_root/app/models/forum.rb
107
+ - test/app_root/app/models/permissions.rb
108
+ - test/app_root/app/models/post.rb
109
+ - test/app_root/app/models/soldier.rb
110
+ - test/app_root/app/models/user.rb
111
+ - test/app_root/config/boot.rb
112
+ - test/app_root/config/environment.rb
113
+ - test/app_root/config/environments/in_memory.rb
114
+ - test/app_root/config/environments/mysql.rb
115
+ - test/app_root/config/environments/postgresql.rb
116
+ - test/app_root/config/environments/sqlite.rb
117
+ - test/app_root/config/environments/sqlite3.rb
118
+ - test/app_root/config/routes.rb
119
+ - test/app_root/db/migrate/20090408115228_create_users.rb
120
+ - test/app_root/db/migrate/20090429075648_create_soldiers.rb
121
+ - test/app_root/db/migrate/20090903234709_create_role_assignments.rb
122
+ - test/app_root/db/migrate/20090903234759_create_accounts.rb
123
+ - test/app_root/db/migrate/20090903234821_create_forums.rb
124
+ - test/app_root/db/migrate/20090903234828_create_posts.rb
125
+ - test/app_root/lib/console_with_fixtures.rb
126
+ - test/has_role_options_test.rb
127
+ - test/has_role_test.rb
128
+ - test/permissions_test.rb
129
+ - test/test_helper.rb
130
+ - test/validation_test.rb