rails_sso 0.7.0 → 0.7.1
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/README.md +20 -6
- data/app/controllers/rails_sso/sessions_controller.rb +1 -1
- data/app/services/rails_sso/fetch_user.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/rails_sso.rb +5 -48
- data/lib/rails_sso/app.rb +16 -6
- data/lib/rails_sso/client.rb +3 -3
- data/lib/rails_sso/configuration.rb +61 -0
- data/lib/rails_sso/engine.rb +11 -11
- data/lib/rails_sso/sso_strategy.rb +1 -1
- data/lib/rails_sso/token_mock.rb +9 -1
- data/lib/rails_sso/version.rb +1 -1
- data/test/dummy/log/test.log +102 -0
- data/test/lib/rails_sso/configuration_test.rb +11 -0
- data/test/lib/rails_sso/sso_strategy_test.rb +4 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 170c6345095e886214afff31d808cdbbba60d2c0
|
4
|
+
data.tar.gz: 3647503ec6439121f4a86b6279c191add1d55d69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb0ff27da239e77ef5918f73af3d43be096280bf2eaa0d94208f758099ec37854cd014778f18929fefd6af9a04f2d44ff10e78a0fe812613be379d53b0836776
|
7
|
+
data.tar.gz: 39c3f78d9edb3d289e8dad0b365df98cc9fb51b2423b2704f82fd3f5c8b30dbdf72e48c417beec21c31f1161df433112927aa2c2f7628f43c2e9bcf7f0f18eea
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ RailsSso.configure do |config|
|
|
53
53
|
# test & development mode
|
54
54
|
config.test_mode = ENV['mock_sso']
|
55
55
|
config.access_token_mock = ENV['access_token_mock']
|
56
|
-
config.
|
56
|
+
config.profile_mocks = {
|
57
57
|
'169783' => {
|
58
58
|
user: 'John Blacksmith',
|
59
59
|
uid: '169783'
|
@@ -113,18 +113,32 @@ RailsSso.configure do
|
|
113
113
|
end
|
114
114
|
```
|
115
115
|
|
116
|
-
Mock data should be passed to `
|
116
|
+
Mock data should be passed to `profile_mocks` configuration with dummy access token as a key.
|
117
117
|
|
118
118
|
```ruby
|
119
119
|
RailsSso.configure do |config|
|
120
|
-
config.
|
121
|
-
|
122
|
-
|
120
|
+
config.profile_mocks = {
|
121
|
+
"kowalski_uid" => {
|
122
|
+
"name" => "John Kowalski",
|
123
|
+
"uid" => "42"
|
124
|
+
},
|
125
|
+
"nowak_uid" => {
|
126
|
+
"name" => "Pawel Nowak",
|
127
|
+
"uid" => "23"
|
128
|
+
}
|
123
129
|
}
|
124
130
|
end
|
125
131
|
```
|
126
132
|
|
127
|
-
|
133
|
+
Finally you have to select which token to use.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
RailsSso.configure do |config|
|
137
|
+
config.access_token_mock = "kowalski_uid"
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
To mock signed out state set `nil` to access token value.
|
128
142
|
|
129
143
|
## Contributing
|
130
144
|
|
data/config/routes.rb
CHANGED
@@ -3,6 +3,6 @@ RailsSso::Engine.routes.draw do
|
|
3
3
|
get '/:provider/callback', to: 'sessions#create'
|
4
4
|
delete '/sign_out', to: 'sessions#destroy', as: :sign_out
|
5
5
|
|
6
|
-
root to: redirect("/auth/#{RailsSso.provider_name}"), as: :sign_in
|
6
|
+
root to: redirect("/auth/#{RailsSso.config.provider_name}"), as: :sign_in
|
7
7
|
end
|
8
8
|
end
|
data/lib/rails_sso.rb
CHANGED
@@ -1,56 +1,12 @@
|
|
1
1
|
module RailsSso
|
2
|
-
|
3
|
-
mattr_accessor :magic_enabled
|
2
|
+
class Error < RuntimeError; end
|
4
3
|
|
5
|
-
mattr_accessor :
|
6
|
-
mattr_accessor :provider_name
|
7
|
-
mattr_accessor :provider_key
|
8
|
-
mattr_accessor :provider_secret
|
9
|
-
|
10
|
-
mattr_accessor :provider_profile_path
|
11
|
-
mattr_accessor :provider_sign_out_path
|
12
|
-
|
13
|
-
mattr_accessor :use_cache
|
14
|
-
|
15
|
-
mattr_accessor :test_mode
|
16
|
-
mattr_accessor :profile_mocks
|
17
|
-
mattr_accessor :access_token_mock
|
18
|
-
|
19
|
-
mattr_accessor :failure_app
|
4
|
+
mattr_accessor :config
|
20
5
|
|
21
6
|
def self.configure
|
22
|
-
self.
|
23
|
-
self.magic_enabled = true
|
24
|
-
self.use_cache = false
|
25
|
-
self.test_mode = false
|
26
|
-
self.profile_mocks = {}
|
27
|
-
self.access_token_mock = nil
|
28
|
-
self.failure_app = RailsSso::FailureApp
|
29
|
-
|
30
|
-
yield self
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.user_repository
|
34
|
-
@@user_repository.constantize
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.provider_callback_path
|
38
|
-
"/sso/#{self.provider_name}/callback"
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.oauth2_strategy_class
|
42
|
-
OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(provider_name.to_s)}")
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.test_mode=(value)
|
46
|
-
@@test_mode = value
|
47
|
-
OmniAuth.config.test_mode = value
|
48
|
-
end
|
7
|
+
self.config = Configuration.new
|
49
8
|
|
50
|
-
|
51
|
-
@@profile_mocks.fetch(@@access_token_mock) do
|
52
|
-
fail %Q{Mock "#{@@access_token_mock}" has not beed setup!}
|
53
|
-
end
|
9
|
+
yield config
|
54
10
|
end
|
55
11
|
end
|
56
12
|
|
@@ -58,6 +14,7 @@ require "warden"
|
|
58
14
|
require "omniauth-oauth2"
|
59
15
|
require "rails_sso/version"
|
60
16
|
require "rails_sso/app"
|
17
|
+
require "rails_sso/configuration"
|
61
18
|
require "rails_sso/engine"
|
62
19
|
require "rails_sso/helpers"
|
63
20
|
require "rails_sso/client"
|
data/lib/rails_sso/app.rb
CHANGED
@@ -7,10 +7,10 @@ module RailsSso
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def fetch_user_data
|
10
|
-
FetchUser.new(provider_client.token!(
|
10
|
+
FetchUser.new(provider_client.token!(current_access_token_value)).call
|
11
11
|
rescue ResponseError => e
|
12
12
|
refresh_access_token! do
|
13
|
-
FetchUser.new(provider_client.token!(
|
13
|
+
FetchUser.new(provider_client.token!(current_access_token_value)).call
|
14
14
|
end if e.code == :unauthenticated
|
15
15
|
end
|
16
16
|
|
@@ -30,7 +30,7 @@ module RailsSso
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def access_token
|
33
|
-
return token_mock if RailsSso.test_mode
|
33
|
+
return token_mock if RailsSso.config.test_mode?
|
34
34
|
|
35
35
|
OAuth2::AccessToken.new(strategy.client, session[:access_token], {
|
36
36
|
refresh_token: session[:refresh_token]
|
@@ -38,15 +38,25 @@ module RailsSso
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def invalidate_access_token!
|
41
|
-
if RailsSso.provider_sign_out_path
|
42
|
-
access_token.delete(RailsSso.provider_sign_out_path)
|
41
|
+
if RailsSso.config.provider_sign_out_path
|
42
|
+
access_token.delete(RailsSso.config.provider_sign_out_path)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
+
def current_access_token_value
|
49
|
+
session[:access_token] or current_access_token_mock
|
50
|
+
end
|
51
|
+
|
52
|
+
def current_access_token_mock
|
53
|
+
if RailsSso.config.test_mode?
|
54
|
+
token_mock.token
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
48
58
|
def token_mock
|
49
|
-
RailsSso::TokenMock.new
|
59
|
+
@token_mock ||= RailsSso::TokenMock.new
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
data/lib/rails_sso/client.rb
CHANGED
@@ -10,7 +10,7 @@ module RailsSso
|
|
10
10
|
|
11
11
|
def self.build_real(url)
|
12
12
|
build(url) do |conn|
|
13
|
-
if RailsSso.use_cache
|
13
|
+
if RailsSso.config.use_cache
|
14
14
|
conn.use :http_cache,
|
15
15
|
store: Rails.cache,
|
16
16
|
logger: Rails.logger,
|
@@ -25,13 +25,13 @@ module RailsSso
|
|
25
25
|
def self.build_fake(url)
|
26
26
|
build(url) do |conn|
|
27
27
|
conn.adapter :test do |stub|
|
28
|
-
RailsSso.profile_mocks.each do |token, profile|
|
28
|
+
RailsSso.config.profile_mocks.each do |token, profile|
|
29
29
|
headers = {
|
30
30
|
"Content-Type" => "application/json",
|
31
31
|
"Authorization" => "Bearer #{token}"
|
32
32
|
}
|
33
33
|
|
34
|
-
stub.get(RailsSso.provider_profile_path, headers) do |env|
|
34
|
+
stub.get(RailsSso.config.provider_profile_path, headers) do |env|
|
35
35
|
if profile.nil?
|
36
36
|
[401, { "Content-Type" => "application/json" }, ""]
|
37
37
|
else
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module RailsSso
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :application_controller
|
4
|
+
attr_accessor :magic_enabled
|
5
|
+
|
6
|
+
attr_writer :provider_url
|
7
|
+
attr_accessor :provider_name
|
8
|
+
attr_accessor :provider_key
|
9
|
+
attr_accessor :provider_secret
|
10
|
+
|
11
|
+
attr_accessor :provider_profile_path
|
12
|
+
attr_accessor :provider_sign_out_path
|
13
|
+
|
14
|
+
attr_accessor :use_cache
|
15
|
+
|
16
|
+
attr_reader :test_mode
|
17
|
+
attr_accessor :profile_mocks
|
18
|
+
attr_accessor :access_token_mock
|
19
|
+
|
20
|
+
attr_accessor :failure_app
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
self.application_controller = "ApplicationController"
|
24
|
+
self.magic_enabled = true
|
25
|
+
self.use_cache = false
|
26
|
+
self.test_mode = false
|
27
|
+
self.profile_mocks = {}
|
28
|
+
self.access_token_mock = nil
|
29
|
+
self.failure_app = RailsSso::FailureApp
|
30
|
+
end
|
31
|
+
|
32
|
+
def provider_callback_path
|
33
|
+
"/sso/#{provider_name}/callback"
|
34
|
+
end
|
35
|
+
|
36
|
+
def oauth2_strategy_class
|
37
|
+
OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(provider_name.to_s)}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_mode=(value)
|
41
|
+
@test_mode = value
|
42
|
+
OmniAuth.config.test_mode = value
|
43
|
+
end
|
44
|
+
|
45
|
+
def profile_mock
|
46
|
+
profile_mocks.fetch(access_token_mock) do
|
47
|
+
fail %Q{Mock "#{access_token_mock}" has not been setup!}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_mode?
|
52
|
+
@test_mode
|
53
|
+
end
|
54
|
+
|
55
|
+
def provider_url
|
56
|
+
fail RailsSso::Error, "Provider url not set!" if @provider_url.nil?
|
57
|
+
|
58
|
+
@provider_url
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/rails_sso/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RailsSso
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
initializer "sso.helpers" do
|
4
|
-
if RailsSso.magic_enabled
|
4
|
+
if RailsSso.config.magic_enabled
|
5
5
|
ActiveSupport.on_load(:action_controller) do
|
6
6
|
include RailsSso::Helpers
|
7
7
|
end
|
@@ -9,8 +9,8 @@ module RailsSso
|
|
9
9
|
end
|
10
10
|
|
11
11
|
initializer "sso.omniauth", after: :load_config_initializers, before: :build_middleware_stack do |app|
|
12
|
-
if RailsSso.provider_name
|
13
|
-
RailsSso.oauth2_strategy_class.class_eval do
|
12
|
+
if RailsSso.config.provider_name
|
13
|
+
RailsSso.config.oauth2_strategy_class.class_eval do
|
14
14
|
def setup_phase
|
15
15
|
setup_sso!
|
16
16
|
|
@@ -34,24 +34,24 @@ module RailsSso
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def sso_client
|
37
|
-
if RailsSso.test_mode
|
38
|
-
RailsSso::Client.build_fake(RailsSso.provider_url)
|
37
|
+
if RailsSso.config.test_mode
|
38
|
+
RailsSso::Client.build_fake(RailsSso.config.provider_url)
|
39
39
|
else
|
40
|
-
RailsSso::Client.build_real(RailsSso.provider_url)
|
40
|
+
RailsSso::Client.build_real(RailsSso.config.provider_url)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
app.config.middleware.use OmniAuth::Builder do
|
46
|
-
provider RailsSso.provider_name,
|
47
|
-
RailsSso.provider_key,
|
48
|
-
RailsSso.provider_secret,
|
49
|
-
callback_path: RailsSso.provider_callback_path
|
46
|
+
provider RailsSso.config.provider_name,
|
47
|
+
RailsSso.config.provider_key,
|
48
|
+
RailsSso.config.provider_secret,
|
49
|
+
callback_path: RailsSso.config.provider_callback_path
|
50
50
|
end
|
51
51
|
|
52
52
|
app.config.middleware.insert_after OmniAuth::Builder, Warden::Manager do |manager|
|
53
53
|
manager.default_strategies :sso
|
54
|
-
manager.failure_app = RailsSso.failure_app
|
54
|
+
manager.failure_app = RailsSso.config.failure_app
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/rails_sso/token_mock.rb
CHANGED
@@ -9,9 +9,17 @@ module RailsSso
|
|
9
9
|
def initialize(*)
|
10
10
|
@connection = Faraday.new do |builder|
|
11
11
|
builder.adapter :test do |stub|
|
12
|
-
stub.delete(RailsSso.provider_sign_out_path) { |env| [200, {}, ''] }
|
12
|
+
stub.delete(RailsSso.config.provider_sign_out_path) { |env| [200, {}, ''] }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
def token
|
18
|
+
RailsSso.config.access_token_mock
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh_token
|
22
|
+
nil
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/rails_sso/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -709,3 +709,105 @@ RailsSso::AppTest: test_#fetch_user_data_when_invalid_token_returns_nil_and_rese
|
|
709
709
|
------------------------------------------------------------------------------------------
|
710
710
|
RailsSso::AppTest: test_#fetch_user_data_when_stale_token_refreshes_token_and_returns_data
|
711
711
|
------------------------------------------------------------------------------------------
|
712
|
+
------------------------------------------------------------------------------------------------
|
713
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
714
|
+
------------------------------------------------------------------------------------------------
|
715
|
+
-------------------------------------------------------------------------------------------------------
|
716
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
717
|
+
-------------------------------------------------------------------------------------------------------
|
718
|
+
------------------------------------------------------------------------------------------------
|
719
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
720
|
+
------------------------------------------------------------------------------------------------
|
721
|
+
-------------------------------------------------------------------------------------------------------
|
722
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
723
|
+
-------------------------------------------------------------------------------------------------------
|
724
|
+
------------------------------------------------------------------------------------------------
|
725
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
726
|
+
------------------------------------------------------------------------------------------------
|
727
|
+
-------------------------------------------------------------------------------------------------------
|
728
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
729
|
+
-------------------------------------------------------------------------------------------------------
|
730
|
+
------------------------------------------------------------------------------------------------
|
731
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
732
|
+
------------------------------------------------------------------------------------------------
|
733
|
+
-------------------------------------------------------------------------------------------------------
|
734
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
735
|
+
-------------------------------------------------------------------------------------------------------
|
736
|
+
------------------------------------------------------------------------------------------------
|
737
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
738
|
+
------------------------------------------------------------------------------------------------
|
739
|
+
-------------------------------------------------------------------------------------------------------
|
740
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
741
|
+
-------------------------------------------------------------------------------------------------------
|
742
|
+
------------------------------------------------------------------------------------------------
|
743
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
744
|
+
------------------------------------------------------------------------------------------------
|
745
|
+
-------------------------------------------------------------------------------------------------------
|
746
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
747
|
+
-------------------------------------------------------------------------------------------------------
|
748
|
+
------------------------------------------------------------------------------------------------
|
749
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
750
|
+
------------------------------------------------------------------------------------------------
|
751
|
+
-------------------------------------------------------------------------------------------------------
|
752
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
753
|
+
-------------------------------------------------------------------------------------------------------
|
754
|
+
------------------------------------------------------------------------------------------------
|
755
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
756
|
+
------------------------------------------------------------------------------------------------
|
757
|
+
-------------------------------------------------------------------------------------------------------
|
758
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
759
|
+
-------------------------------------------------------------------------------------------------------
|
760
|
+
------------------------------------------------------------------------------------------------
|
761
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
762
|
+
------------------------------------------------------------------------------------------------
|
763
|
+
-------------------------------------------------------------------------------------------------------
|
764
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
765
|
+
-------------------------------------------------------------------------------------------------------
|
766
|
+
-------------------------------------------------------------------------------------------------------
|
767
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
768
|
+
-------------------------------------------------------------------------------------------------------
|
769
|
+
Processing by RailsSso::SessionsController#destroy as HTML
|
770
|
+
Redirected to http://test.host/
|
771
|
+
Completed 302 Found in 0ms
|
772
|
+
------------------------------------------------------------------------------------------------
|
773
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
774
|
+
------------------------------------------------------------------------------------------------
|
775
|
+
Processing by RailsSso::SessionsController#create as HTML
|
776
|
+
Parameters: {"provider"=>"developer"}
|
777
|
+
Redirected to http://test.host/
|
778
|
+
Completed 302 Found in 0ms
|
779
|
+
------------------------------------------------------------------------------------------------
|
780
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
781
|
+
------------------------------------------------------------------------------------------------
|
782
|
+
Processing by RailsSso::SessionsController#create as HTML
|
783
|
+
Parameters: {"provider"=>"developer"}
|
784
|
+
Redirected to http://test.host/
|
785
|
+
Completed 302 Found in 0ms
|
786
|
+
-------------------------------------------------------------------------------------------------------
|
787
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
788
|
+
-------------------------------------------------------------------------------------------------------
|
789
|
+
Processing by RailsSso::SessionsController#destroy as HTML
|
790
|
+
Redirected to http://test.host/
|
791
|
+
Completed 302 Found in 0ms
|
792
|
+
------------------------
|
793
|
+
RailsSsoTest: test_truth
|
794
|
+
------------------------
|
795
|
+
-------------------------------------------------------------------------------------------------------
|
796
|
+
RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
|
797
|
+
-------------------------------------------------------------------------------------------------------
|
798
|
+
Processing by RailsSso::SessionsController#destroy as HTML
|
799
|
+
Redirected to http://test.host/
|
800
|
+
Completed 302 Found in 0ms
|
801
|
+
------------------------------------------------------------------------------------------------
|
802
|
+
RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
|
803
|
+
------------------------------------------------------------------------------------------------
|
804
|
+
Processing by RailsSso::SessionsController#create as HTML
|
805
|
+
Parameters: {"provider"=>"developer"}
|
806
|
+
Redirected to http://test.host/
|
807
|
+
Completed 302 Found in 0ms
|
808
|
+
-------------------------------------------------------------------------
|
809
|
+
RailsSso::ConfigurationTest: test_#provider_url_fails_if_not_yet_provided
|
810
|
+
-------------------------------------------------------------------------
|
811
|
+
-------------------------------------------------------------------------
|
812
|
+
RailsSso::ConfigurationTest: test_#provider_url_fails_if_not_yet_provided
|
813
|
+
-------------------------------------------------------------------------
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class RailsSso::ConfigurationTest < ActiveSupport::TestCase
|
4
|
+
test "#provider_url fails if not yet provided" do
|
5
|
+
config = RailsSso::Configuration.new
|
6
|
+
|
7
|
+
assert_raises RailsSso::Error, "Provider url not set!" do
|
8
|
+
config.provider_url
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -18,8 +18,8 @@ class RailsSso::SsoStrategyTest < ActiveSupport::TestCase
|
|
18
18
|
test "is valid when in test mode with access token mock" do
|
19
19
|
env = { "rack.session" => {} }
|
20
20
|
strategy = RailsSso::SsoStrategy.new(env)
|
21
|
-
RailsSso.stubs(:test_mode).returns(true)
|
22
|
-
RailsSso.stubs(:access_token_mock).returns("169783")
|
21
|
+
RailsSso.config.stubs(:test_mode).returns(true)
|
22
|
+
RailsSso.config.stubs(:access_token_mock).returns("169783")
|
23
23
|
|
24
24
|
assert strategy.valid?
|
25
25
|
end
|
@@ -27,8 +27,8 @@ class RailsSso::SsoStrategyTest < ActiveSupport::TestCase
|
|
27
27
|
test "is invalid when in test mode without access token mock" do
|
28
28
|
env = { "rack.session" => {} }
|
29
29
|
strategy = RailsSso::SsoStrategy.new(env)
|
30
|
-
RailsSso.stubs(:test_mode).returns(true)
|
31
|
-
RailsSso.stubs(:access_token_mock).returns(nil)
|
30
|
+
RailsSso.config.stubs(:test_mode).returns(true)
|
31
|
+
RailsSso.config.stubs(:access_token_mock).returns(nil)
|
32
32
|
|
33
33
|
refute strategy.valid?
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Dudulski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/rails_sso.rb
|
142
142
|
- lib/rails_sso/app.rb
|
143
143
|
- lib/rails_sso/client.rb
|
144
|
+
- lib/rails_sso/configuration.rb
|
144
145
|
- lib/rails_sso/engine.rb
|
145
146
|
- lib/rails_sso/failure_app.rb
|
146
147
|
- lib/rails_sso/helpers.rb
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- test/dummy/public/500.html
|
188
189
|
- test/dummy/public/favicon.ico
|
189
190
|
- test/lib/rails_sso/app_test.rb
|
191
|
+
- test/lib/rails_sso/configuration_test.rb
|
190
192
|
- test/lib/rails_sso/failure_app_test.rb
|
191
193
|
- test/lib/rails_sso/response_error_test.rb
|
192
194
|
- test/lib/rails_sso/sso_strategy_test.rb
|
@@ -224,6 +226,7 @@ test_files:
|
|
224
226
|
- test/lib/rails_sso/sso_strategy_test.rb
|
225
227
|
- test/lib/rails_sso/response_error_test.rb
|
226
228
|
- test/lib/rails_sso/failure_app_test.rb
|
229
|
+
- test/lib/rails_sso/configuration_test.rb
|
227
230
|
- test/rails_sso_test.rb
|
228
231
|
- test/test_helper.rb
|
229
232
|
- test/routes/sso_routes_test.rb
|