aclatraz 0.1.3 → 0.1.4

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.
@@ -5,97 +5,99 @@ describe "Aclatraz suspect" do
5
5
  subject { StubSuspect.new }
6
6
  let(:target) { StubTarget.new }
7
7
 
8
- its(:acl_suspect?) { should be_true }
8
+ it "#acl_suspect? should be true" do
9
+ subject.should be_acl_suspect
10
+ end
9
11
 
10
- it "1: should properly set given role" do
11
- subject.roles.assign(:foobar1)
12
- subject.roles.assign(:foobar2, StubTarget)
13
- subject.roles.assign(:foobar3, target)
12
+ it "should properly set given role" do
13
+ subject.roles.assign(:first)
14
+ subject.roles.assign(:second, StubTarget)
15
+ subject.roles.assign(:third, target)
14
16
 
15
- subject.roles.has?(:foobar1).should be_true
16
- subject.roles.has?(:foobar2, StubTarget).should be_true
17
- subject.roles.has?(:foobar3, target).should be_true
17
+ subject.roles.has?(:first).should be_true
18
+ subject.roles.has?(:second, StubTarget).should be_true
19
+ subject.roles.has?(:third, target).should be_true
18
20
  end
19
21
 
20
- it "2: should properly check given permissions" do
21
- subject.roles.has?(:foobar1).should be_true
22
- subject.roles.has?(:foobar2, StubTarget).should be_true
23
- subject.roles.has?(:foobar3, target).should be_true
24
- subject.roles.has?(:foobar1, StubTarget).should be_false
22
+ it "should properly check given permissions" do
23
+ subject.roles.has?(:first).should be_true
24
+ subject.roles.has?(:second, StubTarget).should be_true
25
+ subject.roles.has?(:third, target).should be_true
26
+ subject.roles.has?(:first, StubTarget).should be_false
25
27
  end
26
28
 
27
- it "3: should allow to get list of roles assigned to user" do
28
- (subject.roles.all - ["foobar1", "foobar2", "foobar3"]) .should be_empty
29
+ it "should allow to get list of roles assigned to user" do
30
+ (subject.roles.all - ["first", "second", "third"]) .should be_empty
29
31
  end
30
32
 
31
- it "4: should properly remove given permissions" do
32
- subject.roles.delete(:foobar1)
33
- subject.roles.delete(:foobar2, StubTarget)
34
- subject.roles.delete(:foobar3, target)
33
+ it "should properly remove given permissions" do
34
+ subject.roles.delete(:first)
35
+ subject.roles.delete(:second, StubTarget)
36
+ subject.roles.delete(:third, target)
35
37
 
36
- subject.roles.has?(:foobar1).should be_false
37
- subject.roles.has?(:foobar2, StubTarget).should be_false
38
- subject.roles.has?(:foobar3, target).should be_false
38
+ subject.roles.has?(:first).should be_false
39
+ subject.roles.has?(:second, StubTarget).should be_false
40
+ subject.roles.has?(:third, target).should be_false
39
41
  end
40
42
 
41
43
  context "syntactic sugars" do
42
- it "1: should properly set given role" do
43
- subject.is.foobar1!
44
- subject.is.foobar2_of!(StubTarget)
45
- subject.is.foobar3_for!(target)
46
- subject.is.foobar4_on!(target)
47
- subject.is.foobar5_at!(target)
48
- subject.is.foobar6_by!(target)
49
- subject.is.foobar7_in!(target)
44
+ it "should properly set given role" do
45
+ subject.is.first!
46
+ subject.is.second_of!(StubTarget)
47
+ subject.is.third_for!(target)
48
+ subject.is.fourth_on!(target)
49
+ subject.is.fifth_at!(target)
50
+ subject.is.sixth_by!(target)
51
+ subject.is.seventh_in!(target)
50
52
 
51
- subject.roles.has?(:foobar1).should be_true
52
- subject.roles.has?(:foobar2_of, StubTarget).should be_true
53
- subject.roles.has?(:foobar3_for, target).should be_true
54
- subject.roles.has?(:foobar4_of, target).should be_true
55
- subject.roles.has?(:foobar5_at, target).should be_true
56
- subject.roles.has?(:foobar6_by, target).should be_true
57
- subject.roles.has?(:foobar7_in, target).should be_true
53
+ subject.roles.has?(:first).should be_true
54
+ subject.roles.has?(:second_of, StubTarget).should be_true
55
+ subject.roles.has?(:third_for, target).should be_true
56
+ subject.roles.has?(:fourth_of, target).should be_true
57
+ subject.roles.has?(:fifth_at, target).should be_true
58
+ subject.roles.has?(:sixth_by, target).should be_true
59
+ subject.roles.has?(:seventh_in, target).should be_true
58
60
  end
59
61
 
