oa-core 0.2.4 → 0.2.5

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.
@@ -1,30 +1,30 @@
1
1
  require 'omniauth/core'
2
2
 
3
3
  module OmniAuth
4
- class Builder < ::Rack::Builder
4
+ class Builder < ::Rack::Builder
5
5
  def initialize(app, &block)
6
6
  @app = app
7
7
  super(&block)
8
8
  end
9
-
9
+
10
10
  def on_failure(&block)
11
11
  OmniAuth.config.on_failure = block
12
12
  end
13
-
13
+
14
14
  def configure(&block)
15
15
  OmniAuth.configure(&block)
16
16
  end
17
-
17
+
18
18
  def provider(klass, *args, &block)
19
19
  if klass.is_a?(Class)
20
20
  middleware = klass
21
21
  else
22
22
  middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
23
23
  end
24
-
24
+
25
25
  use middleware, *args, &block
26
26
  end
27
-
27
+
28
28
  def call(env)
29
29
  @ins << @app unless @ins.include?(@app)
30
30
  to_app.call(env)
@@ -73,7 +73,7 @@ module OmniAuth
73
73
  attr_writer :on_failure
74
74
  attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host
75
75
  end
76
-
76
+
77
77
  def self.config
78
78
  Configuration.instance
79
79
  end
@@ -97,7 +97,8 @@ module OmniAuth
97
97
  'soundcloud' => 'SoundCloud',
98
98
  'smugmug' => 'SmugMug',
99
99
  'cas' => 'CAS',
100
- 'trademe' => 'TradeMe'
100
+ 'trademe' => 'TradeMe',
101
+ 'ldap' => 'LDAP'
101
102
  }
102
103
 
103
104
  module_function
@@ -7,7 +7,7 @@ module OmniAuth
7
7
  background: #ccc;
8
8
  font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif;
9
9
  }
10
-
10
+
11
11
  h1 {
12
12
  text-align: center;
13
13
  margin: 30px auto 0px;
@@ -25,12 +25,12 @@ module OmniAuth
25
25
  border-top-left-radius: 10px;
26
26
  border-top-right-radius: 10px;
27
27
  }
28
-
28
+
29
29
  h1, form {
30
30
  -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
31
31
  -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
32
32
  }
33
-
33
+
34
34
  form {
35
35
  background: white;
36
36
  border: 10px solid #eee;
@@ -45,13 +45,13 @@ module OmniAuth
45
45
  border-bottom-left-radius: 10px;
46
46
  border-bottom-right-radius: 10px;
47
47
  }
48
-
48
+
49
49
  label {
50
50
  display: block;
51
51
  font-weight: bold;
52
52
  margin-bottom: 5px;
53
53
  }
54
-
54
+
55
55
  input {
56
56
  font-size: 18px;
57
57
  padding: 4px 8px;
@@ -59,13 +59,13 @@ module OmniAuth
59
59
  margin-bottom: 10px;
60
60
  width: 280px;
61
61
  }
62
-
62
+
63
63
  input#identifier, input#openid_url {
64
64
  background: url(http://openid.net/login-bg.gif) no-repeat;
65
65
  background-position: 0 50%;
66
66
  padding-left: 18px;
67
67
  }
68
-
68
+
69
69
  button {
70
70
  font-size: 22px;
71
71
  padding: 4px 8px;
@@ -85,7 +85,7 @@ module OmniAuth
85
85
  font-size: 16px;
86
86
  }
87
87
  CSS
88
-
88
+
89
89
  attr_accessor :options
90
90
 
91
91
  def initialize(options = {})
@@ -95,28 +95,28 @@ module OmniAuth
95
95
  @html = ""
96
96
  header(options[:title])
97
97
  end
98
-
98
+
99
99
  def self.build(title=nil, &block)
100
100
  form = OmniAuth::Form.new(title)
101
101
  form.instance_eval(&block)
102
102
  end
103
-
103
+
104
104
  def label_field(text, target)
105
105
  @html << "\n<label for='#{target}'>#{text}:</label>"
106
106
  self
107
107
  end
