oa-cadun 3.1.4 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
  module OACadun
2
2
  module VERSION
3
3
  MAJOR = 3
4
- MINOR = 1
5
- TINY = 4
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY] * '.'
8
8
  end
@@ -18,6 +18,14 @@ module OmniAuth
18
18
  redirect "#{Config.login_url}/#{service_id}?url=#{callback_url}"
19
19
  end
20
20
 
21
+ def callback_phase
22
+ begin
23
+ super
24
+ rescue => e
25
+ fail!(:invalid_credentials, e)
26
+ end
27
+ end
28
+
21
29
  def auth_hash
22
30
  self.class.build_auth_hash(user, request)
23
31
  end
data/oa-cadun.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.require_paths = %w(lib)
17
17
 
18
18
  s.add_dependency 'oa-core'
19
- s.add_dependency 'cadun', '0.2.4'
19
+ s.add_dependency 'cadun', '0.3.0'
20
20
  s.add_development_dependency 'rack'
21
21
  s.add_development_dependency 'rspec'
22
22
  s.add_development_dependency 'rr'
@@ -44,6 +44,34 @@ describe OmniAuth::Strategies::Cadun do
44
44
  end
45
45
  end
46
46
 
47
+ describe "#callback_phase" do
48
+ context "when the authorization fails" do
49
+ before do
50
+ FakeWeb.register_uri :put, "http://isp-authenticator.dev.globoi.com:8280/ws/rest/autorizacao",
51
+ :body => nil
52
+
53
+ strategy.call! Rack::MockRequest.env_for("http://localhost/auth/cadun/callback", "rack.session" => {})
54
+ end
55
+
56
+ subject { strategy.callback_phase }
57
+
58
+ specify { strategy.env['omniauth.auth'].should be_nil }
59
+ specify { strategy.env['omniauth.error.type'].should == :invalid_credentials }
60
+ end
61
+
62
+ context "when the authorization succeeds" do
63
+ before do
64
+ stub_requests
65
+ strategy.call! Rack::MockRequest.env_for("http://localhost/auth/cadun/callback", "rack.session" => {})
66
+ end
67
+
68
+ subject { strategy.callback_phase }
69
+
70
+ specify { strategy.env['omniauth.auth'].should_not be_nil }
71
+ specify { strategy.env['omniauth.error.type'].should be_nil }
72
+ end
73
+ end
74
+
47
75
  describe "#auth_hash" do
48
76
  before do
49
77
  stub_requests
@@ -69,7 +97,7 @@ describe OmniAuth::Strategies::Cadun do
69
97
  specify { subject[:user_info].should include(:email => "fab1@spam.la") }
70
98
  specify { subject[:user_info].should include(:gender => "MASCULINO") }
71
99
  specify { subject[:user_info].should include(:GLBID => "GLBID") }
72
- specify { subject[:user_info].should include(:user_id => "21737810") }
100
+ specify { subject[:user_info].should include(:cadun_id => "21737810") }
73
101
  specify { subject[:user_info].should include(:mobile => "21 99999999") }
74
102
  specify { subject[:user_info].should include(:name => "Fabricio Rodrigo Lopes") }
75
103
  specify { subject[:user_info].should include(:neighborhood => "Andaraí") }
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'rack/mock'
4
4
 
5
5
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
6
 
7
- RSpec.configure do |config|
7
+ RSpec.configure do |config|
8
8
  config.before :suite do
9
9
  FakeWeb.allow_net_connect = false
10
10
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-cadun
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.1.4
5
+ version: 3.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bruno
@@ -12,8 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-05-27 00:00:00 -03:00
16
- default_executable:
15
+ date: 2011-05-30 00:00:00 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
18
  name: oa-core
@@ -34,7 +33,7 @@ dependencies:
34
33
  requirements:
35
34
  - - "="
36
35
  - !ruby/object:Gem::Version
37
- version: 0.2.4
36
+ version: 0.3.0
38
37
  type: :runtime
39
38
  version_requirements: *id002
40
39
  - !ruby/object:Gem::Dependency
@@ -107,7 +106,6 @@ files:
107
106
  - spec/support/fixtures/autorizacao.xml
108
107
  - spec/support/fixtures/config.yml
109
108
  - spec/support/fixtures/pessoa.xml
110
- has_rdoc: true
111
109
  homepage: https://github.com/azisaka/oa-cadun
112
110
  licenses: []
113
111
 
@@ -131,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
129
  requirements: []
132
130
 
133
131
  rubyforge_project:
134
- rubygems_version: 1.6.2
132
+ rubygems_version: 1.8.4
135
133
  signing_key:
136
134
  specification_version: 3
137
135
  summary: OmniAuth strategy for CadUn