60
- it "2: should properly check given permissions" do
61
- subject.is.foobar1?.should be_true
62
- subject.is.foobar2_of?(StubTarget).should be_true
63
- subject.is.foobar3_for?(target).should be_true
64
- subject.is.foobar4_on?(target).should be_true
65
- subject.is.foobar5_at?(target).should be_true
66
- subject.is.foobar6_by?(target).should be_true
67
- subject.is.foobar7_in?(target).should be_true
68
- subject.is.foobar8_in?.should be_false
62
+ it "should properly check given permissions" do
63
+ subject.is.first?.should be_true
64
+ subject.is.second_of?(StubTarget).should be_true
65
+ subject.is.third_for?(target).should be_true
66
+ subject.is.fourth_on?(target).should be_true
67
+ subject.is.fifth_at?(target).should be_true
68
+ subject.is.sixth_by?(target).should be_true
69
+ subject.is.seventh_in?(target).should be_true
70
+ subject.is.eighth_in?.should be_false
69
71
 
70
- subject.is_not.foobar1?.should be_false
71
- subject.is_not.foobar2_of?(StubTarget).should be_false
72
- subject.is_not.foobar3_for?(target).should be_false
73
- subject.is_not.foobar4_on?(target).should be_false
74
- subject.is_not.foobar5_at?(target).should be_false
75
- subject.is_not.foobar6_by?(target).should be_false
76
- subject.is_not.foobar7_in?(target).should be_false
77
- subject.is_not.foobar8_in?.should be_true
72
+ subject.is_not.first?.should be_false
73
+ subject.is_not.second_of?(StubTarget).should be_false
74
+ subject.is_not.third_for?(target).should be_false
75
+ subject.is_not.fourth_on?(target).should be_false
76
+ subject.is_not.fifth_at?(target).should be_false
77
+ subject.is_not.sixth_by?(target).should be_false
78
+ subject.is_not.seventh_in?(target).should be_false
79
+ subject.is_not.eighth_in?.should be_true
78
80
  end
79
81
 
80
- it "3: should properly remove given permissions" do
81
- subject.is_not.foobar1!
82
- subject.is_not.foobar2_of!(StubTarget)
83
- subject.is_not.foobar3_for!(target)
84
- subject.is_not.foobar4_on!(target)
85
- subject.is_not.foobar5_at!(target)
86
- subject.is_not.foobar6_by!(target)
87
- subject.is_not.foobar7_in!(target)
82
+ it "should properly remove given permissions" do
83
+ subject.is_not.first!
84
+ subject.is_not.second_of!(StubTarget)
85
+ subject.is_not.third_for!(target)
86
+ subject.is_not.fourth_on!(target)
87
+ subject.is_not.fifth_at!(target)
88
+ subject.is_not.sixth_by!(target)
89
+ subject.is_not.seventh_in!(target)
88
90
 
89
- subject.is.foobar1?.should be_false
90
- subject.is.foobar2_of?(StubTarget).should be_false
91
- subject.is.foobar3_for?(target).should be_false
92
- subject.is.foobar4_on?(target).should be_false
93
- subject.is.foobar5_at?(target).should be_false
94
- subject.is.foobar6_by?(target).should be_false
95
- subject.is.foobar7_in?(target).should be_false
91
+ subject.is.first?.should be_false
92
+ subject.is.second_of?(StubTarget).should be_false
93
+ subject.is.third_for?(target).should be_false
94
+ subject.is.fourth_on?(target).should be_false
95
+ subject.is.fifth_at?(target).should be_false
96
+ subject.is.sixth_by?(target).should be_false
97
+ subject.is.seventh_in?(target).should be_false
96
98
  end
97
99
 
98
- it "4: should raise NoMethodError when there is not checker or setter/deleter called" do
100
+ it "should raise NoMethodError when there is not checker or setter/deleter called" do
99
101
  lambda { subject.is.foobar }.should raise_error(NoMethodError)
100
102
  lambda { subject.is_not.foobar }.should raise_error(NoMethodError)
101
103
  end
@@ -2,19 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe "Aclatraz" do
4
4
  context "on init" do
5
- it "should raise InvalidStore error when given store doesn't exists" do
6
- lambda { Aclatraz.init(:fooobar) }.should raise_error(Aclatraz::InvalidStore)
5
+ it "should raise error when given store is invalid" do
6
+ lambda {
7
+ Aclatraz.init(:invalid_data_store)
8
+ }.should raise_error(Aclatraz::InvalidStore)
7
9
  end
8
10
 
9
- it "should properly set datastore when class given" do
10
- class TestStore; end
11
- lambda { Aclatraz.init(TestStore) }.should_not raise_error
12
- Aclatraz.store.should be_kind_of(TestStore)
11
+ it "should set data store when it is valid" do
12
+ lambda {
13
+ Aclatraz.init(StubStore)
14
+ Aclatraz.store.should be_kind_of(StubStore)
15
+ }.should_not raise_error
13
16
  end
14
17
  end
15
18
 