108
-
108
+
109
109
  def input_field(type, name)
110
110
  @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>"
111
111
  self
112
112
  end
113
-
113
+
114
114
  def text_field(label, name)
115
115
  label_field(label, name)
116
116
  input_field('text', name)
117
117
  self
118
118
  end
119
-
119
+
120
120
  def password_field(label, name)
121
121
  label_field(label, name)
122
122
  input_field('password', name)
@@ -126,7 +126,7 @@ module OmniAuth
126
126
  def button(text)
127
127
  @html << "\n<button type='submit'>#{text}</button>"
128
128
  end
129
-
129
+
130
130
  def html(html)
131
131
  @html << html
132
132
  end
@@ -137,7 +137,7 @@ module OmniAuth
137
137
  @html << "\n</fieldset>"
138
138
  self
139
139
  end
140
-
140
+
141
141
  def header(title)
142
142
  @html << <<-HTML
143
143
  <!DOCTYPE html>
@@ -152,7 +152,7 @@ module OmniAuth
152
152
  HTML
153
153
  self
154
154
  end
155
-
155
+
156
156
  def footer
157
157
  return self if @footer
158
158
  @html << <<-HTML
@@ -164,19 +164,19 @@ module OmniAuth
164
164
  @footer = true
165
165
  self
166
166
  end
167
-
167
+
168
168
  def to_html
169
169
  footer
170
170
  @html
171
171
  end
172
-
172
+
173
173
  def to_response
174
174
  footer
175
175
  Rack::Response.new(@html).finish
176
176
  end
177
-
177
+
178
178
  protected
179
-
179
+
180
180
  def css
181
181
  "\n<style type='text/css'>#{OmniAuth.config.form_css}</style>"
182
182
  end
@@ -1,23 +1,27 @@
1
1
  require 'omniauth/core'
2
2
 
3
3
  module OmniAuth
4
- class NoSessionError < StandardError; end
5
- module Strategy
4
+ class NoSessionError < StandardError; end
5
+ # The Strategy is the base unit of OmniAuth's ability to
6
+ # wrangle multiple providers. Each strategy provided by
7
+ # OmniAuth includes this mixin to gain the default functionality
8
+ # necessary to be compatible with the OmniAuth library.
9
+ module Strategy
6
10
  def self.included(base)
7
11
  OmniAuth.strategies << base
8
12
  base.class_eval do
9
13
  attr_reader :app, :name, :env, :options, :response
10
14
  end
11
15
  end
12
-
16
+
13
17
  def initialize(app, name, *args, &block)
14
18
  @app = app
15
19
  @name = name.to_sym
16
20
  @options = args.last.is_a?(Hash) ? args.pop : {}
17
-
21
+
18
22
  yield self if block_given?
19
23
  end
20
-
24
+
21
25
  def inspect
22
26
  "#<#{self.class.to_s}>"
23
27
  end
@@ -30,69 +34,86 @@ module OmniAuth
30
34
  raise OmniAuth::NoSessionError.new("You must provide a session to use OmniAuth.") unless env['rack.session']
31
35
 
32
36
  @env = env
33
- @env['omniauth.strategy'] = self
34
-
37
+ @env['omniauth.strategy'] = self if on_auth_path?
38
+
35
39
  return mock_call!(env) if OmniAuth.config.test_mode
36
-
37
- if current_path == request_path && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
38
- setup_phase
39
- if response = call_through_to_app
40
- response
41
- else
42
- if request.params['origin']
43
- @env['rack.session']['omniauth.origin'] = request.params['origin']
44
- elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
45
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
46
- end
47
- request_phase
48
- end
49
- elsif current_path == callback_path
50
- setup_phase
51
- @env['omniauth.origin'] = session.delete('omniauth.origin')
52
- @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
53
40
 
54
- callback_phase
41
+ return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
42
+ return callback_call if on_callback_path?
43
+ return other_phase if respond_to?(:other_phase)
44
+ @app.call(env)
45
+ end
46
+
47
+ # Performs the steps necessary to run the request phase of a strategy.
48
+ def request_call
49
+ setup_phase
50
+ if response = call_through_to_app
51
+ response
55
52
  else
