rails_sso 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd754eb87958a853877abfe7c61e0f86cefa040f
4
- data.tar.gz: a1d6e5a87618f51aed1b31de3a3fd505270940bc
3
+ metadata.gz: c2a497053dd237b714c1b0b91a2439715979f799
4
+ data.tar.gz: e1182450ba793d89369d5f7a39e2cc065322e8bc
5
5
  SHA512:
6
- metadata.gz: dc961652cc56dd18bfcd348920140f48881cd4c2c45bd43556b5093aecfbfa386707fcff4423f14e932e37c018a5f4631122768f8f1977da4ddc75dbbb5cb35e
7
- data.tar.gz: 70dd69cd3ae60fa1adc88153788205608ae5a73d54324829e63e2fb3d9baec31dea1f953955867c93a8e09a9f7d65cb9d82232484f8d9c686826f7c421dd9a75
6
+ metadata.gz: ba6952eae5f2ac284edf0fe57cd81e032545506bd09f87caf13bdb022baa150090c2824c80a8a48362c9dbc2032c4ee94341cf55a539341048ecfb6c1daa03a2
7
+ data.tar.gz: 7792868a6d5856dbf3a0cae4276563ab1ea81e6b5c9b0cd65096be40a9b7c27763e4d8e05cf680788305f472033f2ae446bf733eab1d76e4184c6517c56ba085
@@ -3,13 +3,13 @@ module RailsSso
3
3
  skip_before_action :authenticate_user!, only: [:create]
4
4
 
5
5
  def create
6
- save_access_token!(auth_hash.credentials)
6
+ sign_in_with_access_token!(auth_hash.credentials)
7
7
 
8
8
  redirect_to root_path
9
9
  end
10
10
 
11
11
  def destroy
12
- invalidate_access_token!
12
+ sign_out!
13
13
 
14
14
  redirect_to root_path
15
15
  end
@@ -0,0 +1,58 @@
1
+ module RailsSso
2
+ class App
3
+ attr_reader :strategy, :session
4
+
5
+ def initialize(strategy, session)
6
+ @strategy, @session = strategy, session
7
+ end
8
+
9
+ def fetch_user_data
10
+ FetchUser.new(provider_client.token!(session[:access_token])).call
11
+ rescue ResponseError => e
12
+ refresh_access_token! do
13
+ FetchUser.new(provider_client.token!(session[:access_token])).call
14
+ end if e.code == :unauthenticated
15
+ end
16
+
17
+ def refresh_access_token!
18
+ save_access_token!(access_token.refresh!)
19
+
20
+ yield if block_given?
21
+ rescue ::OAuth2::Error
22
+ nil
23
+ rescue ResponseError => e
24
+ nil if e.code == :unauthenticated
25
+ end
26
+
27
+ def save_access_token!(access_token)
28
+ session[:access_token] = access_token.token
29
+ session[:refresh_token] = access_token.refresh_token
30
+ end
31
+
32
+ def access_token
33
+ OAuth2::AccessToken.new(strategy.client, session[:access_token], {
34
+ refresh_token: session[:refresh_token]
35
+ })
36
+ end
37
+
38
+ def invalidate_access_token!
39
+ if RailsSso.provider_sign_out_path
40
+ access_token.delete(RailsSso.provider_sign_out_path)
41
+ end
42
+ end
43
+
44
+ def provider_client
45
+ @provider_client ||= RailsSso::Client.new(RailsSso.provider_url) do |conn|
46
+ if RailsSso.use_cache
47
+ conn.use :http_cache,
48
+ store: Rails.cache,
49
+ logger: Rails.logger,
50
+ serializer: Marshal,
51
+ shared_cache: false
52
+ end
53
+
54
+ conn.adapter Faraday.default_adapter
55
+ end
56
+ end
57
+ end
58
+ end
@@ -8,12 +8,35 @@ module RailsSso
8
8
 
9
9
  initializer 'sso.omniauth', after: :load_config_initializers, before: :build_middleware_stack do |app|
10
10
  if RailsSso.provider_name
11
+ RailsSso.oauth2_strategy_class.class_eval do
12
+ def setup_phase
13
+ setup_sso!
14
+
15
+ super
16
+ end
17
+
18
+ def other_phase
19
+ setup_sso!
20
+
21
+ call_app!
22
+ end
23
+
24
+ def setup_sso!
25
+ env['sso'] ||= RailsSso::App.new(self, session)
26
+ end
27
+ end
28
+
11
29
  app.config.middleware.use OmniAuth::Builder do
12
30
  provider RailsSso.provider_name,
13
31
  RailsSso.provider_key,
14
32
  RailsSso.provider_secret,
15
33
  callback_path: RailsSso.provider_callback_path
16
34
  end
35
+
36
+ app.config.middleware.insert_after OmniAuth::Builder, Warden::Manager do |manager|
37
+ manager.default_strategies :sso
38
+ manager.failure_app = RailsSso::FailureApp
39
+ end
17
40
  end
18
41
  end
19
42
  end
