devise_jwt_auth 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/devise_jwt_auth/application_controller.rb +11 -22
- data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +3 -7
- data/app/controllers/devise_jwt_auth/concerns/set_user_by_token.rb +22 -18
- data/app/controllers/devise_jwt_auth/confirmations_controller.rb +10 -19
- data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +38 -46
- data/app/controllers/devise_jwt_auth/passwords_controller.rb +34 -36
- data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +4 -1
- data/app/controllers/devise_jwt_auth/registrations_controller.rb +40 -21
- data/app/controllers/devise_jwt_auth/sessions_controller.rb +21 -21
- data/app/controllers/devise_jwt_auth/unlocks_controller.rb +5 -4
- data/app/models/devise_jwt_auth/concerns/active_record_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +7 -14
- data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +4 -1
- data/app/models/devise_jwt_auth/concerns/user.rb +18 -11
- data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +11 -3
- data/app/validators/devise_jwt_auth_email_validator.rb +12 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/lib/devise_jwt_auth/blacklist.rb +3 -1
- data/lib/devise_jwt_auth/controllers/url_helpers.rb +1 -2
- data/lib/devise_jwt_auth/engine.rb +4 -4
- data/lib/devise_jwt_auth/rails/routes.rb +35 -24
- data/lib/devise_jwt_auth/token_factory.rb +3 -2
- data/lib/devise_jwt_auth/url.rb +2 -4
- data/lib/devise_jwt_auth/version.rb +1 -1
- data/lib/generators/devise_jwt_auth/USAGE +1 -1
- data/lib/generators/devise_jwt_auth/install_generator.rb +7 -6
- data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +27 -6
- data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +3 -2
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +6 -7
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +15 -11
- data/lib/generators/devise_jwt_auth/templates/user.rb.erb +2 -2
- data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -2
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +1 -1
- data/test/controllers/custom/custom_passwords_controller_test.rb +8 -8
- data/test/controllers/custom/custom_refresh_token_controller_test.rb +2 -3
- data/test/controllers/custom/custom_registrations_controller_test.rb +2 -2
- data/test/controllers/demo_group_controller_test.rb +0 -24
- data/test/controllers/demo_mang_controller_test.rb +4 -224
- data/test/controllers/demo_user_controller_test.rb +6 -432
- data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +5 -5
- data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +9 -10
- data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +34 -35
- data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +8 -12
- data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +12 -26
- data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +32 -34
- data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +2 -2
- data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
- data/test/controllers/overrides/passwords_controller_test.rb +1 -6
- data/test/controllers/overrides/refresh_token_controller_test.rb +1 -2
- data/test/controllers/overrides/registrations_controller_test.rb +1 -1
- data/test/dummy/app/controllers/custom/refresh_token_controller.rb +2 -1
- data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -16
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +4 -4
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +4 -16
- data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
- data/test/dummy/app/models/concerns/favorite_color.rb +11 -9
- data/test/dummy/config/application.rb +1 -0
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/environments/development.rb +2 -2
- data/test/dummy/config/environments/test.rb +11 -7
- data/test/dummy/config/initializers/devise_jwt_auth.rb +1 -0
- data/test/dummy/config/initializers/figaro.rb +1 -1
- data/test/dummy/config/initializers/omniauth.rb +2 -2
- data/test/dummy/config/routes.rb +10 -8
- data/test/dummy/config.ru +2 -2
- data/test/dummy/db/migrate/20141222035835_devise_jwt_auth_create_only_email_users.rb +9 -9
- data/test/dummy/db/migrate/20190924101113_devise_jwt_auth_create_confirmable_users.rb +6 -5
- data/test/dummy/db/schema.rb +170 -170
- data/test/dummy/tmp/generators/app/models/user.rb +8 -0
- data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +6 -7
- data/test/dummy/tmp/generators/db/migrate/{20200210193225_devise_jwt_auth_create_azpire_v1_human_resource_users.rb → 20220123023137_devise_jwt_auth_create_users.rb} +20 -17
- data/test/factories/users.rb +5 -3
- data/test/lib/devise_jwt_auth/blacklist_test.rb +2 -2
- data/test/lib/devise_jwt_auth/token_factory_test.rb +7 -7
- data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +3 -20
- data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +4 -21
- data/test/models/concerns/tokens_serialization_test.rb +68 -68
- data/test/models/user_test.rb +0 -38
- data/test/support/controllers/routes.rb +7 -5
- data/test/test_helper.rb +1 -1
- metadata +45 -71
- data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +0 -9
data/lib/devise_jwt_auth/url.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DeviseJwtAuth::Url
|
4
|
-
|
5
4
|
def self.generate(url, params = {})
|
6
5
|
uri = URI(url)
|
7
6
|
|
8
7
|
res = "#{uri.scheme}://#{uri.host}"
|
9
|
-
res += ":#{uri.port}" if
|
8
|
+
res += ":#{uri.port}" if uri.port && uri.port != 80 && uri.port != 443
|
10
9
|
res += uri.path.to_s if uri.path
|
11
10
|
query = [uri.query, params.to_query].reject(&:blank?).join('&')
|
12
11
|
res += "?#{query}"
|
@@ -28,7 +27,7 @@ module DeviseJwtAuth::Url
|
|
28
27
|
# wildcard convenience class
|
29
28
|
class Wildcat
|
30
29
|
def self.parse_to_regex(str)
|
31
|
-
escaped = Regexp.escape(str).gsub('\*','.*?')
|
30
|
+
escaped = Regexp.escape(str).gsub('\*', '.*?')
|
32
31
|
Regexp.new("^#{escaped}$", Regexp::IGNORECASE)
|
33
32
|
end
|
34
33
|
|
@@ -40,5 +39,4 @@ module DeviseJwtAuth::Url
|
|
40
39
|
!!@regex.match(str)
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
@@ -8,7 +8,7 @@ Arguments:
|
|
8
8
|
# 'User'
|
9
9
|
MOUNT_PATH # The path at which to mount the authentication routes. Default is
|
10
10
|
# 'auth'. More detail documentation is here:
|
11
|
-
# https://
|
11
|
+
# https://github.com/aarona/devise_jwt_auth
|
12
12
|
|
13
13
|
Example:
|
14
14
|
rails generate devise_jwt_auth:install User auth
|
@@ -10,12 +10,12 @@ module DeviseJwtAuth
|
|
10
10
|
class_option :primary_key_type, type: :string, desc: 'The type for primary key'
|
11
11
|
|
12
12
|
def copy_migrations
|
13
|
-
if self.class.migration_exists?('db/migrate', "devise_jwt_auth_create_#{user_class.pluralize.gsub('::','').underscore}")
|
14
|
-
say_status('skipped', "Migration 'devise_jwt_auth_create_#{user_class.pluralize.gsub('::','').underscore}' already exists")
|
13
|
+
if self.class.migration_exists?('db/migrate', "devise_jwt_auth_create_#{user_class.pluralize.gsub('::', '').underscore}")
|
14
|
+
say_status('skipped', "Migration 'devise_jwt_auth_create_#{user_class.pluralize.gsub('::', '').underscore}' already exists")
|
15
15
|
else
|
16
16
|
migration_template(
|
17
17
|
'devise_jwt_auth_create_users.rb.erb',
|
18
|
-
"db/migrate/devise_jwt_auth_create_#{user_class.pluralize.gsub('::','').underscore}.rb"
|
18
|
+
"db/migrate/devise_jwt_auth_create_#{user_class.pluralize.gsub('::', '').underscore}.rb"
|
19
19
|
)
|
20
20
|
end
|
21
21
|
end
|
@@ -26,8 +26,9 @@ module DeviseJwtAuth
|
|
26
26
|
inclusion = 'include DeviseJwtAuth::Concerns::User'
|
27
27
|
unless parse_file_for_line(fname, inclusion)
|
28
28
|
|
29
|
-
active_record_needle =
|
30
|
-
inject_into_file fname, after: "class #{user_class} < #{active_record_needle}\n" do
|
29
|
+
active_record_needle = Rails::VERSION::MAJOR == 5 ? 'ApplicationRecord' : 'ActiveRecord::Base'
|
30
|
+
inject_into_file fname, after: "class #{user_class} < #{active_record_needle}\n" do
|
31
|
+
<<-'RUBY'
|
31
32
|
# Include default devise modules.
|
32
33
|
devise :database_authenticatable, :registerable,
|
33
34
|
:recoverable, :rememberable, :trackable, :validatable,
|
@@ -43,7 +44,7 @@ module DeviseJwtAuth
|
|
43
44
|
|
44
45
|
private
|
45
46
|
|
46
|
-
def self.next_migration_number(
|
47
|
+
def self.next_migration_number(_path)
|
47
48
|
Time.zone.now.utc.strftime('%Y%m%d%H%M%S')
|
48
49
|
end
|
49
50
|
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DeviseJwtAuth
|
4
|
+
# Helper methods for installation generators.
|
2
5
|
module InstallGeneratorHelpers
|
3
6
|
class << self
|
4
7
|
def included(mod)
|
@@ -19,15 +22,19 @@ module DeviseJwtAuth
|
|
19
22
|
if File.exist?(File.join(destination_root, fname))
|
20
23
|
if parse_file_for_line(fname, line)
|
21
24
|
say_status('skipped', 'Concern is already included in the application controller.')
|
22
|
-
elsif
|
23
|
-
inject_into_file fname,
|
25
|
+
elsif rails_api?
|
26
|
+
inject_into_file fname,
|
27
|
+
after: "class ApplicationController < ActionController::API\n" do
|
28
|
+
<<-'RUBY'
|
24
29
|
include DeviseJwtAuth::Concerns::SetUserByToken
|
25
|
-
|
30
|
+
RUBY
|
26
31
|
end
|
27
32
|
else
|
28
|
-
inject_into_file fname,
|
33
|
+
inject_into_file fname,
|
34
|
+
after: "class ApplicationController < ActionController::Base\n" do
|
35
|
+
<<-'RUBY'
|
29
36
|
include DeviseJwtAuth::Concerns::SetUserByToken
|
30
|
-
|
37
|
+
RUBY
|
31
38
|
end
|
32
39
|
end
|
33
40
|
else
|
@@ -67,6 +74,20 @@ module DeviseJwtAuth
|
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
77
|
+
def ip_column
|
78
|
+
# Padded with spaces so it aligns nicely with the rest of the columns.
|
79
|
+
format('%-8s', (inet? ? 'inet' : 'string'))
|
80
|
+
end
|
81
|
+
|
82
|
+
def inet?
|
83
|
+
postgresql?
|
84
|
+
end
|
85
|
+
|
86
|
+
def postgresql?
|
87
|
+
config = ActiveRecord::Base.connection_db_config.configuration_hash
|
88
|
+
config && config['adapter'] == 'postgresql'
|
89
|
+
end
|
90
|
+
|
70
91
|
private
|
71
92
|
|
72
93
|
def insert_after_line(filename, line, str)
|
@@ -86,7 +107,7 @@ module DeviseJwtAuth
|
|
86
107
|
match
|
87
108
|
end
|
88
109
|
|
89
|
-
def
|
110
|
+
def rails_api?
|
90
111
|
fname = 'app/controllers/application_controller.rb'
|
91
112
|
line = 'class ApplicationController < ActionController::API'
|
92
113
|
parse_file_for_line(fname, line)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'install_generator_helpers'
|
4
4
|
|
5
5
|
module DeviseJwtAuth
|
6
|
+
# Adds Mongoid settings to ORM
|
6
7
|
class InstallMongoidGenerator < Rails::Generators::Base
|
7
8
|
include DeviseJwtAuth::InstallGeneratorHelpers
|
8
9
|
|
@@ -11,8 +12,8 @@ module DeviseJwtAuth
|
|
11
12
|
if File.exist?(File.join(destination_root, fname))
|
12
13
|
inclusion = 'include DeviseJwtAuth::Concerns::User'
|
13
14
|
unless parse_file_for_line(fname, inclusion)
|
14
|
-
inject_into_file fname, before: /end\s\z/ do
|
15
|
-
|
15
|
+
inject_into_file fname, before: /end\s\z/ do
|
16
|
+
<<-'RUBY'
|
16
17
|
include Mongoid::Locker
|
17
18
|
|
18
19
|
field :locker_locked_at, type: Time
|
@@ -6,7 +6,7 @@ DeviseJwtAuth.setup do |config|
|
|
6
6
|
# use the HTTP only refresh cookie that is sent during the authentication
|
7
7
|
# process and make refresh token requests.
|
8
8
|
# config.send_new_access_token_on_each_request = false
|
9
|
-
|
9
|
+
|
10
10
|
# By default, refresh token HTTP Only cookies last for 2 weeks. These tokens
|
11
11
|
# are used for requesting shorter-lived acccess tokens.
|
12
12
|
# config.refresh_token_lifespan = 2.weeks
|
@@ -29,13 +29,13 @@ DeviseJwtAuth.setup do |config|
|
|
29
29
|
# config.access_token_name = 'access-token'
|
30
30
|
|
31
31
|
# This is the refresh token encryption key. You should set this in an
|
32
|
-
# environment variable or secret key base that isn't
|
32
|
+
# environment variable or secret key base that isn't stored in a repository.
|
33
33
|
# Also, its a good idea to NOT use the same key for access tokens.
|
34
34
|
config.refresh_token_encryption_key = 'your-refresh-token-secret-key-here'
|
35
|
-
|
36
|
-
# This is the
|
37
|
-
# environment variable or secret key base that isn't
|
38
|
-
# Also, its a good idea to NOT use the same key for
|
35
|
+
|
36
|
+
# This is the access token encryption key. You should set this in an
|
37
|
+
# environment variable or secret key base that isn't stored in a repository.
|
38
|
+
# Also, its a good idea to NOT use the same key for refresh tokens.
|
39
39
|
config.access_token_encryption_key = 'your-access-token-secret-key-here'
|
40
40
|
|
41
41
|
# This route will be the prefix for all oauth2 redirect callbacks. For
|
@@ -70,5 +70,4 @@ DeviseJwtAuth.setup do |config|
|
|
70
70
|
# config.update_token_version_after_password_reset = true
|
71
71
|
# config.bypass_sign_in = true
|
72
72
|
# config.require_client_password_reset_token = false
|
73
|
-
|
74
73
|
end
|
@@ -2,12 +2,18 @@
|
|
2
2
|
|
3
3
|
class DeviseJwtAuthCreate<%= user_class.pluralize.gsub("::","") %> < ActiveRecord::Migration<%= "[#{Rails::VERSION::STRING[0..2]}]" if Rails::VERSION::MAJOR > 4 %>
|
4
4
|
def change
|
5
|
-
<% table_name = @user_class.pluralize.gsub("::","").underscore
|
6
|
-
|
5
|
+
<% table_name = @user_class.pluralize.gsub("::","").underscore -%>
|
6
|
+
create_table(:<%= table_name %><%= primary_key_type %>) do |t|
|
7
7
|
## Required
|
8
8
|
t.string :provider, null: false, default: 'email'
|
9
9
|
t.string :uid, null: false, default: ''
|
10
10
|
|
11
|
+
## User Info
|
12
|
+
t.string :name
|
13
|
+
t.string :nickname
|
14
|
+
t.string :image
|
15
|
+
t.string :email
|
16
|
+
|
11
17
|
## Database authenticatable
|
12
18
|
t.string :encrypted_password, null: false, default: ''
|
13
19
|
|
@@ -19,6 +25,13 @@ class DeviseJwtAuthCreate<%= user_class.pluralize.gsub("::","") %> < ActiveRecor
|
|
19
25
|
## Rememberable
|
20
26
|
t.datetime :remember_created_at
|
21
27
|
|
28
|
+
## Trackable
|
29
|
+
# t.integer :sign_in_count, default: 0, null: false
|
30
|
+
# t.datetime :current_sign_in_at
|
31
|
+
# t.datetime :last_sign_in_at
|
32
|
+
# t.<%= ip_column %> :current_sign_in_ip
|
33
|
+
# t.<%= ip_column %> :last_sign_in_ip
|
34
|
+
|
22
35
|
## Confirmable
|
23
36
|
t.string :confirmation_token
|
24
37
|
t.datetime :confirmed_at
|
@@ -30,15 +43,6 @@ class DeviseJwtAuthCreate<%= user_class.pluralize.gsub("::","") %> < ActiveRecor
|
|
30
43
|
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
31
44
|
# t.datetime :locked_at
|
32
45
|
|
33
|
-
## User Info
|
34
|
-
t.string :name
|
35
|
-
t.string :nickname
|
36
|
-
t.string :image
|
37
|
-
t.string :email
|
38
|
-
|
39
|
-
## Tokens
|
40
|
-
<%= json_supported_database? ? 't.json :tokens' : 't.text :tokens' %>
|
41
|
-
|
42
46
|
t.timestamps
|
43
47
|
end
|
44
48
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
class <%= user_class %> < ActiveRecord::Base
|
4
4
|
# Include default devise modules. Others available are:
|
5
|
-
# :confirmable, :lockable, :timeoutable and :omniauthable
|
5
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
6
6
|
devise :database_authenticatable, :registerable,
|
7
|
-
:recoverable, :rememberable, :
|
7
|
+
:recoverable, :rememberable, :validatable
|
8
8
|
include DeviseJwtAuth::Concerns::User
|
9
9
|
end
|
@@ -10,8 +10,8 @@ class Custom::ConfirmationsControllerTest < ActionController::TestCase
|
|
10
10
|
@redirect_url = Faker::Internet.url
|
11
11
|
@new_user = create(:user)
|
12
12
|
@new_user.send_confirmation_instructions(redirect_url: @redirect_url)
|
13
|
-
@mail
|
14
|
-
@token
|
13
|
+
@mail = ActionMailer::Base.deliveries.last
|
14
|
+
@token = @mail.body.match(/confirmation_token=([^&]*)&/)[1]
|
15
15
|
@client_config = @mail.body.match(/config=([^&]*)&/)[1]
|
16
16
|
|
17
17
|
get :show,
|
@@ -19,7 +19,7 @@ class Custom::OmniauthCallbacksControllerTest < ActionDispatch::IntegrationTest
|
|
19
19
|
end
|
20
20
|
|
21
21
|
test 'yield resource to block on omniauth_success success' do
|
22
|
-
@redirect_url = 'http://ng-
|
22
|
+
@redirect_url = 'http://ng-jwt-auth.dev/'
|
23
23
|
get '/nice_user_auth/facebook',
|
24
24
|
params: { auth_origin_url: @redirect_url,
|
25
25
|
omniauth_window_type: 'newWindow' }
|
@@ -8,20 +8,20 @@ class Custom::PasswordsControllerTest < ActionController::TestCase
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
@resource = create(:user, :confirmed)
|
11
|
-
@redirect_url = 'http://ng-
|
11
|
+
@redirect_url = 'http://ng-jwt-auth.dev'
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'yield resource to block on create success' do
|
15
15
|
post :create,
|
16
|
-
params: { email:
|
16
|
+
params: { email: @resource.email,
|
17
17
|
redirect_url: @redirect_url }
|
18
18
|
|
19
19
|
@mail = ActionMailer::Base.deliveries.last
|
20
20
|
@resource.reload
|
21
21
|
|
22
|
-
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
22
|
+
# @mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
23
23
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
24
|
-
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)
|
24
|
+
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)"/)[1]
|
25
25
|
|
26
26
|
assert @controller.create_block_called?,
|
27
27
|
'create failed to yield resource to provided block'
|
@@ -29,19 +29,19 @@ class Custom::PasswordsControllerTest < ActionController::TestCase
|
|
29
29
|
|
30
30
|
test 'yield resource to block on edit success' do
|
31
31
|
@resource = create(:user)
|
32
|
-
@redirect_url = 'http://ng-
|
32
|
+
@redirect_url = 'http://ng-jwt-auth.dev'
|
33
33
|
|
34
34
|
post :create,
|
35
|
-
params: { email:
|
35
|
+
params: { email: @resource.email,
|
36
36
|
redirect_url: @redirect_url },
|
37
37
|
xhr: true
|
38
38
|
|
39
39
|
@mail = ActionMailer::Base.deliveries.last
|
40
40
|
@resource.reload
|
41
41
|
|
42
|
-
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
42
|
+
# @mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
43
43
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
44
|
-
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)
|
44
|
+
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)"/)[1]
|
45
45
|
|
46
46
|
get :edit,
|
47
47
|
params: { reset_password_token: @mail_reset_token,
|
@@ -9,8 +9,7 @@ class Custom::RefreshTokenControllerTest < ActionDispatch::IntegrationTest
|
|
9
9
|
before do
|
10
10
|
@resource = create(:user, :confirmed)
|
11
11
|
@auth_headers = get_cookie_header(DeviseJwtAuth.refresh_token_name,
|
12
|
-
@resource.create_refresh_token
|
13
|
-
)
|
12
|
+
@resource.create_refresh_token)
|
14
13
|
end
|
15
14
|
|
16
15
|
test 'yield resource to block on refresh_token success' do
|
@@ -33,4 +32,4 @@ class Custom::RefreshTokenControllerTest < ActionDispatch::IntegrationTest
|
|
33
32
|
assert_equal @data['custom'], 'foo'
|
34
33
|
end
|
35
34
|
end
|
36
|
-
end
|
35
|
+
end
|
@@ -8,8 +8,8 @@ class Custom::RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
@create_params = attributes_for(:user,
|
11
|
-
|
12
|
-
|
11
|
+
confirm_success_url: Faker::Internet.url,
|
12
|
+
unpermitted_param: '(x_x)')
|
13
13
|
|
14
14
|
@existing_user = create(:user, :confirmed)
|
15
15
|
@auth_headers = @existing_user.create_named_token_pair
|
@@ -16,33 +16,17 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
16
16
|
@resource = create(:user, :confirmed)
|
17
17
|
@resource_auth_headers = @resource.create_named_token_pair
|
18
18
|
|
19
|
-
# @resource_token = @resource_auth_headers['access-token']
|
20
|
-
# @resource_client_id = @resource_auth_headers['client']
|
21
|
-
# @resource_expiry = @resource_auth_headers['expiry']
|
22
|
-
|
23
19
|
# mang
|
24
20
|
@mang = create(:mang_user, :confirmed)
|
25
21
|
|
26
22
|
@mang_auth_headers = @mang.create_named_token_pair
|
27
|
-
|
28
|
-
# @mang_token = @mang_auth_headers['access-token']
|
29
|
-
# @mang_client_id = @mang_auth_headers['client']
|
30
|
-
# @mang_expiry = @mang_auth_headers['expiry']
|
31
23
|
end
|
32
24
|
|
33
25
|
describe 'user access' do
|
34
26
|
before do
|
35
|
-
# ensure that request is not treated as batch request
|
36
|
-
# age_token(@resource, @resource_client_id)
|
37
|
-
|
38
27
|
get '/demo/members_only_group',
|
39
28
|
params: {},
|
40
29
|
headers: @resource_auth_headers
|
41
|
-
|
42
|
-
@resp_token = response.headers['access-token']
|
43
|
-
@resp_client_id = response.headers['client']
|
44
|
-
@resp_expiry = response.headers['expiry']
|
45
|
-
@resp_uid = response.headers['uid']
|
46
30
|
end
|
47
31
|
|
48
32
|
test 'request is successful' do
|
@@ -82,17 +66,9 @@ class DemoGroupControllerTest < ActionDispatch::IntegrationTest
|
|
82
66
|
|
83
67
|
describe 'mang access' do
|
84
68
|
before do
|
85
|
-
# ensure that request is not treated as batch request
|
86
|
-
# age_token(@mang, @mang_client_id)
|
87
|
-
|
88
69
|
get '/demo/members_only_group',
|
89
70
|
params: {},
|
90
71
|
headers: @mang_auth_headers
|
91
|
-
|
92
|
-
@resp_token = response.headers['access-token']
|
93
|
-
@resp_client_id = response.headers['client']
|
94
|
-
@resp_expiry = response.headers['expiry']
|
95
|
-
@resp_uid = response.headers['uid']
|
96
72
|
end
|
97
73
|
|
98
74
|
test 'request is successful' do
|