56
- if respond_to?(:other_phase)
57
- other_phase
58
- else
59
- @app.call(env)
53
+ if request.params['origin']
54
+ @env['rack.session']['omniauth.origin'] = request.params['origin']
55
+ elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
56
+ @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
60
57
  end
58
+ request_phase
61
59
  end
62
60
  end
63
61
 
62
+ # Performs the steps necessary to run the callback phase of a strategy.
63
+ def callback_call
64
+ setup_phase
65
+ @env['omniauth.origin'] = session.delete('omniauth.origin')
66
+ @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
67
+
68
+ callback_phase
69
+ end
70
+
71
+ def on_auth_path?
72
+ on_request_path? || on_callback_path?
73
+ end
74
+
75
+ def on_request_path?
76
+ current_path.casecmp(request_path) == 0
77
+ end
78
+
79
+ def on_callback_path?
80
+ current_path.casecmp(callback_path) == 0
81
+ end
82
+
64
83
  def mock_call!(env)
65
- if current_path == request_path
66
- setup_phase
67
- if response = call_through_to_app
68
- response
69
- else
70
- if request.params['origin']
71
- @env['rack.session']['omniauth.origin'] = request.params['origin']
72
- elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
73
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
74
- end
75
- redirect(callback_path)
76
- end
77
- elsif current_path == callback_path
78
- setup_phase
79
- mocked_auth = OmniAuth.mock_auth_for(name.to_sym)
80
- if mocked_auth.is_a?(Symbol)
81
- fail!(mocked_auth)
82
- else
83
- @env['omniauth.auth'] = mocked_auth
84
- @env['omniauth.origin'] = session.delete('omniauth.origin')
85
- @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
86
- call_app!
87
- end
84
+ return mock_request_call if on_request_path?
85
+ return mock_callback_call if on_callback_path?
86
+ call_app!
87
+ end
88
+
89
+ def mock_request_call
90
+ setup_phase
91
+ return response if response = call_through_to_app
92
+
93
+ if request.params['origin']
94
+ @env['rack.session']['omniauth.origin'] = request.params['origin']
95
+ elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
96
+ @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
97
+ end
98
+ redirect(callback_path)
99
+ end
100
+
101
+ def mock_callback_call
102
+ setup_phase
103
+ mocked_auth = OmniAuth.mock_auth_for(name.to_sym)
104
+ if mocked_auth.is_a?(Symbol)
105
+ fail!(mocked_auth)
88
106
  else
107
+ @env['omniauth.auth'] = mocked_auth
108
+ @env['omniauth.origin'] = session.delete('omniauth.origin')
109
+ @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
89
110
  call_app!
90
111
  end
91
112
  end
92
-
113
+
93
114
  def setup_phase
94
115
  if options[:setup].respond_to?(:call)
95
- options[:setup].call(env)
116
+ options[:setup].call(env)
96
117
  elsif options[:setup]
97
118
  setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET')
98
119
  call_app!(setup_env)
@@ -102,20 +123,20 @@ module OmniAuth
102
123
  def request_phase
103
124
  raise NotImplementedError
104
125
  end
105
-
126
+
106
127
  def callback_phase
107
128
  @env['omniauth.auth'] = auth_hash
108
- call_app!
129
+ call_app!
109
130
  end
110
-
131
+
111
132
  def path_prefix
112
133
  options[:path_prefix] || OmniAuth.config.path_prefix
113
134
  end
114
-
135
+
115
136
  def request_path
116
137
  options[:request_path] || "#{path_prefix}/#{name}"
117
138
  end
118
-
139
+
119
140
  def callback_path
120
141
  options[:callback_path] || "#{path_prefix}/#{name}/callback"
121
142
  end
@@ -131,25 +152,25 @@ module OmniAuth
131
152
  def query_string
132
153
  request.query_string.empty? ? "" : "?#{request.query_string}"
133
154
  end
134
-
155
+
135
156
  def call_through_to_app
136
157
  status, headers, body = *call_app!