@@ -0,0 +1,15 @@
1
+ module RailsSso
2
+ class FailureApp < ::ActionController::Metal
3
+ include ActionController::Redirecting
4
+ include RailsSso::Engine.routes.url_helpers
5
+
6
+ def self.call(env)
7
+ @respond ||= action(:respond)
8
+ @respond.call(env)
9
+ end
10
+
11
+ def respond
12
+ redirect_to sign_in_path
13
+ end
14
+ end
15
+ end
@@ -7,78 +7,33 @@ module RailsSso
7
7
  end
8
8
 
9
9
  def current_user_data
10
- @current_user_data ||= fetch_user_data
11
- end
12
-
13
- def user_signed_in?
14
- !!current_user_data
10
+ warden.user
15
11
  end
16
12
 
17
13
  def authenticate_user!
18
- redirect_to sso.sign_in_path unless user_signed_in?
19
- end
20
-
21
- def access_token
22
- OAuth2::AccessToken.new(oauth2_strategy.client, session[:access_token], {
23
- refresh_token: session[:refresh_token]
24
- })
25
- end
26
-
27
- def invalidate_access_token!
28
- if RailsSso.provider_sign_out_path
29
- access_token.delete(RailsSso.provider_sign_out_path)
30
- end
31
-
32
- reset_session
14
+ warden.authenticate!
33
15
  end
34
16
 
35
- def save_access_token!(access_token)
36
- session[:access_token] = access_token.token
37
- session[:refresh_token] = access_token.refresh_token
17
+ def user_signed_in?
18
+ warden.authenticated?
38
19
  end
39
20
 
40
- def refresh_access_token!
41
- save_access_token!(access_token.refresh!)
42
-
43
- yield if block_given?
44
- rescue ::OAuth2::Error
45
- nil
46
- rescue ResponseError => e
47
- nil if e.code == :unauthenticated
21
+ def sign_in_with_access_token!(access_token)
22
+ sso_app.save_access_token!(access_token)
48
23
  end
49
24
 
50
- private
51
-
52
- def oauth2_strategy
53
- oauth2_strategy_class.new(request, RailsSso.provider_key, RailsSso.provider_secret)
54
- end
25
+ def sign_out!
26
+ sso_app.invalidate_access_token!
55
27
 
56
- def oauth2_strategy_class
57
- OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(RailsSso.provider_name.to_s)}")
28
+ warden.logout
58
29
  end
59
30
 
60
- def provider_client
61
- @provider_client ||= RailsSso::Client.new(RailsSso.provider_url) do |conn|
62
- if RailsSso.use_cache
63
- conn.use :http_cache,
64
- store: Rails.cache,
65
- logger: Rails.logger,
66
- serializer: Marshal,
67
- shared_cache: false
68
- end
69
-
70
- conn.adapter Faraday.default_adapter
71
- end
31
+ def warden
32
+ env['warden']
72
33
  end
73
34
 
74
- def fetch_user_data
75
- return unless session[:access_token]
76
-
77
- RailsSso::FetchUser.new(provider_client.token!(session[:access_token])).call
78
- rescue ResponseError => e
79
- refresh_access_token! do
80
- RailsSso::FetchUser.new(provider_client.token!(session[:access_token])).call
81
- end if e.code == :unauthenticated
35
+ def sso_app
36
+ env['sso']
82
37
  end
83
38
  end
84
39
  end
@@ -0,0 +1,23 @@
1
+ module RailsSso
2
+ class SsoStrategy < ::Warden::Strategies::Base
3
+ def store?
4
+ false
5
+ end
6
+
7
+ def valid?
8
+ session[:access_token].present?
9
+ end
10
+
11
+ def authenticate!
12
+ env['sso'].fetch_user_data.tap do |user|
13
+ if user.nil?
14
+ fail! 'strategies.sso.failed'
15
+ else
16
+ success! user
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ Warden::Strategies.add(:sso, RailsSso::SsoStrategy)
@@ -1,3 +1,3 @@
1
1
  module RailsSso
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/rails_sso.rb CHANGED
@@ -24,11 +24,19 @@ module RailsSso
24
24
  def self.provider_callback_path
25
25
  "/sso/#{self.provider_name}/callback"
26
26
  end
27
+
28
+ def self.oauth2_strategy_class
29
+ OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(provider_name.to_s)}")
30
+ end
27
31
  end
28
32
 
33
+ require 'warden'
29
34
  require 'omniauth-oauth2'
30
35
  require 'rails_sso/version'
36
+ require 'rails_sso/app'
31
37
  require 'rails_sso/engine'
32
38
  require 'rails_sso/helpers'
33
39
  require 'rails_sso/client'
34
40
  require 'rails_sso/response_error'
41
+ require 'rails_sso/sso_strategy'
42
+ require 'rails_sso/failure_app'
@@ -22,7 +22,7 @@ class RailsSso::SessionsControllerTest < ActionController::TestCase
22
22
  end
23
23
 
24
24
  test 'create should save access token and redirect to root path' do
25
- @controller.expects(:save_access_token!).with(@auth_hash.credentials).once
25
+ @controller.expects(:sign_in_with_access_token!).with(@auth_hash.credentials).once
26
26
 
27
27
  get :create, { provider: 'developer' }
28
28
 
@@ -30,7 +30,7 @@ class RailsSso::SessionsControllerTest < ActionController::TestCase
30
30
  end
