oa-globocom 0.2.0 → 0.4.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,8 +1,8 @@
1
1
  module OAGloboCom
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 0
4
+ MINOR = 4
5
+ PATCH = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH] * '.'
8
8
  end
data/lib/oa-globocom.rb CHANGED
@@ -1,5 +1 @@
1
- $:.push File.expand_path('lib', __FILE__)
2
-
3
- require 'oa-core'
4
- require 'globocom-auth'
5
- require 'omni_auth/strategies/globocom'
1
+ require File.dirname(__FILE__) + '/omni_auth/strategies/globocom'
@@ -1,6 +1,7 @@
1
- require 'globocom-auth/config'
2
- require 'globocom-auth/user'
3
- require 'globocom-auth/gateway'
1
+ require 'rubygems'
2
+ require 'oa-core'
3
+ require 'cadun'
4
+ require 'cadun/config'
4
5
 
5
6
  module OmniAuth
6
7
  module Strategies
@@ -8,20 +9,20 @@ module OmniAuth
8
9
  include OmniAuth::Strategy
9
10
 
10
11
  def initialize(app, options = {})
11
- GloboComAuth::Config.load_file(options[:config])
12
+ Cadun::Config.load_file(options[:config])
12
13
 
13
- super(app, :globocom, options)
14
+ super(app, :cadun, options)
14
15
  end
15
16
 
16
17
  def request_phase
17
- redirect "#{GloboComAuth::Config.login_url}/#{service_id}?url=#{callback_url}"
18
+ redirect "#{Cadun::Config.login_url}/#{service_id}?url=#{callback_url}"
18
19
  end
19
20
 
20
21
  def callback_phase
21
22
  begin
22
23
  super
23
24
  rescue => e
24
- fail!(:invalid_credentials, e)
25
+ fail!(e.message, e.message)
25
26
  end
26
27
  end
27
28
 
@@ -30,7 +31,7 @@ module OmniAuth
30
31
  end
31
32
 
32
33
  def user
33
- @user ||= GloboComAuth::User.new(:glb_id => request.params['GLBID'], :ip => client_ip, :service_id => service_id)
34
+ @user ||= Cadun::User.new(:glb_id => request.params['GLBID'], :ip => client_ip, :service_id => service_id)
34
35
  end
35
36
 
36
37
  def service_id
@@ -55,7 +56,7 @@ module OmniAuth
55
56
  end
56
57
 
57
58
  def self.build_auth_hash(user, request = nil)
58
- hash = { :provider => "globocom", :uid => user.id, :user_info => user.to_hash.merge(:birthday => user.birthday.strftime('%d/%m/%Y')) }
59
+ hash = { :provider => "cadun", :uid => user.id, :user_info => user.to_hash.merge(:birthday => user.birthday.strftime('%d/%m/%Y')) }
59
60
  hash[:user_info].merge!(:GLBID => request.params['GLBID'], :url => request.params['url']) if request
60
61
 
61
62
  hash
data/oa-globocom.gemspec CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
16
16
  s.require_paths = %w(lib)
17
17
 
18
- s.add_dependency 'oa-core'
19
- s.add_dependency 'globocom-auth', '0.1.0'
18
+ s.add_dependency 'oa-core', '~> 0.2.6'
19
+ s.add_dependency 'cadun', '~> 0.5.3'
20
20
  s.add_development_dependency 'rack'
21
+ s.add_development_dependency 'rake'
21
22
  s.add_development_dependency 'rspec'
22
23
  s.add_development_dependency 'rr'
23
24
  s.add_development_dependency 'fakeweb'
@@ -9,7 +9,7 @@ describe OmniAuth::Strategies::GloboCom do
9
9
  describe "#request_phase" do
10
10
  context "when it has a referer" do
11
11
  before do
12
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, "HTTP_HOST" => "test.localhost")
12
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, "HTTP_HOST" => "test.localhost")
13
13
 
14
14
  @status, @headers, @body = strategy.request_phase
15
15
  end
@@ -19,13 +19,13 @@ describe OmniAuth::Strategies::GloboCom do
19
19
  end
20
20
 
21
21
  describe "headers" do