137
158
  @response = Rack::Response.new(body, status, headers)
138
-
159
+
139
160
  status == 404 ? nil : @response.finish
140
161
  end
141
162
 
142
163
  def call_app!(env = @env)
143
164
  @app.call(env)
144
165
  end
145
-
166
+
146
167
  def auth_hash
147
168
  {
148
169
  'provider' => name.to_s,
149
170
  'uid' => nil
150
171
  }
151
172
  end
152
-
173
+
153
174
  def full_host
154
175
  case OmniAuth.config.full_host
155
176
  when String
@@ -179,7 +200,7 @@ module OmniAuth
179
200
  def request
180
201
  @request ||= Rack::Request.new(@env)
181
202
  end
182
-
203
+
183
204
  def redirect(uri)
184
205
  r = Rack::Response.new
185
206
 
@@ -189,12 +210,12 @@ module OmniAuth
189
210
  r.write("Redirecting to #{uri}...")
190
211
  r.redirect(uri)
191
212
  end
192
-
213
+
193
214
  r.finish
194
215
  end
195
-
216
+
196
217
  def user_info; {} end
197
-
218
+
198
219
  def fail!(message_key, exception = nil)
199
220
  self.env['omniauth.error'] = exception
200
221
  self.env['omniauth.error.type'] = message_key.to_sym
@@ -1,12 +1,12 @@
1
1
  module OmniAuth
2
-
2
+
3
3
  # Support for testing OmniAuth strategies.
4
4
  module Test
5
-
5
+
6
6
  autoload :PhonySession, 'omniauth/test/phony_session'
7
7
  autoload :StrategyMacros, 'omniauth/test/strategy_macros'
8
8
  autoload :StrategyTestCase, 'omniauth/test/strategy_test_case'
9
-
9
+
10
10
  end
11
-
11
+
12
12
  end
@@ -1,34 +1,34 @@
1
1
  module OmniAuth
2
-
2
+
3
3
  module Test
4
-
4
+
5
5
  module StrategyMacros
6
-
6
+
7
7
  def sets_an_auth_hash
8
8
  it 'should set an auth hash' do
9
9
  last_request.env['omniauth.auth'].should be_kind_of(Hash)
10
10
  end
11
11
  end
12
-
12
+
13
13
  def sets_provider_to(provider)
14
14
  it "should set the provider to #{provider}" do
15
15
  (last_request.env['omniauth.auth'] || {})['provider'].should == provider
16
16
  end
17
17
  end
18
-
18
+
19
19
  def sets_uid_to(uid)
20
20
  it "should set the UID to #{uid}" do
21
21
  (last_request.env['omniauth.auth'] || {})['uid'].should == uid
22
22
  end
23
23
  end
24
-
24
+
25
25
  def sets_user_info_to(user_info)
26
26
  it "should set the user_info to #{user_info}" do
27
27
  (last_request.env['omniauth.auth'] || {})['user_info'].should == user_info
28
28
  end
29
29
  end
30
30
  end
31
-
31
+
32
32
  end
33
33
 
34
34
  end
@@ -2,9 +2,9 @@ require 'rack'
2
2
  require 'omniauth/test'
3
3
 
4
4
  module OmniAuth
5
-
5
+
6
6
  module Test
7
-
7
+
8
8
  # Support for testing OmniAuth strategies.
9
9
  #
10
10
  # @example Usage
@@ -19,7 +19,7 @@ module OmniAuth
19
19
  # end
20
20
  # end
21
21
  module StrategyTestCase
22
-
22
+
23
23
  def app
24
24
  strat = self.strategy
25
25
  resp = self.app_response
@@ -29,7 +29,7 @@ module OmniAuth
29
29
  run lambda {|env| [404, {'Content-Type' => 'text/plain'}, [resp || env.key?('omniauth.auth').to_s]] }
30
30
  }.to_app
31
31
  end
32
-
32
+
33
33
  def app_response
34
34
  nil
35
35
  end
@@ -37,13 +37,13 @@ module OmniAuth
37
37
  def session
38
38
  last_request.env['rack.session']
39
39
  end