31
31
 
32
32
  test 'destroy should invalidate access token and redirect to root path' do
33
- @controller.expects(:invalidate_access_token!).once
33
+ @controller.expects(:sign_out!).once
34
34
 
35
35
  delete :destroy, {}, { access_token: 'abc', refresh_token: 'def' }
36
36
 
@@ -3992,3 +3992,559 @@ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
3992
3992
  ------------------------------------------------------------------------------------
3993
3993
  RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
3994
3994
  ------------------------------------------------------------------------------------
3995
+ ------------------------------------------------------------------------------------
3996
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
3997
+ ------------------------------------------------------------------------------------
3998
+ ----------------------------------------------------------------------------
3999
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4000
+ ----------------------------------------------------------------------------
4001
+ ----------------------------------------------------
4002
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4003
+ ----------------------------------------------------
4004
+ ------------------------------------------------------------------------------------------------
4005
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4006
+ ------------------------------------------------------------------------------------------------
4007
+ Processing by RailsSso::SessionsController#create as HTML
4008
+ Parameters: {"provider"=>"developer"}
4009
+ Redirected to http://test.host/
4010
+ Completed 302 Found in 0ms
4011
+ -------------------------------------------------------------------------------------------------------
4012
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4013
+ -------------------------------------------------------------------------------------------------------
4014
+ Processing by RailsSso::SessionsController#destroy as HTML
4015
+ Redirected to http://test.host/
4016
+ Completed 302 Found in 0ms
4017
+ -----------------------------------------------------------------------------------------
4018
+ RailsSso::HelpersTest: test_#refresh_access_token!_will_refresh_token_and_copy_new_values
4019
+ -----------------------------------------------------------------------------------------
4020
+ --------------------------------------------------------------------------
4021
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_true_if_authenticated
4022
+ --------------------------------------------------------------------------
4023
+ -------------------------------------------------------------------------------------
4024
+ RailsSso::HelpersTest: test_#current_user_data_will_return_user_data_if_authenticated
4025
+ -------------------------------------------------------------------------------------
4026
+ ----------------------------------------------------------------------------------
4027
+ RailsSso::HelpersTest: test_#access_token_returns_a_new_OAuth2::AccessToken_object
4028
+ ----------------------------------------------------------------------------------
4029
+ --------------------------------------------------------------------------------------------
4030
+ RailsSso::HelpersTest: test_save_access_token!_will_copy_access_and_refresh_token_to_session
4031
+ --------------------------------------------------------------------------------------------
4032
+ -----------------------------------------------------------------------------------
4033
+ RailsSso::HelpersTest: test_#current_user_data_will_return_nil_if_not_authenticated
4034
+ -----------------------------------------------------------------------------------
4035
+ -------------------------------------------------------------------------------------------------
4036
+ RailsSso::HelpersTest: test_#invalidate_access_token!_will_call_Single_Sign-Out_with_access_token
4037
+ -------------------------------------------------------------------------------------------------
4038
+ -------------------------------------------------------------------------------
4039
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_false_if_not_authenticated
4040
+ -------------------------------------------------------------------------------
4041
+ -----------------------------------------------------------------------------------------------------
4042
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4043
+ -----------------------------------------------------------------------------------------------------
4044
+ ---------------------------------------------------------------------
4045
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4046
+ ---------------------------------------------------------------------
4047
+ -------------------------------------------------------------
4048
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4049
+ -------------------------------------------------------------
4050
+ ----------------------------------------------------
4051
+ SsoRoutesTest: test_should_route_/:provider/callback
4052
+ ----------------------------------------------------
4053
+ ------------------------------------------
4054
+ SsoRoutesTest: test_should_route_/sign_out
4055
+ ------------------------------------------
4056
+ ------------------------
4057
+ RailsSsoTest: test_truth
4058
+ ------------------------
4059
+ -----------------------------------------------------------------------------------------------------
4060
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4061
+ -----------------------------------------------------------------------------------------------------
4062
+ ---------------------------------------------------------------------
4063
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4064
+ ---------------------------------------------------------------------
4065
+ -------------------------------------------------------------
4066
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4067
+ -------------------------------------------------------------
4068
+ ------------------------------------------
4069
+ SsoRoutesTest: test_should_route_/sign_out
4070
+ ------------------------------------------
4071
+ ----------------------------------------------------
4072
+ SsoRoutesTest: test_should_route_/:provider/callback
4073
+ ----------------------------------------------------
4074
+ ----------------------------------------------------------------------------
4075
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4076
+ ----------------------------------------------------------------------------
4077
+ ------------------------------------------------------------------------------------
4078
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4079
+ ------------------------------------------------------------------------------------
4080
+ ----------------------------------------------------
4081
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4082
+ ----------------------------------------------------
4083
+ ------------------------------------------------------------------------------------------------
4084
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4085
+ ------------------------------------------------------------------------------------------------
4086
+ Processing by RailsSso::SessionsController#create as HTML
4087
+ Parameters: {"provider"=>"developer"}
4088
+ Redirected to http://test.host/
4089
+ Completed 302 Found in 0ms
4090
+ -------------------------------------------------------------------------------------------------------
4091
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4092
+ -------------------------------------------------------------------------------------------------------
4093
+ Processing by RailsSso::SessionsController#destroy as HTML
4094
+ Redirected to http://test.host/
4095
+ Completed 302 Found in 1ms
4096
+ --------------------------------------------------------------------------------------------
4097
+ RailsSso::HelpersTest: test_save_access_token!_will_copy_access_and_refresh_token_to_session
4098
+ --------------------------------------------------------------------------------------------
4099
+ -----------------------------------------------------------------------------------
4100
+ RailsSso::HelpersTest: test_#current_user_data_will_return_nil_if_not_authenticated
4101
+ -----------------------------------------------------------------------------------
4102
+ -------------------------------------------------------------------------------------
4103
+ RailsSso::HelpersTest: test_#current_user_data_will_return_user_data_if_authenticated
4104
+ -------------------------------------------------------------------------------------
4105
+ -----------------------------------------------------------------------------------------
4106
+ RailsSso::HelpersTest: test_#refresh_access_token!_will_refresh_token_and_copy_new_values
4107
+ -----------------------------------------------------------------------------------------
4108
+ --------------------------------------------------------------------------
4109
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_true_if_authenticated
4110
+ --------------------------------------------------------------------------
4111
+ -------------------------------------------------------------------------------
4112
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_false_if_not_authenticated
4113
+ -------------------------------------------------------------------------------
4114
+ ----------------------------------------------------------------------------------
4115
+ RailsSso::HelpersTest: test_#access_token_returns_a_new_OAuth2::AccessToken_object
4116
+ ----------------------------------------------------------------------------------
4117
+ -------------------------------------------------------------------------------------------------
4118
+ RailsSso::HelpersTest: test_#invalidate_access_token!_will_call_Single_Sign-Out_with_access_token
4119
+ -------------------------------------------------------------------------------------------------
4120
+ ------------------------
4121
+ RailsSsoTest: test_truth
4122
+ ------------------------
4123
+ ------------------------
4124
+ RailsSsoTest: test_truth
4125
+ ------------------------
4126
+ ----------------------------------------------------
4127
+ SsoRoutesTest: test_should_route_/:provider/callback
4128
+ ----------------------------------------------------
4129
+ ------------------------------------------
4130
+ SsoRoutesTest: test_should_route_/sign_out
4131
+ ------------------------------------------
4132
+ ------------------------------------------------------------------------------------------------
4133
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4134
+ ------------------------------------------------------------------------------------------------
4135
+ Processing by RailsSso::SessionsController#create as HTML
4136
+ Parameters: {"provider"=>"developer"}
4137
+ Redirected to http://test.host/
4138
+ Completed 302 Found in 0ms
4139
+ -------------------------------------------------------------------------------------------------------
4140
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4141
+ -------------------------------------------------------------------------------------------------------
4142
+ Processing by RailsSso::SessionsController#destroy as HTML
4143
+ Redirected to http://test.host/
4144
+ Completed 302 Found in 0ms
4145
+ ----------------------------------------------------
4146
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4147
+ ----------------------------------------------------
4148
+ ------------------------------------------------------------------------------------
4149
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4150
+ ------------------------------------------------------------------------------------
4151
+ ----------------------------------------------------------------------------
4152
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4153
+ ----------------------------------------------------------------------------
4154
+ -------------------------------------------------------------
4155
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4156
+ -------------------------------------------------------------
4157
+ ---------------------------------------------------------------------
4158
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4159
+ ---------------------------------------------------------------------
4160
+ -----------------------------------------------------------------------------------------------------
4161
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4162
+ -----------------------------------------------------------------------------------------------------
4163
+ -----------------------------------------------------------------------------------
4164
+ RailsSso::HelpersTest: test_#current_user_data_will_return_nil_if_not_authenticated
4165
+ -----------------------------------------------------------------------------------
4166
+ -------------------------------------------------------------------------------------
4167
+ RailsSso::HelpersTest: test_#current_user_data_will_return_user_data_if_authenticated
4168
+ -------------------------------------------------------------------------------------
4169
+ -------------------------------------------------------------------------------
4170
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_false_if_not_authenticated
4171
+ -------------------------------------------------------------------------------
4172
+ --------------------------------------------------------------------------
4173
+ RailsSso::HelpersTest: test_#user_signed_in?_returns_true_if_authenticated
4174
+ --------------------------------------------------------------------------
4175
+ ------------------------
4176
+ RailsSsoTest: test_truth
4177
+ ------------------------
4178
+ ------------------------------------------------------------------------------------
4179
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4180
+ ------------------------------------------------------------------------------------
4181
+ ----------------------------------------------------
4182
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4183
+ ----------------------------------------------------
4184
+ ----------------------------------------------------------------------------
4185
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4186
+ ----------------------------------------------------------------------------
4187
+ ----------------------------------------------------
4188
+ SsoRoutesTest: test_should_route_/:provider/callback
4189
+ ----------------------------------------------------
4190
+ ------------------------------------------
4191
+ SsoRoutesTest: test_should_route_/sign_out
4192
+ ------------------------------------------
4193
+ ---------------------------------------------------------------------
4194
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4195
+ ---------------------------------------------------------------------
4196
+ -----------------------------------------------------------------------------------------------------
4197
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4198
+ -----------------------------------------------------------------------------------------------------
4199
+ -------------------------------------------------------------
4200
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4201
+ -------------------------------------------------------------
4202
+ ------------------------------------------------------------------------------------------------
4203
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4204
+ ------------------------------------------------------------------------------------------------
4205
+ Processing by RailsSso::SessionsController#create as HTML
4206
+ Parameters: {"provider"=>"developer"}
4207
+ Redirected to http://test.host/
4208
+ Completed 302 Found in 0ms
4209
+ -------------------------------------------------------------------------------------------------------
4210
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4211
+ -------------------------------------------------------------------------------------------------------
4212
+ Processing by RailsSso::SessionsController#destroy as HTML
4213
+ Redirected to http://test.host/
4214
+ Completed 302 Found in 0ms
4215
+ ------------------------------------------------------------------------------------------------
4216
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4217
+ ------------------------------------------------------------------------------------------------
4218
+ Processing by RailsSso::SessionsController#create as HTML
4219
+ Parameters: {"provider"=>"developer"}
4220
+ Completed 500 Internal Server Error in 0ms
4221
+ -------------------------------------------------------------------------------------------------------
4222
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4223
+ -------------------------------------------------------------------------------------------------------
4224
+ Processing by RailsSso::SessionsController#destroy as HTML
4225
+ Completed 500 Internal Server Error in 0ms
4226
+ -------------------------------------------------------------
4227
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4228
+ -------------------------------------------------------------
4229
+ ---------------------------------------------------------------------
4230
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4231
+ ---------------------------------------------------------------------
4232
+ -----------------------------------------------------------------------------------------------------
4233
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4234
+ -----------------------------------------------------------------------------------------------------
4235
+ ----------------------------------------------------
4236
+ SsoRoutesTest: test_should_route_/:provider/callback
4237
+ ----------------------------------------------------
4238
+ ------------------------------------------
4239
+ SsoRoutesTest: test_should_route_/sign_out
4240
+ ------------------------------------------
4241
+ ----------------------------------------------------------------------------
4242
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4243
+ ----------------------------------------------------------------------------
4244
+ ------------------------------------------------------------------------------------
4245
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4246
+ ------------------------------------------------------------------------------------
4247
+ ----------------------------------------------------
4248
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4249
+ ----------------------------------------------------
4250
+ ------------------------
4251
+ RailsSsoTest: test_truth
4252
+ ------------------------
4253
+ -----------------------------------------------------------------------------------------------------
4254
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4255
+ -----------------------------------------------------------------------------------------------------
4256
+ ---------------------------------------------------------------------
4257
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4258
+ ---------------------------------------------------------------------
4259
+ -------------------------------------------------------------
4260
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4261
+ -------------------------------------------------------------
4262
+ -------------------------------------------------------------------------------------------------------
4263
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4264
+ -------------------------------------------------------------------------------------------------------
4265
+ Processing by RailsSso::SessionsController#destroy as HTML
4266
+ Redirected to http://test.host/
4267
+ Completed 302 Found in 0ms
4268
+ ------------------------------------------------------------------------------------------------
4269
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4270
+ ------------------------------------------------------------------------------------------------
4271
+ Processing by RailsSso::SessionsController#create as HTML
4272
+ Parameters: {"provider"=>"developer"}
4273
+ Redirected to http://test.host/
4274
+ Completed 302 Found in 0ms
4275
+ ----------------------------------------------------
4276
+ SsoRoutesTest: test_should_route_/:provider/callback
4277
+ ----------------------------------------------------
4278
+ ------------------------------------------
4279
+ SsoRoutesTest: test_should_route_/sign_out
4280
+ ------------------------------------------
4281
+ ----------------------------------------------------------------------------
4282
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4283
+ ----------------------------------------------------------------------------
4284
+ ----------------------------------------------------
4285
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4286
+ ----------------------------------------------------
4287
+ ------------------------------------------------------------------------------------
4288
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4289
+ ------------------------------------------------------------------------------------
4290
+ ------------------------
4291
+ RailsSsoTest: test_truth
4292
+ ------------------------
4293
+ ----------------------------------------------------
4294
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4295
+ ----------------------------------------------------
4296
+ ------------------------------------------------------------------------------------
4297
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4298
+ ------------------------------------------------------------------------------------
4299
+ ----------------------------------------------------------------------------
4300
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4301
+ ----------------------------------------------------------------------------
4302
+ ----------------------------------------------------
4303
+ SsoRoutesTest: test_should_route_/:provider/callback
4304
+ ----------------------------------------------------
4305
+ ------------------------------------------
4306
+ SsoRoutesTest: test_should_route_/sign_out
4307
+ ------------------------------------------
4308
+ ------------------------
4309
+ RailsSsoTest: test_truth
4310
+ ------------------------
4311
+ -------------------------------------------------------------
4312
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4313
+ -------------------------------------------------------------
4314
+ -----------------------------------------------------------------------------------------------------
4315
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4316
+ -----------------------------------------------------------------------------------------------------
4317
+ ---------------------------------------------------------------------
4318
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4319
+ ---------------------------------------------------------------------
4320
+ ------------------------------------------------------------------------------------------------
4321
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4322
+ ------------------------------------------------------------------------------------------------
4323
+ Processing by RailsSso::SessionsController#create as HTML
4324
+ Parameters: {"provider"=>"developer"}
4325
+ Redirected to http://test.host/
4326
+ Completed 302 Found in 0ms
4327
+ -------------------------------------------------------------------------------------------------------
4328
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4329
+ -------------------------------------------------------------------------------------------------------
4330
+ Processing by RailsSso::SessionsController#destroy as HTML
4331
+ Redirected to http://test.host/
4332
+ Completed 302 Found in 0ms
4333
+ --------------------------------------------------------
4334
+ RailsSso::FailureAppTest: test_.call_runs_respond_action
4335
+ --------------------------------------------------------
4336
+ -----------------------------------------------------------------------------------------------------
4337
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4338
+ -----------------------------------------------------------------------------------------------------
4339
+ -------------------------------------------------------------
4340
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4341
+ -------------------------------------------------------------
4342
+ ---------------------------------------------------------------------
4343
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4344
+ ---------------------------------------------------------------------
4345
+ ------------------------
4346
+ RailsSsoTest: test_truth
4347
+ ------------------------
4348
+ ------------------------------------------------------------------------------------------------
4349
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4350
+ ------------------------------------------------------------------------------------------------
4351
+ Processing by RailsSso::SessionsController#create as HTML
4352
+ Parameters: {"provider"=>"developer"}
4353
+ Redirected to http://test.host/
4354
+ Completed 302 Found in 0ms
4355
+ -------------------------------------------------------------------------------------------------------
4356
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4357
+ -------------------------------------------------------------------------------------------------------
4358
+ Processing by RailsSso::SessionsController#destroy as HTML
4359
+ Redirected to http://test.host/
4360
+ Completed 302 Found in 0ms
4361
+ ----------------------------------------------------------------------------
4362
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4363
+ ----------------------------------------------------------------------------
4364
+ ------------------------------------------------------------------------------------
4365
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4366
+ ------------------------------------------------------------------------------------
4367
+ ----------------------------------------------------
4368
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4369
+ ----------------------------------------------------
4370
+ --------------------------------------------------------
4371
+ RailsSso::FailureAppTest: test_.call_runs_respond_action
4372
+ --------------------------------------------------------
4373
+ ------------------------------------------
4374
+ SsoRoutesTest: test_should_route_/sign_out
4375
+ ------------------------------------------
4376
+ ----------------------------------------------------
4377
+ SsoRoutesTest: test_should_route_/:provider/callback
4378
+ ----------------------------------------------------
4379
+ ------------------------------------------------------------------------------------------------
4380
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4381
+ ------------------------------------------------------------------------------------------------
4382
+ Processing by RailsSso::SessionsController#create as HTML
4383
+ Parameters: {"provider"=>"developer"}
4384
+ Redirected to http://test.host/
4385
+ Completed 302 Found in 0ms
4386
+ -------------------------------------------------------------------------------------------------------
4387
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4388
+ -------------------------------------------------------------------------------------------------------
4389
+ Processing by RailsSso::SessionsController#destroy as HTML
4390
+ Redirected to http://test.host/
4391
+ Completed 302 Found in 0ms
4392
+ --------------------------------------------------------
4393
+ RailsSso::FailureAppTest: test_.call_runs_respond_action
4394
+ --------------------------------------------------------
4395
+ ----------------------------------------------------
4396
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4397
+ ----------------------------------------------------
4398
+ ----------------------------------------------------------------------------
4399
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4400
+ ----------------------------------------------------------------------------
4401
+ ------------------------------------------------------------------------------------
4402
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4403
+ ------------------------------------------------------------------------------------
4404
+ ------------------------
4405
+ RailsSsoTest: test_truth
4406
+ ------------------------
4407
+ -----------------------------------------------------------------------------------------------------
4408
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4409
+ -----------------------------------------------------------------------------------------------------
4410
+ ---------------------------------------------------------------------
4411
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4412
+ ---------------------------------------------------------------------
4413
+ -------------------------------------------------------------
4414
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4415
+ -------------------------------------------------------------
4416
+ ------------------------------------------
4417
+ SsoRoutesTest: test_should_route_/sign_out
4418
+ ------------------------------------------
4419
+ ----------------------------------------------------
4420
+ SsoRoutesTest: test_should_route_/:provider/callback
4421
+ ----------------------------------------------------
4422
+ ----------------------------------------------------------------------------
4423
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4424
+ ----------------------------------------------------------------------------
4425
+ ------------------------------------------------------------------------------------
4426
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4427
+ ------------------------------------------------------------------------------------
4428
+ ----------------------------------------------------
4429
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4430
+ ----------------------------------------------------
4431
+ ------------------------------------------------------------------------------------------------
4432
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4433
+ ------------------------------------------------------------------------------------------------
4434
+ Processing by RailsSso::SessionsController#create as HTML
4435
+ Parameters: {"provider"=>"developer"}
4436
+ Redirected to http://test.host/
4437
+ Completed 302 Found in 0ms
4438
+ -------------------------------------------------------------------------------------------------------
4439
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4440
+ -------------------------------------------------------------------------------------------------------
4441
+ Processing by RailsSso::SessionsController#destroy as HTML
4442
+ Redirected to http://test.host/
4443
+ Completed 302 Found in 0ms
4444
+ ------------------------
4445
+ RailsSsoTest: test_truth
4446
+ ------------------------
4447
+ ----------------------------------------------------
4448
+ SsoRoutesTest: test_should_route_/:provider/callback
4449
+ ----------------------------------------------------
4450
+ ------------------------------------------
4451
+ SsoRoutesTest: test_should_route_/sign_out
4452
+ ------------------------------------------
4453
+ --------------------------------------------------------
4454
+ RailsSso::FailureAppTest: test_.call_runs_respond_action
4455
+ --------------------------------------------------------
4456
+ -------------------------------------------------------------
4457
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4458
+ -------------------------------------------------------------
4459
+ -----------------------------------------------------------------------------------------------------
4460
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4461
+ -----------------------------------------------------------------------------------------------------
4462
+ ---------------------------------------------------------------------
4463
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4464
+ ---------------------------------------------------------------------
4465
+ ------------------------
4466
+ RailsSsoTest: test_truth
4467
+ ------------------------
4468
+ --------------------------------------------------------
4469
+ RailsSso::FailureAppTest: test_.call_runs_respond_action
4470
+ --------------------------------------------------------
4471
+ ----------------------------------------------------
4472
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4473
+ ----------------------------------------------------
4474
+ ------------------------------------------------------------------------------------
4475
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4476
+ ------------------------------------------------------------------------------------
4477
+ ----------------------------------------------------------------------------
4478
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4479
+ ----------------------------------------------------------------------------
4480
+ ------------------------------------------------------------------------------------------------
4481
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4482
+ ------------------------------------------------------------------------------------------------
4483
+ Processing by RailsSso::SessionsController#create as HTML
4484
+ Parameters: {"provider"=>"developer"}
4485
+ Redirected to http://test.host/
4486
+ Completed 302 Found in 0ms
4487
+ -------------------------------------------------------------------------------------------------------
4488
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4489
+ -------------------------------------------------------------------------------------------------------
4490
+ Processing by RailsSso::SessionsController#destroy as HTML
4491
+ Redirected to http://test.host/
4492
+ Completed 302 Found in 0ms
4493
+ -------------------------------------------------------------
4494
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4495
+ -------------------------------------------------------------
4496
+ ---------------------------------------------------------------------
4497
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4498
+ ---------------------------------------------------------------------
4499
+ -----------------------------------------------------------------------------------------------------
4500
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4501
+ -----------------------------------------------------------------------------------------------------
4502
+ ----------------------------------------------------
4503
+ SsoRoutesTest: test_should_route_/:provider/callback
4504
+ ----------------------------------------------------
4505
+ ------------------------------------------
4506
+ SsoRoutesTest: test_should_route_/sign_out
4507
+ ------------------------------------------
4508
+ -------------------------------------------------------------------------------------------------------
4509
+ RailsSso::SessionsControllerTest: test_destroy_should_invalidate_access_token_and_redirect_to_root_path
4510
+ -------------------------------------------------------------------------------------------------------
4511
+ Processing by RailsSso::SessionsController#destroy as HTML
4512
+ Redirected to http://test.host/
4513
+ Completed 302 Found in 0ms
4514
+ ------------------------------------------------------------------------------------------------
4515
+ RailsSso::SessionsControllerTest: test_create_should_save_access_token_and_redirect_to_root_path
4516
+ ------------------------------------------------------------------------------------------------
4517
+ Processing by RailsSso::SessionsController#create as HTML
4518
+ Parameters: {"provider"=>"developer"}
4519
+ Redirected to http://test.host/
4520
+ Completed 302 Found in 0ms
4521
+ ----------------------------------------------------
4522
+ SsoRoutesTest: test_should_route_/:provider/callback
4523
+ ----------------------------------------------------
4524
+ ------------------------------------------
4525
+ SsoRoutesTest: test_should_route_/sign_out
4526
+ ------------------------------------------
4527
+ -----------------------------------------------------------------------------
4528
+ RailsSso::FailureAppTest: test_.call_runs_respond_action_and_redirects_to_sso
4529
+ -----------------------------------------------------------------------------
4530
+ -----------------------------------------------------------------------------------------------------
4531
+ RailsSso::FetchUserTest: test_success_call_should_fetch_user_with_access_token_and_return_parsed_data
4532
+ -----------------------------------------------------------------------------------------------------
4533
+ -------------------------------------------------------------
4534
+ RailsSso::FetchUserTest: test_unknown_call_should_raise_error
4535
+ -------------------------------------------------------------
4536
+ ---------------------------------------------------------------------
4537
+ RailsSso::FetchUserTest: test_unauthenticated_call_should_raise_error
4538
+ ---------------------------------------------------------------------
4539
+ ------------------------
4540
+ RailsSsoTest: test_truth
4541
+ ------------------------
4542
+ ----------------------------------------------------
4543
+ RailsSso::ResponseErrorTest: test_assigns_error_code
4544
+ ----------------------------------------------------
4545
+ ------------------------------------------------------------------------------------
4546
+ RailsSso::ResponseErrorTest: test_assigns_unauthenticated_error_message_from_locales
4547
+ ------------------------------------------------------------------------------------
4548
+ ----------------------------------------------------------------------------
4549
+ RailsSso::ResponseErrorTest: test_assigns_unknown_error_message_from_locales
4550
+ ----------------------------------------------------------------------------
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class RailsSso::FailureAppTest < ActiveSupport::TestCase
4
+ test ".call runs respond action and redirects to sso" do
5
+ env = {
6
+ 'REQUEST_URI' => 'http://test.host',
7
+ 'HTTP_HOST' => 'test.host'
8
+ }
9
+ response = RailsSso::FailureApp.call(env).to_a
10
+
11
+ assert_equal 302, response.first
12
+ assert_equal 'http://test.host/sso/', response.second['Location']
13
+ end
14
+ 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.3.5
4
+ version: 0.4.0
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-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: warden
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: sqlite3
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -111,10 +125,13 @@ files:
111
125
  - lib/generators/rails_sso_generator.rb
