omniauth-remote-user 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/omniauth-remote-user/version.rb +1 -1
- data/omniauth-remote-user.gemspec +1 -1
- data/spec/omniauth/strategies/remote_user_spec.rb +125 -0
- data/spec/spec_helper.rb +26 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd7c0c67a089fb6fa483ae0435e979cab1a4d38
|
4
|
+
data.tar.gz: a5a95d58c6692c0864e7ab732fd872b9203b1ad0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82013bb49295bc35dd7acead92634f6f2dbebbd60b686c6e2c5a61aa22e125e1710de84fe892d5bb4f3c7b4b9f9cb064983dd8f8fcddd63df9a198aa08e72afd
|
7
|
+
data.tar.gz: e91d77b0d6e9bc660585da0596f64a483cbc57152cc328b8e3710a986ae1a920528c25c1a20dec38df68599ccccdbfde1b2df9d4a793ab82f4b51c4e295eb3b5
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.homepage = 'http://beta.softwarepublico.gov.br/gitlab/softwarepublico/omniauth-remote-user'
|
11
11
|
gem.authors = ['Lucas Kanashiro', 'Thiago Ribeiro', 'Rodrigo Siqueira','Macartur Sousa', 'Antonio Terceiro']
|
12
12
|
gem.require_paths = %w(lib)
|
13
|
-
gem.files = `git ls-files -z`.split("\x0")
|
13
|
+
gem.files = `git ls-files -z`.split("\x0")
|
14
14
|
gem.test_files = `git ls-files -- {test,spec,feature}/*`.split("\n")
|
15
15
|
gem.license = "Expat"
|
16
16
|
gem.required_rubygems_version = '>= 1.3.5'
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Test Strategy Remote_User' do
|
4
|
+
let(:app) do
|
5
|
+
Rack::Builder.new do |b|
|
6
|
+
b.use Rack::Session::Cookie, :secret => 'abc123'
|
7
|
+
b.use OmniAuth::Strategies::RemoteUser
|
8
|
+
b.run lambda { |_env| [200, {}, ['My body']] }
|
9
|
+
end.to_app
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'Without HTTP_REMOTE_USER and not logged in' do
|
13
|
+
before(:each){
|
14
|
+
get '/', {}, {}
|
15
|
+
}
|
16
|
+
|
17
|
+
it 'Do nothing' do
|
18
|
+
expect(last_response.status).to eq(200)
|
19
|
+
expect(last_request.cookies['_remote_user']).to eq(nil)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'Without HTTP_REMOTE_USER and logged in' do
|
24
|
+
before(:each){
|
25
|
+
clear_cookies
|
26
|
+
set_cookie "_remote_user=test"
|
27
|
+
get '/', {}, {}
|
28
|
+
}
|
29
|
+
|
30
|
+
it 'Logout curreent user' do
|
31
|
+
expect(last_request.cookies['_remote_user']).to eq('test')
|
32
|
+
expect(last_response.status).to eq(302)
|
33
|
+
expect(last_response['Set-Cookie']).to include("_remote_user=")
|
34
|
+
expect(last_response['Set-Cookie']).to include("path=")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'With HTTP_REMOTE_USER and not logged in' do
|
39
|
+
before(:each){
|
40
|
+
get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' }
|
41
|
+
}
|
42
|
+
|
43
|
+
it 'logs HTTP_REMOTE_USER in' do
|
44
|
+
expect(last_response.status).to eq(302)
|
45
|
+
expect(last_response['Set-Cookie']).to include('_remote_user=foobar')
|
46
|
+
expect(last_response['Set-Cookie']).to include('path=')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'With HTTP_REMOTE_USER, logged in and current user equals HTTP_REMOTE_USER' do
|
51
|
+
before(:each){
|
52
|
+
clear_cookies
|
53
|
+
set_cookie "_remote_user=foobar"
|
54
|
+
get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' }
|
55
|
+
}
|
56
|
+
|
57
|
+
it 'Do nothing' do
|
58
|
+
expect(last_request.cookies['_remote_user']).to eq('foobar')
|
59
|
+
expect(last_response.status).to eq(200)
|
60
|
+
expect(last_response['Set-Cookie']).to eq(nil)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'With HTTP_REMOTE_USER, logged in and current user not equals HTTP_REMOTE_USER' do
|
65
|
+
before(:each){
|
66
|
+
clear_cookies
|
67
|
+
set_cookie "_remote_user=foobar"
|
68
|
+
get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar2' }
|
69
|
+
}
|
70
|
+
|
71
|
+
it 'Logout current user and login HTTP_REMOTE_USER' do
|
72
|
+
expect(last_request.cookies['_remote_user']).to eq('foobar')
|
73
|
+
expect(last_response.status).to eq(302)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'Verify omniauth hash with HTTP_REMOTE_USER_DATA' do
|
78
|
+
before(:each){
|
79
|
+
clear_cookies
|
80
|
+
set_cookie "_remote_user=foobar"
|
81
|
+
post '/auth/RemoteUser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar',
|
82
|
+
'HTTP_REMOTE_USER_DATA' => JSON.dump({'name' => 'foobar barfoo', 'email' => 'foobar@test.com'})}
|
83
|
+
}
|
84
|
+
|
85
|
+
it 'Verify uid' do
|
86
|
+
expect(last_request.env['omniauth.auth']['uid']).to eq('foobar')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'Verify info' do
|
90
|
+
expect(last_request.env['omniauth.auth']['info']['nickname']).to eq('foobar')
|
91
|
+
expect(last_request.env['omniauth.auth']['info']['email']).to eq('foobar@test.com')
|
92
|
+
expect(last_request.env['omniauth.auth']['info']['lastname']).to eq('barfoo')
|
93
|
+
expect(last_request.env['omniauth.auth']['info']['firstname']).to eq('foobar')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'Verify omniauth.auth info without HTTP_REMOTE_USER_DATA' do
|
98
|
+
before(:each){
|
99
|
+
clear_cookies
|
100
|
+
set_cookie "_remote_user=foobar"
|
101
|
+
post '/auth/RemoteUser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar' }
|
102
|
+
}
|
103
|
+
|
104
|
+
it 'Verify uid' do
|
105
|
+
expect(last_request.env['omniauth.auth']['uid']).to eq('foobar')
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'Verify info' do
|
109
|
+
expect(last_request.env['omniauth.auth']['info']).to eq({})
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'With HTTP_REMOTE_USER and ' do
|
114
|
+
before(:each){
|
115
|
+
set_cookie "_remote_user=foobar"
|
116
|
+
get "auth/RemoteUser", {}, { 'HTTP_REMOTE_USER' => 'foobar' }
|
117
|
+
}
|
118
|
+
|
119
|
+
it 'redirect for callback' do
|
120
|
+
expect(last_response.status).to eq(302)
|
121
|
+
expect(last_response.location).to eq("/auth/RemoteUser/callback")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
if RUBY_VERSION >= '1.9'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '/spec'
|
7
|
+
#minimum_coverage(90)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
require 'rubygems'
|
11
|
+
require 'bundler'
|
12
|
+
require 'rack/test'
|
13
|
+
require 'rspec'
|
14
|
+
require 'rack/test'
|
15
|
+
require 'omniauth'
|
16
|
+
require 'omniauth/test'
|
17
|
+
|
18
|
+
Bundler.setup :default, :development, :test
|
19
|
+
|
20
|
+
require 'rack/test'
|
21
|
+
require 'omniauth/remote-user'
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include Rack::Test::Methods
|
25
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-remote-user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Kanashiro
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: omniauth
|
@@ -52,6 +52,8 @@ files:
|
|
52
52
|
- lib/omniauth/strategies/remote_user.rb
|
53
53
|
- omniauth-remote-user.gemspec
|
54
54
|
- references/teste.rb
|
55
|
+
- spec/omniauth/strategies/remote_user_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
55
57
|
- test_notes.txt
|
56
58
|
homepage: http://beta.softwarepublico.gov.br/gitlab/softwarepublico/omniauth-remote-user
|
57
59
|
licenses:
|
@@ -73,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
75
|
version: 1.3.5
|
74
76
|
requirements: []
|
75
77
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.5.1
|
77
79
|
signing_key:
|
78
80
|
specification_version: 4
|
79
81
|
summary: Authentication with HTTP Remote User
|
80
82
|
test_files: []
|
81
|
-
has_rdoc:
|