16
- it "should raise StoreNotInitialized error when store has not been set yet" do
17
- Aclatraz.instance_variable_set('@store', nil)
18
- lambda { Aclatraz.store }.should raise_error(Aclatraz::StoreNotInitialized)
19
+ it "should raise error when store has not been initialized yet" do
20
+ lambda {
21
+ Aclatraz.instance_variable_set('@store', nil)
22
+ Aclatraz.store
23
+ }.should raise_error(Aclatraz::StoreNotInitialized)
19
24
  end
20
25
  end
@@ -28,7 +28,7 @@ class Foo
28
28
  def test
29
29
  guard!(:foo, :bar)
30
30
  rescue
31
- end
31
+ end
32
32
  end
33
33
 
34
34
  $foo = Foo.new
@@ -5,6 +5,7 @@ $VERBOSE = nil
5
5
 
6
6
  require 'rubygems'
7
7
  require 'aclatraz'
8
+ require 'mocha'
8
9
  require 'rspec'
9
10
 
10
11
  RSpec.configure do |config|
@@ -30,3 +31,22 @@ end
30
31
  class StubOwner
31
32
  def id; 15; end
32
33
  end
34
+
35
+ class GuardedParent
36
+ include Aclatraz::Guard
37
+ def user; @user ||= StubSuspect.new; end
38
+ suspects :user do
39
+ allow :cooker
40
+ deny :waiter
41
+ end
42
+ end
43
+
44
+ class GuardedChild < GuardedParent
45
+ suspects do
46
+ deny :cooker
47
+ allow :manager
48
+ end
49
+ end
50
+
51
+ class StubStore
52
+ end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aclatraz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
- - Kriss 'nu7hatch' Kowalik
13
+ - Chris Kowalik
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-16 00:00:00 +02:00
18
+ date: 2010-11-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -54,7 +54,7 @@ dependencies:
54
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
- - - ~>
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  hash: 25
60
60
  segments:
@@ -69,7 +69,7 @@ dependencies:
69
69
  requirement: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
72
- - - ~>
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  hash: 3
75
75
  segments:
@@ -84,7 +84,7 @@ dependencies:
84
84
  requirement: &id005 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ~>
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  hash: 27
90
90
  segments:
@@ -99,7 +99,7 @@ dependencies:
99
99
  requirement: &id006 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
102
- - - ~>
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  hash: 27
105
105
  segments:
@@ -108,8 +108,9 @@ dependencies:
108
108
  version: "0.8"
109
109
  type: :development
110
110
  version_requirements: *id006
111
- description: " Extremaly fast, flexible and intuitive access control mechanism, \n powered by fast key value stores like Redis.\n"
112
- email: kriss.kowalik@gmail.com
111
+ description: Extremaly fast, flexible and intuitive access control mechanism, powered by fast key value stores like Redis.
112
+ email:
113
+ - chris@nu7hat.ch
113
114
  executables: []
114
115
 
115
116
  extensions: []
@@ -117,15 +118,15 @@ extensions: []
117
118
  extra_rdoc_files:
118
119
  - LICENSE
119
120
  - README.rdoc
121
+ - CHANGELOG.rdoc
122
+ - TODO.rdoc
120
123
  files:
121
- - .document
122
124
  - .gitignore
123
125
  - CHANGELOG.rdoc
124
126
  - LICENSE
125
127
  - README.rdoc
126
128
  - Rakefile
127
129
  - TODO.rdoc
128
- - VERSION
129
130
  - aclatraz.gemspec
130
131
  - examples/dinner.rb
131
132
  - lib/aclatraz.rb
@@ -134,6 +135,7 @@ files:
134
135
  - lib/aclatraz/helpers.rb
135
136
  - lib/aclatraz/store.rb
136
137
  - lib/aclatraz/store/cassandra.rb
138
+ - lib/aclatraz/store/mongo.rb
137
139
  - lib/aclatraz/store/redis.rb
138
140
  - lib/aclatraz/store/riak.rb
139
141
  - lib/aclatraz/suspect.rb
@@ -150,8 +152,8 @@ homepage: http://github.com/nu7hatch/aclatraz
150
152
  licenses: []
151
153
 
152
154
  post_install_message:
153
- rdoc_options:
154
- - --charset=UTF-8
155
+ rdoc_options: []
156
+
155
157
  require_paths:
156
158
  - lib
157
159
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -178,14 +180,6 @@ rubyforge_project:
178
180
  rubygems_version: 1.3.7
179
181
  signing_key:
180
182
  specification_version: 3
181
- summary: Flexible access control that doesn't sucks!
182
- test_files:
183
- - spec/alcatraz_bm.rb
184
- - spec/spec_helper.rb
185
- - spec/aclatraz/guard_spec.rb
186
- - spec/aclatraz/helpers_spec.rb
187
- - spec/aclatraz/acl_spec.rb
188
- - spec/aclatraz/stores_spec.rb
189
- - spec/aclatraz/suspect_spec.rb
190
- - spec/aclatraz_spec.rb
191
- - examples/dinner.rb
183
+ summary: Flexible access control mechanism!
184
+ test_files: []
185
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.3