112
126
  - lib/generators/templates/sso.rb
113
127
  - lib/rails_sso.rb
128
+ - lib/rails_sso/app.rb
114
129
  - lib/rails_sso/client.rb
115
130
  - lib/rails_sso/engine.rb
131
+ - lib/rails_sso/failure_app.rb
116
132
  - lib/rails_sso/helpers.rb
117
133
  - lib/rails_sso/response_error.rb
134
+ - lib/rails_sso/sso_strategy.rb
118
135
  - lib/rails_sso/version.rb
119
136
  - lib/tasks/rails_sso_tasks.rake
120
137
  - test/controllers/rails_sso/sessions_controller_test.rb
@@ -155,7 +172,7 @@ files:
155
172
  - test/dummy/public/422.html
156
173
  - test/dummy/public/500.html
157
174
  - test/dummy/public/favicon.ico
158
- - test/lib/rails_sso/helpers_test.rb
175
+ - test/lib/rails_sso/failure_app_test.rb
159
176
  - test/lib/rails_sso/response_error_test.rb
160
177
  - test/rails_sso_test.rb
161
178
  - test/routes/sso_routes_test.rb
@@ -188,8 +205,8 @@ summary: SSO Rails Engine
188
205
  test_files:
189
206
  - test/controllers/rails_sso/sessions_controller_test.rb