40
-
40
+
41
41
  def strategy
42
42
  raise NotImplementedError.new('Including specs must define #strategy')
43
43
  end
44
-
44
+
45
45
  end
46
-
46
+
47
47
  end
48
-
48
+
49
49
  end
@@ -0,0 +1,19 @@
1
+ module OmniAuth
2
+ module Version
3
+ unless defined?(::OmniAuth::Version::MAJOR)
4
+ MAJOR = 0
5
+ end
6
+ unless defined?(::OmniAuth::Version::MINOR)
7
+ MINOR = 2
8
+ end
9
+ unless defined?(::OmniAuth::Version::PATCH)
10
+ PATCH = 5
11
+ end
12
+ unless defined?(::OmniAuth::Version::PRE)
13
+ PRE = nil
14
+ end
15
+ unless defined?(::OmniAuth::Version::STRING)
16
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
17
+ end
18
+ end
19
+ end
@@ -1,16 +1,18 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../../omniauth/lib/omniauth/version', __FILE__)
2
+ require File.expand_path('../lib/omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
+ gem.add_development_dependency 'maruku', '~> 0.6'
5
6
  gem.add_development_dependency 'simplecov', '~> 0.4'
6
7
  gem.add_development_dependency 'rack-test', '~> 0.5'
7
8
  gem.add_development_dependency 'rake', '~> 0.8'
8
9
  gem.add_development_dependency 'rspec', '~> 2.5'
9
10
  gem.add_development_dependency 'yard', '~> 0.6'
11
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
10
12
  gem.name = 'oa-core'
11
- gem.version = Omniauth::VERSION.dup
12
- gem.summary = %q{HTTP Basic strategies for OmniAuth.}
13
- gem.description = %q{HTTP Basic strategies for OmniAuth.}
13
+ gem.version = OmniAuth::Version::STRING
14
+ gem.description = %q{Core strategies for OmniAuth.}
15
+ gem.summary = gem.description
14
16
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
15
17
  gem.homepage = 'http://github.com/intridea/omniauth'
16
18
  gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth::Builder do
4
4
  describe '#provider' do
@@ -17,4 +17,4 @@ describe OmniAuth::Builder do
17
17
  end }.should_not raise_error
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe OmniAuth do
4
4
  describe '.strategies' do
@@ -9,45 +9,45 @@ describe OmniAuth do
9
9
  OmniAuth.strategies.last.should == ExampleStrategy
10
10
  end
11
11
  end
12
-
12
+
13
13
  context 'configuration' do
14
14
  it 'should be callable from .configure' do
15
15
  OmniAuth.configure do |c|
16
16
  c.should be_kind_of(OmniAuth::Configuration)
17
17
  end
18
18
  end
19
-
19
+
20
20
  before do
21
21
  @old_path_prefix = OmniAuth.config.path_prefix
22
22
  @old_on_failure = OmniAuth.config.on_failure
23
23
  end
24
-
24
+
25
25
  after do
26
26
  OmniAuth.configure do |config|
27
27
  config.path_prefix = @old_path_prefix
28
28
  config.on_failure = @old_on_failure
29
29
  end
30
30
  end
31
-
31
+
32
32
  it 'should be able to set the path' do
33
33
  OmniAuth.configure do |config|
34
34
  config.path_prefix = '/awesome'
35
35
  end
36
-
36
+
37
37
  OmniAuth.config.path_prefix.should == '/awesome'
38
38
  end
39
-
39
+
40
40
  it 'should be able to set the on_failure rack app' do
41
41
  OmniAuth.configure do |config|
42
42
  config.on_failure do
43
43
  'yoyo'
44
44
  end
45
45
  end
46
-
46
+
47
47
  OmniAuth.config.on_failure.call.should == 'yoyo'
48
48
  end
49
49
  end
50
-
50
+
51
51
  describe '::Utils' do
52
52
  describe '.deep_merge' do
53
53
  it 'should combine hashes' do
@@ -56,7 +56,7 @@ describe OmniAuth do
56
56
  }
57
57
  end
58
58
  end