22
- it { @headers.should include("Location" => "https://login.dev.globoi.com/login/1?url=http%3A%2F%2Ftest.localhost%2Fauth%2Fglobocom%2Fcallback") }
22
+ it { @headers.should include("Location" => "https://login.dev.globoi.com/login/1?url=http%3A%2F%2Ftest.localhost%2Fauth%2Fcadun%2Fcallback") }
23
23
  end
24
24
  end
25
25
 
26
26
  context "when it has a referer and a different port" do
27
27
  before do
28
- strategy.call!(Rack::MockRequest.env_for("http://test.localhost:8080/auth/globocom", "rack.session" => {}, "HTTP_HOST" => "test.localhost", "SERVER_PORT" => "8080"))
28
+ strategy.call!(Rack::MockRequest.env_for("http://test.localhost:8080/auth/cadun", "rack.session" => {}, "HTTP_HOST" => "test.localhost", "SERVER_PORT" => "8080"))
29
29
 
30
30
  @status, @headers, @body = strategy.request_phase
31
31
  end
@@ -35,7 +35,7 @@ describe OmniAuth::Strategies::GloboCom do
35
35
  end
36
36
 
37
37
  describe "headers" do
38
- it { @headers.should include("Location" => "https://login.dev.globoi.com/login/1?url=http%3A%2F%2Ftest.localhost%3A8080%2Fauth%2Fglobocom%2Fcallback") }
38
+ it { @headers.should include("Location" => "https://login.dev.globoi.com/login/1?url=http%3A%2F%2Ftest.localhost%3A8080%2Fauth%2Fcadun%2Fcallback") }
39
39
  end
40
40
  end
41
41
  end
@@ -44,18 +44,18 @@ describe OmniAuth::Strategies::GloboCom do
44
44
  context "when the authorization fails" do
45
45
  before do
46
46
  stub_fail_requests
47
- strategy.call! Rack::MockRequest.env_for("http://localhost/auth/globocom/callback?GLBID=GLBID", "rack.session" => {}, "REMOTE_ADDR" => "127.0.0.1")
47
+ strategy.call! Rack::MockRequest.env_for("http://localhost/auth/cadun/callback?GLBID=GLBID", "rack.session" => {}, "REMOTE_ADDR" => "127.0.0.1")
48
48
  end
49
49
 
50
50
  it { strategy.env['omniauth.auth'].should be_nil }
51
- it { strategy.env['omniauth.error'].message.should == "not authorized" }
52
- it { strategy.env['omniauth.error.type'].should == :invalid_credentials }
51
+ it { strategy.env['omniauth.error'].should == "not authorized" }
52
+ it { strategy.env['omniauth.error.type'].should == :"not authorized" }
53
53
  end
54
54
 
55
55
  context "when the authorization succeeds" do
56
56
  before do
57
57
  stub_requests
58
- strategy.call! Rack::MockRequest.env_for("http://localhost/auth/globocom/callback?GLBID=GLBID", "rack.session" => {}, "REMOTE_ADDR" => "127.0.0.1")
58
+ strategy.call! Rack::MockRequest.env_for("http://localhost/auth/cadun/callback?GLBID=GLBID", "rack.session" => {}, "REMOTE_ADDR" => "127.0.0.1")
59
59
  end
60
60
 
61
61
  it { strategy.env['omniauth.auth'].should_not be_nil }
@@ -75,7 +75,7 @@ describe OmniAuth::Strategies::GloboCom do
75
75
  end
76
76
 
77
77
  describe ":provider" do
78
- it { strategy.auth_hash[:provider].should == "globocom" }
78
+ it { strategy.auth_hash[:provider].should == "cadun" }
79
79
  end
80
80
 
81
81
  describe ":user_info" do
@@ -106,27 +106,27 @@ describe OmniAuth::Strategies::GloboCom do
106
106
 
107
107
  describe "#client_ip" do
108
108
  it 'should return ip from REMOTE_ADDR when it comes alone' do
109
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.15')
109
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.15')
110
110
  strategy.client_ip.should == '200.201.0.15'
111
111
  end
112
112
 
113
113
  it 'should return ip from REMOTE_ADDR when HTTP_X_FORWARDED_FOR is empty' do
