devise_token_auth 0.1.42 → 0.1.43.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise_token_auth might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +39 -38
- data/app/controllers/devise_token_auth/application_controller.rb +15 -0
- data/app/controllers/devise_token_auth/concerns/resource_finder.rb +38 -0
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +21 -19
- data/app/controllers/devise_token_auth/confirmations_controller.rb +12 -7
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +3 -7
- data/app/controllers/devise_token_auth/passwords_controller.rb +16 -26
- data/app/controllers/devise_token_auth/registrations_controller.rb +6 -2
- data/app/controllers/devise_token_auth/sessions_controller.rb +3 -14
- data/app/controllers/devise_token_auth/unlocks_controller.rb +105 -0
- data/app/models/devise_token_auth/concerns/user.rb +29 -12
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +5 -8
- data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
- data/app/views/devise_token_auth/omniauth_external_window.html.erb +1 -1
- data/config/initializers/devise.rb +1 -1
- data/config/locales/da-DK.yml +50 -0
- data/config/locales/en.yml +4 -0
- data/lib/devise_token_auth/controllers/helpers.rb +30 -20
- data/lib/devise_token_auth/rails/routes.rb +1 -1
- data/lib/devise_token_auth/url.rb +1 -1
- data/lib/devise_token_auth/version.rb +1 -1
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +2 -1
- data/lib/generators/devise_token_auth/templates/user.rb +1 -1
- data/test/controllers/custom/custom_confirmations_controller_test.rb +5 -10
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +15 -16
- data/test/controllers/custom/custom_passwords_controller_test.rb +28 -34
- data/test/controllers/custom/custom_registrations_controller_test.rb +23 -21
- data/test/controllers/custom/custom_sessions_controller_test.rb +16 -18
- data/test/controllers/custom/custom_token_validations_controller_test.rb +13 -11
- data/test/controllers/demo_group_controller_test.rb +19 -5
- data/test/controllers/demo_mang_controller_test.rb +37 -16
- data/test/controllers/demo_user_controller_test.rb +70 -38
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +40 -22
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +108 -82
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +127 -145
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +258 -274
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +112 -117
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +14 -15
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +194 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +8 -9
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +16 -12
- data/test/controllers/overrides/passwords_controller_test.rb +19 -15
- data/test/controllers/overrides/registrations_controller_test.rb +7 -7
- data/test/controllers/overrides/sessions_controller_test.rb +6 -6
- data/test/controllers/overrides/token_validations_controller_test.rb +7 -4
- data/test/dummy/app/controllers/auth_origin_controller.rb +2 -2
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +0 -2
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +11 -7
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +10 -8
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +1 -1
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +2 -2
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +2 -2
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +1 -1
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +1 -1
- data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +2 -1
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +1 -1
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +2 -1
- data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +2 -1
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +2 -1
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +2 -1
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +2 -1
- data/test/dummy/db/schema.rb +157 -162
- data/test/dummy/tmp/generators/app/models/user.rb +1 -1
- data/test/dummy/tmp/generators/db/migrate/{20170517171822_devise_token_auth_create_users.rb → 20171014052631_devise_token_auth_create_users.rb} +2 -1
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +5 -1
- data/test/models/user_test.rb +35 -1
- data/test/test_helper.rb +17 -11
- metadata +85 -80
@@ -12,7 +12,7 @@ module ActionDispatch::Routing
|
|
12
12
|
confirmations_ctrl = opts[:controllers][:confirmations] || "devise_token_auth/confirmations"
|
13
13
|
token_validations_ctrl = opts[:controllers][:token_validations] || "devise_token_auth/token_validations"
|
14
14
|
omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || "devise_token_auth/omniauth_callbacks"
|
15
|
-
unlocks_ctrl = opts[:controllers][:unlocks]
|
15
|
+
unlocks_ctrl = opts[:controllers][:unlocks] || "devise_token_auth/unlocks"
|
16
16
|
|
17
17
|
# define devise controller mappings
|
18
18
|
controllers = {:sessions => sessions_ctrl,
|
@@ -14,7 +14,7 @@ module DeviseTokenAuth::Url
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.whitelisted?(url)
|
17
|
-
!!DeviseTokenAuth.redirect_whitelist.find { |pattern| !!Wildcat.new(pattern).match(url) }
|
17
|
+
url.nil? || !!DeviseTokenAuth.redirect_whitelist.find { |pattern| !!Wildcat.new(pattern).match(url) }
|
18
18
|
end
|
19
19
|
|
20
20
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class DeviseTokenAuthCreate<%= user_class.pluralize %> < ActiveRecord::Migration<%=
|
1
|
+
class DeviseTokenAuthCreate<%= user_class.pluralize %> < ActiveRecord::Migration<%= "[#{Rails::VERSION::STRING[0..2]}]" if Rails::VERSION::MAJOR > 4 %>
|
2
2
|
def change
|
3
3
|
create_table(:<%= user_class.pluralize.underscore %>) do |t|
|
4
4
|
## Required
|
@@ -11,6 +11,7 @@ class DeviseTokenAuthCreate<%= user_class.pluralize %> < ActiveRecord::Migration
|
|
11
11
|
## Recoverable
|
12
12
|
t.string :reset_password_token
|
13
13
|
t.datetime :reset_password_sent_at
|
14
|
+
t.boolean :allow_password_change, :default => false
|
14
15
|
|
15
16
|
## Rememberable
|
16
17
|
t.datetime :remember_created_at
|
@@ -1,26 +1,21 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::ConfirmationsControllerTest < ActionController::TestCase
|
4
|
-
|
5
4
|
describe Custom::ConfirmationsController do
|
6
|
-
|
7
5
|
before do
|
8
6
|
@redirect_url = Faker::Internet.url
|
9
7
|
@new_user = users(:unconfirmed_email_user)
|
10
|
-
@new_user.send_confirmation_instructions(
|
11
|
-
redirect_url: @redirect_url
|
12
|
-
})
|
8
|
+
@new_user.send_confirmation_instructions(redirect_url: @redirect_url)
|
13
9
|
@mail = ActionMailer::Base.deliveries.last
|
14
10
|
@token = @mail.body.match(/confirmation_token=([^&]*)&/)[1]
|
15
11
|
@client_config = @mail.body.match(/config=([^&]*)&/)[1]
|
16
12
|
|
17
|
-
get :show,
|
13
|
+
get :show,
|
14
|
+
params: { confirmation_token: @token, redirect_url: @redirect_url }
|
18
15
|
end
|
19
16
|
|
20
|
-
test
|
21
|
-
assert @controller.show_block_called?,
|
17
|
+
test 'yield resource to block on show success' do
|
18
|
+
assert @controller.show_block_called?, 'show failed to yield resource to provided block'
|
22
19
|
end
|
23
|
-
|
24
20
|
end
|
25
|
-
|
26
21
|
end
|
@@ -1,30 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::OmniauthCallbacksControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
4
|
describe Custom::OmniauthCallbacksController do
|
6
|
-
|
7
5
|
setup do
|
8
6
|
OmniAuth.config.test_mode = true
|
9
|
-
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
7
|
+
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(
|
8
|
+
provider: 'facebook',
|
9
|
+
uid: '123545',
|
10
|
+
info: {
|
13
11
|
name: 'swong',
|
14
12
|
email: 'swongsong@yandex.ru'
|
15
13
|
}
|
16
|
-
|
14
|
+
)
|
17
15
|
end
|
18
16
|
|
19
|
-
test
|
20
|
-
@redirect_url =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
assert @controller.omniauth_success_block_called?, "omniauth_success failed to yield resource to provided block"
|
26
|
-
end
|
17
|
+
test 'yield resource to block on omniauth_success success' do
|
18
|
+
@redirect_url = 'http://ng-token-auth.dev/'
|
19
|
+
get '/nice_user_auth/facebook',
|
20
|
+
params: { auth_origin_url: @redirect_url,
|
21
|
+
omniauth_window_type: 'newWindow' }
|
27
22
|
|
28
|
-
|
23
|
+
follow_all_redirects!
|
29
24
|
|
25
|
+
assert @controller.omniauth_success_block_called?,
|
26
|
+
'omniauth_success failed to yield resource to provided block'
|
27
|
+
end
|
28
|
+
end
|
30
29
|
end
|
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::PasswordsControllerTest < ActionController::TestCase
|
4
|
-
|
5
4
|
describe Custom::PasswordsController do
|
6
|
-
|
7
5
|
before do
|
8
6
|
@resource = users(:confirmed_email_user)
|
9
7
|
@redirect_url = 'http://ng-token-auth.dev'
|
10
8
|
end
|
11
9
|
|
12
|
-
test
|
13
|
-
post :create,
|
14
|
-
|
15
|
-
|
16
|
-
}
|
10
|
+
test 'yield resource to block on create success' do
|
11
|
+
post :create,
|
12
|
+
params: { email: @resource.email,
|
13
|
+
redirect_url: @redirect_url }
|
17
14
|
|
18
15
|
@mail = ActionMailer::Base.deliveries.last
|
19
16
|
@resource.reload
|
@@ -22,17 +19,18 @@ class Custom::PasswordsControllerTest < ActionController::TestCase
|
|
22
19
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
23
20
|
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
|
24
21
|
|
25
|
-
assert @controller.create_block_called?,
|
22
|
+
assert @controller.create_block_called?,
|
23
|
+
'create failed to yield resource to provided block'
|
26
24
|
end
|
27
25
|
|
28
|
-
test
|
26
|
+
test 'yield resource to block on edit success' do
|
29
27
|
@resource = users(:unconfirmed_email_user)
|
30
28
|
@redirect_url = 'http://ng-token-auth.dev'
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
post :create,
|
31
|
+
params: { email: @resource.email,
|
32
|
+
redirect_url: @redirect_url },
|
33
|
+
xhr: true
|
36
34
|
|
37
35
|
@mail = ActionMailer::Base.deliveries.last
|
38
36
|
@resource.reload
|
@@ -41,41 +39,37 @@ class Custom::PasswordsControllerTest < ActionController::TestCase
|
|
41
39
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
42
40
|
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
get :edit,
|
43
|
+
params: { reset_password_token: @mail_reset_token,
|
44
|
+
redirect_url: @mail_redirect_url },
|
45
|
+
xhr: true
|
49
46
|
@resource.reload
|
50
|
-
assert @controller.edit_block_called?,
|
47
|
+
assert @controller.edit_block_called?,
|
48
|
+
'edit failed to yield resource to provided block'
|
51
49
|
end
|
52
50
|
|
53
|
-
test
|
51
|
+
test 'yield resource to block on update success' do
|
54
52
|
@auth_headers = @resource.create_new_auth_token
|
55
53
|
request.headers.merge!(@auth_headers)
|
56
54
|
@new_password = Faker::Internet.password
|
57
|
-
put :update,
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
assert @controller.update_block_called?, "update failed to yield resource to provided block"
|
55
|
+
put :update,
|
56
|
+
params: { password: @new_password,
|
57
|
+
password_confirmation: @new_password }
|
58
|
+
assert @controller.update_block_called?, 'update failed to yield resource to provided block'
|
62
59
|
end
|
63
60
|
|
64
|
-
test
|
61
|
+
test 'yield resource to block on update success with custom json' do
|
65
62
|
@auth_headers = @resource.create_new_auth_token
|
66
63
|
request.headers.merge!(@auth_headers)
|
67
64
|
@new_password = Faker::Internet.password
|
68
|
-
put :update,
|
69
|
-
|
70
|
-
|
71
|
-
}
|
65
|
+
put :update,
|
66
|
+
params: { password: @new_password,
|
67
|
+
password_confirmation: @new_password }
|
72
68
|
|
73
69
|
@data = JSON.parse(response.body)
|
74
70
|
|
75
|
-
assert @controller.update_block_called?,
|
76
|
-
assert_equal @data[
|
71
|
+
assert @controller.update_block_called?, 'update failed to yield resource to provided block'
|
72
|
+
assert_equal @data['custom'], 'foo'
|
77
73
|
end
|
78
|
-
|
79
74
|
end
|
80
|
-
|
81
75
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
4
|
describe Custom::RegistrationsController do
|
6
|
-
|
7
5
|
setup do
|
8
6
|
@create_params = {
|
9
7
|
email: Faker::Internet.email,
|
10
|
-
password:
|
11
|
-
password_confirmation:
|
8
|
+
password: 'secret123',
|
9
|
+
password_confirmation: 'secret123',
|
12
10
|
confirm_success_url: Faker::Internet.url,
|
13
11
|
unpermitted_param: '(x_x)'
|
14
12
|
}
|
@@ -21,32 +19,36 @@ class Custom::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
|
21
19
|
age_token(@existing_user, @client_id)
|
22
20
|
end
|
23
21
|
|
24
|
-
test
|
25
|
-
post '/nice_user_auth', @create_params
|
26
|
-
assert @controller.create_block_called?,
|
22
|
+
test 'yield resource to block on create success' do
|
23
|
+
post '/nice_user_auth', params: @create_params
|
24
|
+
assert @controller.create_block_called?,
|
25
|
+
'create failed to yield resource to provided block'
|
27
26
|
end
|
28
27
|
|
29
|
-
test
|
30
|
-
post '/nice_user_auth', @create_params
|
28
|
+
test 'yield resource to block on create success with custom json' do
|
29
|
+
post '/nice_user_auth', params: @create_params
|
31
30
|
|
32
31
|
@data = JSON.parse(response.body)
|
33
32
|
|
34
|
-
assert @controller.create_block_called?,
|
35
|
-
|
33
|
+
assert @controller.create_block_called?,
|
34
|
+
'create failed to yield resource to provided block'
|
35
|
+
assert_equal @data['custom'], 'foo'
|
36
36
|
end
|
37
37
|
|
38
|
-
test
|
39
|
-
put '/nice_user_auth',
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
test 'yield resource to block on update success' do
|
39
|
+
put '/nice_user_auth',
|
40
|
+
params: {
|
41
|
+
nickname: "Ol' Sunshine-face"
|
42
|
+
},
|
43
|
+
headers: @auth_headers
|
44
|
+
assert @controller.update_block_called?,
|
45
|
+
'update failed to yield resource to provided block'
|
43
46
|
end
|
44
47
|
|
45
|
-
test
|
46
|
-
delete '/nice_user_auth', @auth_headers
|
47
|
-
assert @controller.destroy_block_called?,
|
48
|
+
test 'yield resource to block on destroy success' do
|
49
|
+
delete '/nice_user_auth', headers: @auth_headers
|
50
|
+
assert @controller.destroy_block_called?,
|
51
|
+
'destroy failed to yield resource to provided block'
|
48
52
|
end
|
49
|
-
|
50
53
|
end
|
51
|
-
|
52
54
|
end
|
@@ -1,39 +1,37 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::SessionsControllerTest < ActionController::TestCase
|
4
|
-
|
5
4
|
describe Custom::SessionsController do
|
6
|
-
|
7
5
|
before do
|
8
6
|
@existing_user = users(:confirmed_email_user)
|
9
7
|
@existing_user.skip_confirmation!
|
10
8
|
@existing_user.save!
|
11
9
|
end
|
12
10
|
|
13
|
-
test
|
14
|
-
post :create,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
test 'yield resource to block on create success' do
|
12
|
+
post :create,
|
13
|
+
params: {
|
14
|
+
email: @existing_user.email,
|
15
|
+
password: 'secret123'
|
16
|
+
}
|
17
|
+
assert @controller.create_block_called?,
|
18
|
+
'create failed to yield resource to provided block'
|
19
19
|
end
|
20
20
|
|
21
|
-
test
|
21
|
+
test 'yield resource to block on destroy success' do
|
22
22
|
@auth_headers = @existing_user.create_new_auth_token
|
23
23
|
request.headers.merge!(@auth_headers)
|
24
24
|
delete :destroy, format: :json
|
25
|
-
assert @controller.destroy_block_called?,
|
25
|
+
assert @controller.destroy_block_called?,
|
26
|
+
'destroy failed to yield resource to provided block'
|
26
27
|
end
|
27
28
|
|
28
|
-
test
|
29
|
-
post :create,
|
30
|
-
|
31
|
-
|
32
|
-
}
|
29
|
+
test 'render method override' do
|
30
|
+
post :create,
|
31
|
+
params: { email: @existing_user.email,
|
32
|
+
password: 'secret123' }
|
33
33
|
@data = JSON.parse(response.body)
|
34
|
-
assert_equal @data[
|
34
|
+
assert_equal @data['custom'], 'foo'
|
35
35
|
end
|
36
|
-
|
37
36
|
end
|
38
|
-
|
39
37
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class Custom::TokenValidationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
4
|
describe Custom::TokenValidationsController do
|
6
|
-
|
7
5
|
before do
|
8
6
|
@resource = nice_users(:confirmed_email_user)
|
9
7
|
@resource.skip_confirmation!
|
@@ -19,20 +17,24 @@ class Custom::TokenValidationsControllerTest < ActionDispatch::IntegrationTest
|
|
19
17
|
age_token(@resource, @client_id)
|
20
18
|
end
|
21
19
|
|
22
|
-
test
|
23
|
-
get '/nice_user_auth/validate_token',
|
24
|
-
|
20
|
+
test 'yield resource to block on validate_token success' do
|
21
|
+
get '/nice_user_auth/validate_token',
|
22
|
+
params: {},
|
23
|
+
headers: @auth_headers
|
24
|
+
assert @controller.validate_token_block_called?,
|
25
|
+
'validate_token failed to yield resource to provided block'
|
25
26
|
end
|
26
27
|
|
27
|
-
test
|
28
|
-
get '/nice_user_auth/validate_token',
|
28
|
+
test 'yield resource to block on validate_token success with custom json' do
|
29
|
+
get '/nice_user_auth/validate_token',
|
30
|
+
params: {},
|
31
|
+
headers: @auth_headers
|
29
32
|
|
30
33
|
@data = JSON.parse(response.body)
|
31
34
|
|
32
|
-
assert @controller.validate_token_block_called?,
|
33
|
-
|
35
|
+
assert @controller.validate_token_block_called?,
|
36
|
+
'validate_token failed to yield resource to provided block'
|
37
|
+
assert_equal @data['custom'], 'foo'
|
34
38
|
end
|
35
|
-
|
36
39
|
end
|
37
|
-
|
38
40
|
end
|
@@ -8,7 +8,7 @@ require 'test_helper'
|
|
8
8
|
|
9
9
|
class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
10
10
|
describe DemoGroupController do
|
11
|
-
describe
|
11
|
+
describe 'Token access' do
|
12
12
|
before do
|
13
13
|
# user
|
14
14
|
@resource = users(:confirmed_email_user)
|
@@ -38,7 +38,9 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
38
38
|
# ensure that request is not treated as batch request
|
39
39
|
age_token(@resource, @resource_client_id)
|
40
40
|
|
41
|
-
get '/demo/members_only_group',
|
41
|
+
get '/demo/members_only_group',
|
42
|
+
params: {},
|
43
|
+
headers: @resource_auth_headers
|
42
44
|
|
43
45
|
@resp_token = response.headers['access-token']
|
44
46
|
@resp_client_id = response.headers['client']
|
@@ -74,6 +76,10 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
74
76
|
it 'should define member_signed_in?' do
|
75
77
|
assert @controller.current_members.include? @resource
|
76
78
|
end
|
79
|
+
|
80
|
+
it 'should define render_authenticate_error' do
|
81
|
+
assert @controller.methods.include?(:render_authenticate_error)
|
82
|
+
end
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
@@ -82,7 +88,9 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
82
88
|
# ensure that request is not treated as batch request
|
83
89
|
age_token(@mang, @mang_client_id)
|
84
90
|
|
85
|
-
get '/demo/members_only_group',
|
91
|
+
get '/demo/members_only_group',
|
92
|
+
params: {},
|
93
|
+
headers: @mang_auth_headers
|
86
94
|
|
87
95
|
@resp_token = response.headers['access-token']
|
88
96
|
@resp_client_id = response.headers['client']
|
@@ -118,12 +126,18 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
118
126
|
it 'should define member_signed_in?' do
|
119
127
|
assert @controller.current_members.include? @mang
|
120
128
|
end
|
129
|
+
|
130
|
+
it 'should define render_authenticate_error' do
|
131
|
+
assert @controller.methods.include?(:render_authenticate_error)
|
132
|
+
end
|
121
133
|
end
|
122
134
|
end
|
123
135
|
|
124
136
|
describe 'failed access' do
|
125
137
|
before do
|
126
|
-
get '/demo/members_only_group',
|
138
|
+
get '/demo/members_only_group',
|
139
|
+
params: {},
|
140
|
+
headers: @mang_auth_headers.merge('access-token' => 'bogus')
|
127
141
|
end
|
128
142
|
|
129
143
|
it 'should not return any auth headers' do
|
@@ -132,7 +146,7 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
132
146
|
|
133
147
|
it 'should return error: unauthorized status' do
|
134
148
|
assert_equal 401, response.status
|
135
|
-
end
|
149
|
+
end
|
136
150
|
end
|
137
151
|
end
|
138
152
|
end
|