simple-authorisation 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-authorisation (0.0.4)
4
+ simple-authorisation (0.0.7)
5
5
  sinatra (~> 1.2.6)
6
6
 
7
7
  GEM
@@ -23,7 +23,8 @@ module Simple
23
23
  end
24
24
 
25
25
  def self.is_allowed?(route_name, options)
26
- matching_route = (@@routes.keys.sort.reverse.select{|route | route_name.start_with?(route) }).first
26
+ matching_route = (@@routes.keys.sort.reverse.select{|route | route_name =~ /#{route.gsub('*', '.+')}/}).first
27
+ matching_route = (@@routes.keys.sort.reverse.select{|route | route_name.start_with?(route) }).first if matching_route.nil?
27
28
 
28
29
  route_settings = @@routes[matching_route]
29
30
  raise NoSettingsForRoute.new(route_name) if route_settings.nil?
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'simple-authorisation'
6
- s.version = '0.0.7'
6
+ s.version = '0.0.8'
7
7
  s.authors = ["Derek Ekins"]
8
8
  s.description = 'Handles authorisation only'
9
9
  s.summary = "simple-authorisation-#{s.version}"
@@ -77,5 +77,13 @@ module Simple
77
77
  Simple::Authorisation.route '/test', :allow => ['test-action']
78
78
  lambda{ Simple::Authorisation.is_allowed?('/test', :method => :get, :user => user)}.should_not raise_error
79
79
  end
80
+
81
+ it "should allow wildcards in parts of the route" do
82
+ user = Object.new
83
+ user.stub!(:actions).and_return(['test-action'])
84
+
85
+ Simple::Authorisation.route '/test/*/blah', :allow => ['test-action']
86
+ Simple::Authorisation.is_allowed?('/test/something/blah', :method => :get, :user => user).should be_true
87
+ end
80
88
  end
81
89
  end
@@ -10,11 +10,11 @@ module Sinatra
10
10
  end
11
11
 
12
12
  it "asks Simple::Authorisation if access is allowed" do
13
+ Simple::Authorisation.should_receive(:is_allowed?).with("/", {:user=>nil, :anonymous_user_class => NilClass, :method => :get})
14
+
13
15
  Simple::Authorisation.route '/', :allow => ['?']
14
16
  @session.get '/'
15
17
 
16
- # this fails for some reason but I know that it does work - what is wrong???
17
- Simple::Authorisation.should_receive(:is_allowed?).with("/", {:user=>nil})
18
18
  end
19
19
 
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-authorisation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-03 00:00:00.000000000Z
12
+ date: 2011-09-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &23630060 !ruby/object:Gem::Requirement
16
+ requirement: &16703140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *23630060
24
+ version_requirements: *16703140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &23629580 !ruby/object:Gem::Requirement
27
+ requirement: &16702500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *23629580
35
+ version_requirements: *16702500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &23629120 !ruby/object:Gem::Requirement
38
+ requirement: &16701880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *23629120
46
+ version_requirements: *16701880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sinatra
49
- requirement: &23628660 !ruby/object:Gem::Requirement
49
+ requirement: &16701380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.6
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *23628660
57
+ version_requirements: *16701380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rack-test
60
- requirement: &23628200 !ruby/object:Gem::Requirement
60
+ requirement: &16682260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *23628200
68
+ version_requirements: *16682260
69
69
  description: Handles authorisation only
70
70
  email: derek@spathi.com
71
71
  executables: []
@@ -117,7 +117,7 @@ rubyforge_project:
117
117
  rubygems_version: 1.8.6
118
118
  signing_key:
119
119
  specification_version: 3
120
- summary: simple-authorisation-0.0.7
120
+ summary: simple-authorisation-0.0.8
121
121
  test_files:
122
122
  - spec/simple-authorisation/authorisation_spec.rb
123
123
  - spec/simple-authorisation/sinatra_integration_spec.rb