190
207
  - test/rails_sso_test.rb
208
+ - test/lib/rails_sso/failure_app_test.rb
191
209
  - test/lib/rails_sso/response_error_test.rb
192
- - test/lib/rails_sso/helpers_test.rb
193
210
  - test/test_helper.rb
194
211
  - test/services/rails_sso/fetch_user_test.rb
195
212
  - test/dummy/README.rdoc
@@ -1,74 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RailsSso::HelpersTest < ActiveSupport::TestCase
4
- class DummyController
5
- def self.helper_method(*list)
6
- end
7
-
8
- include RailsSso::Helpers
9
-
10
- attr_reader :session
11
-
12
- def initialize(session)
13
- @session = session
14
- end
15
- end
16
-
17
- AccessToken = Struct.new(:token, :refresh_token)
18
-
19
- def setup
20
- RailsSso.provider_name = 'OAuth2'
21
- RailsSso.provider_key = 'provider_key'
22
- RailsSso.provider_secret = 'provider_secret'
23
-
24
- @controller = DummyController.new(session)
25
- end
26
-
27
- def session
28
- @session ||= {}
29
- end
30
-
31
- test "#current_user_data will return nil if not authenticated" do
32
- assert_nil @controller.current_user_data
33
- end
34
-
35
- test "#current_user_data will return user data if authenticated" do
36
- # TODO: pending
37
- end
38
-
39
- test "#user_signed_in? returns false if not authenticated" do
40
- refute @controller.user_signed_in?
41
- end
42
-
43
- test "#user_signed_in? returns true if authenticated" do
44
- # TODO: pending
45
- end
46
-
47
- test "#access_token returns a new OAuth2::AccessToken object" do
48
- session[:access_token] = 'abc'
49
- session[:refresh_token] = 'def'
50
-
51
- access_token = @controller.access_token
52
-
53
- assert_instance_of OAuth2::AccessToken, access_token
54
- assert_equal 'abc', access_token.token
55
- assert_equal 'def', access_token.refresh_token
56
- end
57
-
58
- test "#invalidate_access_token! will call Single Sign-Out with access token" do
59
- # @TODO: pending
60
- end
61
-
62
- test "save_access_token! will copy access and refresh token to session" do
63
- access_token = AccessToken.new('abc', '1337')
64
-
65
- @controller.save_access_token!(access_token)
66
-
67
- assert_equal 'abc', session[:access_token]
68
- assert_equal '1337', session[:refresh_token]
69
- end
70
-
71
- test "#refresh_access_token! will refresh token and copy new values" do
72
- # @TODO: pending
73
- end
74
- end