114
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.20', 'HTTP_X_FORWARDED_FOR' => '')
114
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.20', 'HTTP_X_FORWARDED_FOR' => '')
115
115
  strategy.client_ip.should == '200.201.0.20'
116
116
  end
117
117
 
118
118
  it 'should return ip from HTTP_X_FORWARDED_FOR when it comes alone' do
119
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, 'HTTP_X_FORWARDED_FOR' => '201.10.0.15')
119
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, 'HTTP_X_FORWARDED_FOR' => '201.10.0.15')
120
120
  strategy.client_ip.should == '201.10.0.15'
121
121
  end
122
122
 
123
123
  it 'should return ip from HTTP_X_FORWARDED_FOR even if REMOTE_ADDR is present' do
124
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.15', 'HTTP_X_FORWARDED_FOR' => '201.10.0.16')
124
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, 'REMOTE_ADDR' => '200.201.0.15', 'HTTP_X_FORWARDED_FOR' => '201.10.0.16')
125
125
  strategy.client_ip.should == '201.10.0.16'
126
126
  end
127
127
 
128
128
  it 'should always return the last ip from HTTP_X_FORWARDED_FOR' do
129
- strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/globocom", "rack.session" => {}, 'HTTP_X_FORWARDED_FOR' => '201.10.0.15, 201.10.0.16, 201.10.0.17')
129
+ strategy.call! Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, 'HTTP_X_FORWARDED_FOR' => '201.10.0.15, 201.10.0.16, 201.10.0.17')
130
130
  strategy.client_ip.should == '201.10.0.17'
131
131
  end
132
132
  end
data/spec/spec_helper.rb CHANGED
@@ -5,31 +5,21 @@ require 'rack/mock'
5
5
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
6
 
7
7
  RSpec.configure do |config|
8
- config.before :suite do
9
- FakeWeb.allow_net_connect = false
10
- end
11
-
12
- config.before :each do
13
- FakeWeb.clean_registry
14
- end
15
-
16
8
  config.mock_with :rr
17
9
  config.filter_run :focus => true
18
10
  config.run_all_when_everything_filtered = true
11
+
12
+ config.before(:suite) do
13
+ FakeWeb.allow_net_connect = false
14
+ end
19
15
  end
20
16
 
21
17
  def stub_requests
22
- FakeWeb.register_uri :put, "http://isp-authenticator.dev.globoi.com:8280/ws/rest/autorizacao",
23
- :body => File.join(File.dirname(__FILE__), "support", "fixtures", "autorizacao.xml")
24
-
25
- FakeWeb.register_uri :get, "http://isp-authenticator.dev.globoi.com:8280/cadunii/ws/resources/pessoa/21737810",
26
- :body => File.join(File.dirname(__FILE__), "support", "fixtures", "pessoa.xml")
18
+ FakeWeb.register_uri(:put, "http://isp-authenticator.dev.globoi.com:8280/ws/rest/autorizacao", :body => "#{File.dirname(__FILE__)}/support/fixtures/autorizacao.xml")
19
+ FakeWeb.register_uri(:get, "http://isp-authenticator.dev.globoi.com:8280/cadunii/ws/resources/pessoa/21737810", :body => "#{File.dirname(__FILE__)}/support/fixtures/pessoa.xml")
27
20
  end
28
21
 
29
22
  def stub_fail_requests
30
- FakeWeb.register_uri :put, "http://isp-authenticator.dev.globoi.com:8280/ws/rest/autorizacao",
31
- :body => File.join(File.dirname(__FILE__), "support", "fixtures", "autorizacao_fail.xml")
32
-
33
- FakeWeb.register_uri :get, "http://isp-authenticator.dev.globoi.com:8280/cadunii/ws/resources/pessoa/21737810",
34
- :body => File.join(File.dirname(__FILE__), "support", "fixtures", "pessoa.xml")
23
+ FakeWeb.register_uri(:put, "http://isp-authenticator.dev.globoi.com:8280/ws/rest/autorizacao", :body => "#{File.dirname(__FILE__)}/support/fixtures/autorizacao_fail.xml")
24
+ FakeWeb.register_uri(:get, "http://isp-authenticator.dev.globoi.com:8280/cadunii/ws/resources/pessoa/21737810", :body => "#{File.dirname(__FILE__)}/support/fixtures/pessoa.xml")
35
25
  end