59
-
59
+
60
60
  describe '.camelize' do
61
61
  it 'should work on normal cases' do
62
62
  {
@@ -66,7 +66,7 @@ describe OmniAuth do
66
66
  'three_words_now' => 'ThreeWordsNow'
67
67
  }.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v }
68
68
  end
69
-
69
+
70
70
  it 'should work in special cases' do
71
71
  {
72
72
  'oauth' => "OAuth",
@@ -76,4 +76,4 @@ describe OmniAuth do
76
76
  end
77
77
  end
78
78
  end
79
- end
79
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  class ExampleStrategy
4
4
  include OmniAuth::Strategy
@@ -6,14 +6,14 @@ class ExampleStrategy
6
6
  attr_reader :last_env
7
7
  def request_phase
8
8
  @fail = fail!(options[:failure]) if options[:failure]
9
- @last_env = env
10
- return @fail if @fail
9
+ @last_env = env
10
+ return @fail if @fail
11
11
  raise "Request Phase"
12
12
  end
13
13
  def callback_phase
14
14
  @fail = fail!(options[:failure]) if options[:failure]
15
15
  @last_env = env
16
- return @fail if @fail
16
+ return @fail if @fail
17
17
  raise "Callback Phase"
18
18
  end
19
19
  end
@@ -34,7 +34,7 @@ describe OmniAuth::Strategy do
34
34
  it 'should be the last argument if the last argument is a Hash' do
35
35
  ExampleStrategy.new(app, 'test', :abc => 123).options[:abc].should == 123
36
36
  end
37
-
37
+
38
38
  it 'should be a blank hash if none are provided' do
39
39
  ExampleStrategy.new(app, 'test').options.should == {}
40
40
  end
@@ -48,10 +48,10 @@ describe OmniAuth::Strategy do
48
48
  lambda{ strategy.full_host }.should_not raise_error
49
49
  end
50
50
  end
51
-
51
+
52
52
  describe '#call' do
53
53
  let(:strategy){ ExampleStrategy.new(app, 'test', @options) }
54
-
54
+
55
55
  context 'omniauth.origin' do
56
56
  it 'should be set on the request phase' do
57
57
  lambda{ strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin')) }.should raise_error("Request Phase")
@@ -98,13 +98,21 @@ describe OmniAuth::Strategy do
98
98
  it 'should use the default request path' do
99
99
  lambda{ strategy.call(make_env) }.should raise_error("Request Phase")
100
100
  end
101
-
101
+
102
+ it 'should be case insensitive on request path' do
103
+ lambda{ strategy.call(make_env('/AUTH/Test'))}.should raise_error("Request Phase")
104
+ end
105
+
106
+ it 'should be case insensitive on callback path' do
107
+ lambda{ strategy.call(make_env('/AUTH/TeSt/CaLlBAck'))}.should raise_error("Callback Phase")
108
+ end
109
+
102
110
  it 'should use the default callback path' do
103
111
  lambda{ strategy.call(make_env('/auth/test/callback')) }.should raise_error("Callback Phase")
104
112
  end
105
113
 
106
114
  it 'should strip trailing spaces on request' do
107
- lambda{ strategy.call(make_env('/auth/test/')) }.should raise_error("Request Phase")
115
+ lambda{ strategy.call(make_env('/auth/test/')) }.should raise_error("Request Phase")
108
116
  end
109
117
 
110
118
  it 'should strip trailing spaces on callback' do
@@ -137,11 +145,11 @@ describe OmniAuth::Strategy do
137
145
  end
138
146
  end
139
147
  end
140
-
141
- context 'pre-request call through' do
148
+
149
+ context 'pre-request call through' do
142
150
  subject { ExampleStrategy.new(app, 'test') }
143
151
  let(:app){ lambda{|env| env['omniauth.boom'] = true; [env['test.status'] || 404, {}, ['Whatev']] } }
144
- it 'should be able to modify the env on the fly before the request_phase' do
152
+ it 'should be able to modify the env on the fly before the request_phase' do
145
153
  lambda{ subject.call(make_env) }.should raise_error("Request Phase")
146
154
  subject.response.status.should == 404
147
155
  subject.last_env.should be_key('omniauth.boom')
@@ -152,13 +160,13 @@ describe OmniAuth::Strategy do
152
160
  subject.response.body.should == ['Whatev']
153
161
  end
154
162
  end
155
-
163
+
156
164
  context 'custom paths' do
157
165
  it 'should use a custom request_path if one is provided' do
158
166
  @options = {:request_path => '/awesome'}
159
167
  lambda{ strategy.call(make_env('/awesome')) }.should raise_error("Request Phase")
160
168
  end
161
-
169
+
162
170
  it 'should use a custom callback_path if one is provided' do
163
171
  @options = {:callback_path => '/radical'}
164
172
  lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase")
@@ -184,16 +192,16 @@ describe OmniAuth::Strategy do
184
192
  end
185
193
  end
186
194
  end
187
-
195
+
188
196
  context 'custom prefix' do
189
197
  before do
190
198
  @options = {:path_prefix => '/wowzers'}
191
199
  end
192
-
200
+
193
201
  it 'should use a custom prefix for request' do
194
202
  lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase")
195
203
  end
196
-
204
+
197
205
  it 'should use a custom prefix for callback' do
198
206
  lambda{ strategy.call(make_env('/wowzers/test/callback')) }.should raise_error("Callback Phase")
199
207
  end
@@ -216,22 +224,22 @@ describe OmniAuth::Strategy do
216
224
  end
217
225
  end
218
226
  end
219
-
227
+
220
228
  context 'request method restriction' do
221
229
  before do
222
230
  OmniAuth.config.allowed_request_methods = [:post]
223
231
  end
224
-
232
+
225
233
  it 'should not allow a request method of the wrong type' do
226
234
  lambda{ strategy.call(make_env)}.should_not raise_error
227
235
  end
228
-
236
+
229
237
  it 'should allow a request method of the correct type' do
230
238
  lambda{ strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'POST'))}.should raise_error("Request Phase")
231
239
  end
232
-
240
+
233
241
  after do
234
- OmniAuth.config.allowed_request_methods = [:get, :post]
242
+ OmniAuth.config.allowed_request_methods = [:get, :post]
235
243
  end
236
244
  end
237
245
 
@@ -246,6 +254,14 @@ describe OmniAuth::Strategy do
246
254
  response[1]['Location'].should == '/auth/test/callback'
247
255
  end
248
256
 
257
+ it 'should be case insensitive on request path' do
258
+ strategy.call(make_env('/AUTH/Test'))[0].should == 302
259
+ end
260
+
261
+ it 'should be case insensitive on callback path' do
262
+ strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
263
+ end
264
+
249
265
  it 'should not short circuit requests outside of authentication' do
250
266
  strategy.call(make_env('/')).should == app.call(make_env('/'))
251
267
  end
@@ -270,12 +286,12 @@ describe OmniAuth::Strategy do
270
286
  strategy.call make_env('/auth/test/callback')
271
287
  strategy.env['omniauth.error.type'].should == :invalid_credentials
272
288
  end
273
-
289
+
274
290
  it 'should set omniauth.origin on the request phase' do
275
291
  strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin'))
276
292
  strategy.env['rack.session']['omniauth.origin'].should == 'http://example.com/origin'
277
293
  end
278
-
294
+
279
295
  it 'should set omniauth.origin from the params if provided' do
280
296
  strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo'))
281
297
  strategy.env['rack.session']['omniauth.origin'].should == '/foo'
@@ -283,7 +299,7 @@ describe OmniAuth::Strategy do
283
299
 
284
300
  it 'should turn omniauth.origin into an env variable on the callback phase' do
285
301
  OmniAuth.config.mock_auth[:test] = {}
286
-
302
+
287
303
  strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'}))
288
304
  strategy.env['omniauth.origin'].should == 'http://example.com/origin'
289
305
  end
@@ -305,7 +321,7 @@ describe OmniAuth::Strategy do
305
321
 
306
322
  context 'setup phase' do
307
323
  context 'when options[:setup] = true' do