@@ -1,5 +1,4 @@
1
1
  cadun:
2
2
  logout_url: https://login.dev.globoi.com/Servlet/do/logout
3
3
  login_url: https://login.dev.globoi.com/login
4
- auth_url: isp-authenticator.dev.globoi.com
5
- auth_port: 8280
4
+ auth_url: http://isp-authenticator.dev.globoi.com:8280
metadata CHANGED
@@ -1,95 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: oa-globocom
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.5
4
5
  prerelease:
5
- version: 0.2.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Bruno
9
9
  - Azisaka
10
10
  - Maciel
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-06-08 00:00:00 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
14
+ date: 2011-07-27 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
18
17
  name: oa-core
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &2161634800 !ruby/object:Gem::Requirement
21
19
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.6
26
24
  type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: globocom-auth
30
25
  prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: *2161634800
27
+ - !ruby/object:Gem::Dependency
28
+ name: cadun
29
+ requirement: &2161634300 !ruby/object:Gem::Requirement
32
30
  none: false
33
- requirements:
34
- - - "="
35
- - !ruby/object:Gem::Version
36
- version: 0.1.0
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.5.3
37
35
  type: :runtime
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ version_requirements: *2161634300
38
+ - !ruby/object:Gem::Dependency
40
39
  name: rack
40
+ requirement: &2161633920 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ type: :development
41
47
  prerelease: false
42
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ version_requirements: *2161633920
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: &2161633460 !ruby/object:Gem::Requirement
43
52
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
48
57
  type: :development
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
51
- name: rspec
52
58
  prerelease: false
53
- requirement: &id004 !ruby/object:Gem::Requirement
59
+ version_requirements: *2161633460
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ requirement: &2161633040 !ruby/object:Gem::Requirement
54
63
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
59
68
  type: :development
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
62
- name: rr
63
69
  prerelease: false
64
- requirement: &id005 !ruby/object:Gem::Requirement
70
+ version_requirements: *2161633040
71
+ - !ruby/object:Gem::Dependency
72
+ name: rr
73
+ requirement: &2161632620 !ruby/object:Gem::Requirement
65
74
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
70
79
  type: :development
71
- version_requirements: *id005
72
- - !ruby/object:Gem::Dependency
73
- name: fakeweb
74
80
  prerelease: false
75
- requirement: &id006 !ruby/object:Gem::Requirement
81
+ version_requirements: *2161632620
82
+ - !ruby/object:Gem::Dependency
83
+ name: fakeweb
84
+ requirement: &2161632200 !ruby/object:Gem::Requirement
76
85
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: "0"
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
81
90
  type: :development
82
- version_requirements: *id006
83
- description: The goal of this gem is to allow the developer to use ContaGlobo.com (a login webservice made by Globo.com) in any web app using OmniAuth
84
- email:
91
+ prerelease: false
92
+ version_requirements: *2161632200
93
+ description: The goal of this gem is to allow the developer to use ContaGlobo.com
94
+ (a login webservice made by Globo.com) in any web app using OmniAuth
95
+ email:
85
96
  - bruno@azisaka.com.br
86
97
  executables: []
87
-
88
98
  extensions: []
89
-
90
99
  extra_rdoc_files: []
91
-
92
- files:
100
+ files:
93
101
  - .gitignore
94
102
  - .rspec
95
103
  - .rvmrc
@@ -109,30 +117,26 @@ files:
109
117
  - spec/support/fixtures/pessoa.xml
110
118
  homepage: https://github.com/azisaka/oa-globocom
111
119
  licenses: []
112
-
113
120
  post_install_message:
114
121
  rdoc_options: []
115
-
116
- require_paths:
122
+ require_paths:
117
123
  - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
124
+ required_ruby_version: !ruby/object:Gem::Requirement
119
125
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
124
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
131
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: "0"
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
130
136
  requirements: []
131
-
132
137
  rubyforge_project:
133
- rubygems_version: 1.8.4
138
+ rubygems_version: 1.8.6
134
139
  signing_key:
135
140
  specification_version: 3
136
141
  summary: OmniAuth strategy for Globo.com authentication system
137
142
  test_files: []
138
-