308
- let(:strategy){ ExampleStrategy.new(app, 'test', :setup => true) }
324
+ let(:strategy){ ExampleStrategy.new(app, 'test', :setup => true) }
309
325
  let(:app){lambda{|env| env['omniauth.strategy'].options[:awesome] = 'sauce' if env['PATH_INFO'] == '/auth/test/setup'; [404, {}, 'Awesome'] }}
310
326
 
311
327
  it 'should call through to /auth/:provider/setup' do
@@ -327,7 +343,7 @@ describe OmniAuth::Strategy do
327
343
  end
328
344
 
329
345
  let(:strategy){ ExampleStrategy.new(app, 'test', :setup => setup_proc) }
330
-
346
+
331
347
  it 'should not call the app on a non-omniauth endpoint' do
332
348
  strategy.call(make_env('/somehwere/else'))
333
349
  strategy.options[:awesome].should_not == 'sauce'
@@ -335,7 +351,7 @@ describe OmniAuth::Strategy do
335
351
 
336
352
  it 'should call the rack app' do
337
353
  strategy.call(make_env('/auth/test'))
338
- strategy.options[:awesome].should == 'sauce'
354
+ strategy.options[:awesome].should == 'sauce'
339
355
  end
340
356
  end
341
357
  end
@@ -1,10 +1,6 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start
3
- require 'rubygems'
4
- require 'bundler'
5
- Bundler.setup
6
3
  require 'rspec'
7
- require 'rspec/autorun'
8
4
  require 'rack/test'
9
5
  require 'omniauth/core'
10
6
  require 'omniauth/test'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Bleigh
@@ -11,64 +11,86 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-22 00:00:00 Z
14
+ date: 2011-04-29 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: simplecov
17
+ name: maruku
18
18
  prerelease: false
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: "0.4"
24
+ version: "0.6"
25
25
  type: :development
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: rack-test
28
+ name: simplecov
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
34
34
  - !ruby/object:Gem::Version
35
- version: "0.5"
35
+ version: "0.4"
36
36
  type: :development
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
- name: rake
39
+ name: rack-test
40
40
  prerelease: false
41
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: "0.8"
46
+ version: "0.5"
47
47
  type: :development
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: rspec
50
+ name: rake
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- version: "2.5"
57
+ version: "0.8"
58
58
  type: :development
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: yard
61
+ name: rspec
62
62
  prerelease: false
63
63
  requirement: &id005 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: "0.6"
68
+ version: "2.5"
69
69
  type: :development
70
70
  version_requirements: *id005
71
- description: HTTP Basic strategies for OmniAuth.
71
+ - !ruby/object:Gem::Dependency
72
+ name: yard
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "0.6"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: ZenTest
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "4.5"
91
+ type: :development
92
+ version_requirements: *id007
93
+ description: Core strategies for OmniAuth.
72
94
  email:
73
95
  - michael@intridea.com
74
96
  - sferik@gmail.com
@@ -82,7 +104,6 @@ files:
82
104
  - .gemtest
83
105
  - .rspec
84
106
  - .yardopts
85
- - Gemfile
86
107
  - LICENSE
87
108
  - Rakefile
88
109
  - autotest/discover.rb
@@ -95,6 +116,7 @@ files:
95
116
  - lib/omniauth/test/phony_session.rb
96
117
  - lib/omniauth/test/strategy_macros.rb
97
118
  - lib/omniauth/test/strategy_test_case.rb
119
+ - lib/omniauth/version.rb
98
120
  - oa-core.gemspec
99
121
  - spec/omniauth/builder_spec.rb
100
122
  - spec/omniauth/core_spec.rb
@@ -126,7 +148,7 @@ rubyforge_project:
126
148
  rubygems_version: 1.7.2
127
149
  signing_key:
128
150
  specification_version: 3
129
- summary: HTTP Basic strategies for OmniAuth.
151
+ summary: Core strategies for OmniAuth.
130
152
  test_files:
131
153
  - spec/omniauth/builder_spec.rb
132
154
  - spec/omniauth/core_spec.rb
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec