devise_g5_authenticatable 0.3.0 → 1.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +29 -7
- data/Appraisals +21 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +11 -7
- data/README.md +6 -6
- data/Rakefile +6 -5
- data/app/controllers/devise_g5_authenticatable/registrations_controller.rb +3 -0
- data/app/controllers/devise_g5_authenticatable/sessions_controller.rb +9 -5
- data/config/initializers/devise_g5_authenticatable.rb +2 -0
- data/devise_g5_authenticatable.gemspec +6 -5
- data/gemfiles/rails_4.1.gemfile +26 -0
- data/gemfiles/rails_4.2.gemfile +26 -0
- data/gemfiles/rails_5.0.gemfile +26 -0
- data/gemfiles/rails_5.1.gemfile +26 -0
- data/lib/devise_g5_authenticatable/controllers/helpers.rb +5 -0
- data/lib/devise_g5_authenticatable/controllers/url_helpers.rb +3 -0
- data/lib/devise_g5_authenticatable/engine.rb +4 -1
- data/lib/devise_g5_authenticatable/g5/auth_password_validator.rb +6 -1
- data/lib/devise_g5_authenticatable/g5/auth_user_creator.rb +16 -15
- data/lib/devise_g5_authenticatable/g5/auth_user_updater.rb +11 -5
- data/lib/devise_g5_authenticatable/g5/user_exporter.rb +11 -6
- data/lib/devise_g5_authenticatable/g5.rb +2 -0
- data/lib/devise_g5_authenticatable/hooks/g5_authenticatable.rb +8 -3
- data/lib/devise_g5_authenticatable/models/g5_authenticatable.rb +38 -26
- data/lib/devise_g5_authenticatable/models/protected_attributes.rb +11 -2
- data/lib/devise_g5_authenticatable/omniauth.rb +8 -2
- data/lib/devise_g5_authenticatable/routes.rb +48 -35
- data/lib/devise_g5_authenticatable/version.rb +3 -1
- data/lib/devise_g5_authenticatable.rb +4 -1
- data/spec/controllers/helpers_spec.rb +54 -49
- data/spec/controllers/sessions_controller_spec.rb +67 -39
- data/spec/controllers/url_helpers_spec.rb +78 -78
- data/spec/dummy/app/views/{anonymous → devise}/new.html.erb +0 -0
- data/spec/dummy/config/environments/test.rb +20 -4
- data/spec/dummy/config/initializers/devise.rb +5 -1
- data/spec/dummy/config/initializers/rails_compatibility.rb +10 -0
- data/spec/dummy/db/migrate/20131230235849_devise_create_users.rb +3 -1
- data/spec/dummy/db/migrate/20140102213131_drop_database_authenticatable.rb +3 -1
- data/spec/dummy/db/migrate/20140103032308_drop_recoverable.rb +3 -1
- data/spec/dummy/db/migrate/20140103042329_drop_rememberable.rb +3 -1
- data/spec/dummy/db/migrate/20140103174810_add_omniauth_columns_to_users.rb +3 -1
- data/spec/dummy/db/migrate/20140103191601_add_email_back_to_user.rb +3 -1
- data/spec/dummy/db/migrate/20140113202948_devise_create_admins.rb +3 -1
- data/spec/dummy/db/migrate/20140113233821_add_provider_and_uid_to_admins.rb +3 -1
- data/spec/dummy/db/schema.rb +29 -29
- data/spec/factories/admin.rb +2 -0
- data/spec/factories/user.rb +2 -0
- data/spec/features/edit_registration_spec.rb +22 -13
- data/spec/features/registration_spec.rb +13 -8
- data/spec/features/sign_in_spec.rb +4 -2
- data/spec/features/sign_out_spec.rb +4 -2
- data/spec/features/token_validation_spec.rb +24 -14
- data/spec/g5/auth_password_validator_spec.rb +28 -15
- data/spec/g5/auth_user_creator_spec.rb +29 -22
- data/spec/g5/auth_user_updater_spec.rb +23 -16
- data/spec/g5/user_exporter_spec.rb +36 -31
- data/spec/models/g5_authenticatable_spec.rb +78 -38
- data/spec/models/protected_attributes_spec.rb +24 -19
- data/spec/rails_helper.rb +46 -0
- data/spec/routing/registrations_routing_spec.rb +43 -27
- data/spec/routing/sessions_routing_spec.rb +46 -29
- data/spec/spec_helper.rb +93 -27
- data/spec/support/controller_test_helpers.rb +15 -0
- data/spec/support/devise.rb +9 -1
- data/spec/support/shared_contexts/custom_router.rb +16 -0
- data/spec/support/shared_contexts/oauth_error.rb +4 -2
- data/spec/support/shared_contexts/rake.rb +10 -4
- data/spec/support/shared_examples/registration_error.rb +3 -1
- data/spec/support/{user_feature_methods.rb → user_omniauth_methods.rb} +9 -5
- data/spec/tasks/export_users_spec.rb +5 -3
- metadata +30 -26
- data/circle.yml +0 -4
- data/spec/support/omniauth.rb +0 -3
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
4
|
# Many of these configuration options can be set straight in your model.
|
3
5
|
Devise.setup do |config|
|
@@ -23,7 +25,9 @@ Devise.setup do |config|
|
|
23
25
|
|
24
26
|
# Require optional support for protected_attributes in devise
|
25
27
|
# models
|
26
|
-
|
28
|
+
if Rails.version.starts_with?('4')
|
29
|
+
require 'devise_g5_authenticatable/models/protected_attributes'
|
30
|
+
end
|
27
31
|
|
28
32
|
# ==> Configuration for any authentication mechanism
|
29
33
|
# Configure which keys are used when authenticating a user. The default is
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Support migration version syntax in rails 4
|
4
|
+
ActiveSupport.on_load(:active_record) do
|
5
|
+
unless ActiveRecord::Migration.respond_to?(:[])
|
6
|
+
ActiveRecord::Migration.define_singleton_method(:[]) do |version|
|
7
|
+
self if version.to_s.starts_with?('4')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -9,42 +8,43 @@
|
|
9
8
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
9
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
10
|
#
|
12
|
-
# It's strongly recommended
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(:
|
13
|
+
ActiveRecord::Schema.define(version: 20140113233821) do
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
# These are extensions that must be enabled in order to support this database
|
16
|
+
enable_extension "plpgsql"
|
17
|
+
|
18
|
+
create_table "admins", id: :serial, force: :cascade do |t|
|
19
|
+
t.string "email", default: "", null: false
|
20
|
+
t.integer "sign_in_count", default: 0, null: false
|
19
21
|
t.datetime "current_sign_in_at"
|
20
22
|
t.datetime "last_sign_in_at"
|
21
|
-
t.string
|
22
|
-
t.string
|
23
|
-
t.datetime "created_at"
|
24
|
-
t.datetime "updated_at"
|
25
|
-
t.string
|
26
|
-
t.string
|
27
|
-
t.string
|
23
|
+
t.string "current_sign_in_ip"
|
24
|
+
t.string "last_sign_in_ip"
|
25
|
+
t.datetime "created_at"
|
26
|
+
t.datetime "updated_at"
|
27
|
+
t.string "provider"
|
28
|
+
t.string "uid"
|
29
|
+
t.string "g5_access_token"
|
30
|
+
t.index ["email"], name: "index_admins_on_email", unique: true
|
31
|
+
t.index ["provider", "uid"], name: "index_admins_on_provider_and_uid", unique: true
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
create_table "users", :force => true do |t|
|
34
|
-
t.integer "sign_in_count", :default => 0, :null => false
|
34
|
+
create_table "users", id: :serial, force: :cascade do |t|
|
35
|
+
t.integer "sign_in_count", default: 0, null: false
|
35
36
|
t.datetime "current_sign_in_at"
|
36
37
|
t.datetime "last_sign_in_at"
|
37
|
-
t.string
|
38
|
-
t.string
|
39
|
-
t.datetime "created_at"
|
40
|
-
t.datetime "updated_at"
|
41
|
-
t.string
|
42
|
-
t.string
|
43
|
-
t.string
|
44
|
-
t.string
|
38
|
+
t.string "current_sign_in_ip"
|
39
|
+
t.string "last_sign_in_ip"
|
40
|
+
t.datetime "created_at"
|
41
|
+
t.datetime "updated_at"
|
42
|
+
t.string "uid"
|
43
|
+
t.string "provider"
|
44
|
+
t.string "g5_access_token"
|
45
|
+
t.string "email", default: "", null: false
|
46
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
47
|
+
t.index ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true
|
45
48
|
end
|
46
49
|
|
47
|
-
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
48
|
-
add_index "users", ["provider", "uid"], :name => "index_users_on_provider_and_uid", :unique => true
|
49
|
-
|
50
50
|
end
|
data/spec/factories/admin.rb
CHANGED
data/spec/factories/user.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'Editing a user registration' do
|
4
6
|
subject(:update_registration) { click_button 'Update' }
|
5
7
|
|
6
8
|
let(:user) { create(:user) }
|
7
9
|
|
8
|
-
let(:auth_client)
|
10
|
+
let(:auth_client) do
|
11
|
+
double(:auth_client, update_user: auth_user, me: auth_user)
|
12
|
+
end
|
9
13
|
|
10
14
|
let(:auth_user) { double(:auth_user, id: user.uid, email: user.email) }
|
11
15
|
before do
|
12
|
-
allow(G5AuthenticationClient::Client).to receive(:new)
|
16
|
+
allow(G5AuthenticationClient::Client).to receive(:new)
|
17
|
+
.and_return(auth_client)
|
13
18
|
end
|
14
19
|
|
15
20
|
before do
|
@@ -34,10 +39,11 @@ describe 'Editing a user registration' do
|
|
34
39
|
end
|
35
40
|
|
36
41
|
it 'should update the email on the auth server' do
|
37
|
-
expect(auth_client).to receive(:update_user)
|
38
|
-
|
39
|
-
|
40
|
-
|
42
|
+
expect(auth_client).to receive(:update_user)
|
43
|
+
.with(id: user.uid,
|
44
|
+
email: email,
|
45
|
+
password: nil,
|
46
|
+
password_confirmation: nil)
|
41
47
|
update_registration
|
42
48
|
end
|
43
49
|
end
|
@@ -46,10 +52,11 @@ describe 'Editing a user registration' do
|
|
46
52
|
let(:password) { 'a brand new password' }
|
47
53
|
|
48
54
|
it 'should update the password on the auth server' do
|
49
|
-
expect(auth_client).to receive(:update_user)
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
expect(auth_client).to receive(:update_user)
|
56
|
+
.with(id: user.uid,
|
57
|
+
email: email,
|
58
|
+
password: password,
|
59
|
+
password_confirmation: password_confirmation)
|
53
60
|
update_registration
|
54
61
|
end
|
55
62
|
end
|
@@ -70,7 +77,9 @@ describe 'Editing a user registration' do
|
|
70
77
|
|
71
78
|
context 'when the auth server returns an error' do
|
72
79
|
include_context 'OAuth2::Error'
|
73
|
-
before
|
80
|
+
before do
|
81
|
+
allow(auth_client).to receive(:update_user).and_raise(oauth_error)
|
82
|
+
end
|
74
83
|
|
75
84
|
it 'should display an error message' do
|
76
85
|
update_registration
|
@@ -1,12 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'User registration' do
|
4
6
|
subject(:register_user) { click_button 'Sign up' }
|
5
7
|
|
6
8
|
let(:auth_client) { double(:auth_client, create_user: auth_user) }
|
7
9
|
let(:auth_user) { double(:auth_user, id: uid, email: email) }
|
8
10
|
before do
|
9
|
-
allow(G5AuthenticationClient::Client).to receive(:new)
|
11
|
+
allow(G5AuthenticationClient::Client).to receive(:new)
|
12
|
+
.and_return(auth_client)
|
10
13
|
end
|
11
14
|
|
12
15
|
before do
|
@@ -32,11 +35,11 @@ describe 'User registration' do
|
|
32
35
|
end
|
33
36
|
|
34
37
|
it 'should create the user on the auth server' do
|
35
|
-
expect(auth_client).to receive(:create_user)
|
36
|
-
with(
|
38
|
+
expect(auth_client).to receive(:create_user)
|
39
|
+
.with(email: email,
|
37
40
|
password: password,
|
38
|
-
password_confirmation: password_confirmation
|
39
|
-
and_return(auth_user)
|
41
|
+
password_confirmation: password_confirmation)
|
42
|
+
.and_return(auth_user)
|
40
43
|
register_user
|
41
44
|
end
|
42
45
|
|
@@ -52,7 +55,9 @@ describe 'User registration' do
|
|
52
55
|
|
53
56
|
context 'when there is an error on the auth server' do
|
54
57
|
include_context 'OAuth2::Error'
|
55
|
-
before
|
58
|
+
before do
|
59
|
+
allow(auth_client).to receive(:create_user).and_raise(oauth_error)
|
60
|
+
end
|
56
61
|
|
57
62
|
it 'should display an error message' do
|
58
63
|
register_user
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'Signing out' do
|
4
6
|
it 'should redirect to the auth server'
|
5
7
|
it 'should pass the root url as a param to the redirect'
|
6
8
|
it 'should not allow the user to access protected pages'
|
@@ -1,14 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'Token validation per request' do
|
4
6
|
let(:user) { create(:user) }
|
5
7
|
let(:protected_path) { edit_user_registration_path }
|
6
8
|
let(:token_info_url) { 'http://auth.g5search.com/oauth/token/info' }
|
7
9
|
|
10
|
+
let(:auth_header) { { 'Authorization' => "Bearer #{user.g5_access_token}" } }
|
11
|
+
|
8
12
|
before do
|
9
|
-
stub_request(:get, token_info_url)
|
10
|
-
with(headers:
|
11
|
-
to_return(status: 200, body: '', headers: {})
|
13
|
+
stub_request(:get, token_info_url)
|
14
|
+
.with(headers: auth_header)
|
15
|
+
.to_return(status: 200, body: '', headers: {})
|
12
16
|
end
|
13
17
|
|
14
18
|
before do
|
@@ -42,8 +46,8 @@ describe 'Token validation per request' do
|
|
42
46
|
before { visit protected_path }
|
43
47
|
|
44
48
|
it 'should validate the token against the auth server' do
|
45
|
-
expect(a_request(:get, token_info_url).
|
46
|
-
|
49
|
+
expect(a_request(:get, token_info_url).with(headers: auth_header))
|
50
|
+
.to have_been_made
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'should allow the user to access the protected page' do
|
@@ -53,13 +57,19 @@ describe 'Token validation per request' do
|
|
53
57
|
|
54
58
|
context 'when the access_token has been invalidated' do
|
55
59
|
before do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
response_headers = {
|
61
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
62
|
+
'Cache-Control' => 'no-cache'
|
63
|
+
}
|
64
|
+
response_body = {
|
65
|
+
'error' => 'invalid_token',
|
66
|
+
'error_description' => 'The access token expired'
|
67
|
+
}
|
68
|
+
stub_request(:get, token_info_url)
|
69
|
+
.with(headers: auth_header)
|
70
|
+
.to_return(status: 401,
|
71
|
+
headers: response_headers,
|
72
|
+
body: response_body.to_json)
|
63
73
|
visit protected_path
|
64
74
|
end
|
65
75
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe Devise::G5::AuthPasswordValidator do
|
4
6
|
let(:validator) { described_class.new(model) }
|
5
7
|
|
6
8
|
let(:model) { build_stubbed(:user) }
|
@@ -14,24 +16,26 @@ describe Devise::G5::AuthPasswordValidator do
|
|
14
16
|
let(:auth_user) { double(:auth_user, uid: model.uid, email: model.email) }
|
15
17
|
|
16
18
|
let(:oauth_error) { OAuth2::Error.new(response) }
|
17
|
-
let(:response)
|
19
|
+
let(:response) do
|
20
|
+
double(:oauth_response, parsed: oauth_error_hash).as_null_object
|
21
|
+
end
|
18
22
|
|
19
23
|
before do
|
20
|
-
allow(G5AuthenticationClient::Client).to receive(:new)
|
21
|
-
and_return(auth_client)
|
24
|
+
allow(G5AuthenticationClient::Client).to receive(:new)
|
25
|
+
.and_return(auth_client)
|
22
26
|
end
|
23
27
|
|
24
28
|
context 'with valid password' do
|
25
29
|
before { valid_password? }
|
26
30
|
|
27
31
|
it 'should initialize auth client with the username' do
|
28
|
-
expect(G5AuthenticationClient::Client).to have_received(:new)
|
29
|
-
with(hash_including(username: model.email))
|
32
|
+
expect(G5AuthenticationClient::Client).to have_received(:new)
|
33
|
+
.with(hash_including(username: model.email))
|
30
34
|
end
|
31
35
|
|
32
36
|
it 'should initialize auth client with the password' do
|
33
|
-
expect(G5AuthenticationClient::Client).to have_received(:new)
|
34
|
-
with(hash_including(password: password))
|
37
|
+
expect(G5AuthenticationClient::Client).to have_received(:new)
|
38
|
+
.with(hash_including(password: password))
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'should retrieve the auth user associated with these credentials' do
|
@@ -47,8 +51,10 @@ describe Devise::G5::AuthPasswordValidator do
|
|
47
51
|
before { allow(auth_client).to receive(:me).and_raise(oauth_error) }
|
48
52
|
|
49
53
|
let(:oauth_error_hash) do
|
50
|
-
{'error' => 'invalid_resource_owner',
|
51
|
-
|
54
|
+
{ 'error' => 'invalid_resource_owner',
|
55
|
+
'error_description' => 'The provided resource owner credentials are' \
|
56
|
+
' not valid, or resource owner cannot be' \
|
57
|
+
' found.' }
|
52
58
|
end
|
53
59
|
|
54
60
|
it 'should return false' do
|
@@ -57,8 +63,14 @@ describe Devise::G5::AuthPasswordValidator do
|
|
57
63
|
end
|
58
64
|
|
59
65
|
context 'with blank password' do
|
60
|
-
before
|
61
|
-
|
66
|
+
before do
|
67
|
+
allow(auth_client).to receive(:me)
|
68
|
+
.and_raise(RuntimeError, runtime_error)
|
69
|
+
end
|
70
|
+
let(:runtime_error) do
|
71
|
+
'Insufficient credentials for access token. Supply a' \
|
72
|
+
' username/password or authentication code.'
|
73
|
+
end
|
62
74
|
|
63
75
|
it 'should return false' do
|
64
76
|
expect(valid_password?).to be_falsey
|
@@ -69,8 +81,9 @@ describe Devise::G5::AuthPasswordValidator do
|
|
69
81
|
before { allow(auth_client).to receive(:me).and_raise(oauth_error) }
|
70
82
|
|
71
83
|
let(:oauth_error_hash) do
|
72
|
-
{'error' => 'unauthorized_client',
|
73
|
-
|
84
|
+
{ 'error' => 'unauthorized_client',
|
85
|
+
'error_description' => 'The client is not authorized to perform' \
|
86
|
+
' this request using this method.' }
|
74
87
|
end
|
75
88
|
|
76
89
|
it 'should re-raise the error' do
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe Devise::G5::AuthUserCreator do
|
4
6
|
let(:creator) { described_class.new(model) }
|
5
7
|
|
6
8
|
describe '#create' do
|
@@ -19,23 +21,26 @@ describe Devise::G5::AuthUserCreator do
|
|
19
21
|
|
20
22
|
let(:auth_client) { double(:g5_authentication_client) }
|
21
23
|
|
22
|
-
let(:auth_user)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
let(:auth_user) do
|
25
|
+
double(:auth_user, id: uid,
|
26
|
+
email: model.email,
|
27
|
+
password: other_password,
|
28
|
+
clean_up_passwords: nil,
|
29
|
+
to_hash: {})
|
30
|
+
end
|
28
31
|
|
29
32
|
let(:uid) { 'remote-auth-user-42' }
|
30
33
|
|
31
34
|
before do
|
32
|
-
allow(G5AuthenticationClient::Client).to receive(:new)
|
35
|
+
allow(G5AuthenticationClient::Client).to receive(:new)
|
36
|
+
.and_return(auth_client)
|
33
37
|
end
|
34
38
|
|
35
39
|
context 'when there is an existing auth user' do
|
36
40
|
before do
|
37
41
|
model.uid = nil
|
38
|
-
allow(auth_client).to receive(:create_user)
|
42
|
+
allow(auth_client).to receive(:create_user)
|
43
|
+
.and_raise(StandardError, 'Email has already been taken')
|
39
44
|
allow(auth_client).to receive(:find_user_by_email).and_return(auth_user)
|
40
45
|
allow(auth_client).to receive(:update_user)
|
41
46
|
end
|
@@ -43,7 +48,7 @@ describe Devise::G5::AuthUserCreator do
|
|
43
48
|
it 'should create the local user with the existing uid' do
|
44
49
|
allow(auth_user).to receive(:password=)
|
45
50
|
allow(auth_user).to receive(:password_confirmation=)
|
46
|
-
expect{ create }.to change
|
51
|
+
expect { create }.to change { model.uid }.to(uid)
|
47
52
|
end
|
48
53
|
|
49
54
|
it 'should reset the password' do
|
@@ -67,23 +72,25 @@ describe Devise::G5::AuthUserCreator do
|
|
67
72
|
before { create }
|
68
73
|
|
69
74
|
it 'should use the token for updated_by user to call g5 auth' do
|
70
|
-
expect(G5AuthenticationClient::Client).to have_received(:new)
|
71
|
-
with(access_token: updated_by.g5_access_token)
|
75
|
+
expect(G5AuthenticationClient::Client).to have_received(:new)
|
76
|
+
.with(access_token: updated_by.g5_access_token)
|
72
77
|
end
|
73
78
|
|
74
79
|
it 'should create a new auth user with the correct email' do
|
75
|
-
expect(auth_client).to have_received(:create_user)
|
76
|
-
with(hash_including(email: model.email))
|
80
|
+
expect(auth_client).to have_received(:create_user)
|
81
|
+
.with(hash_including(email: model.email))
|
77
82
|
end
|
78
83
|
|
79
84
|
it 'should create a new auth user with the correct password' do
|
80
|
-
expect(auth_client).to have_received(:create_user)
|
81
|
-
with(hash_including(password: password))
|
85
|
+
expect(auth_client).to have_received(:create_user)
|
86
|
+
.with(hash_including(password: password))
|
82
87
|
end
|
83
88
|
|
84
|
-
it '
|
85
|
-
expect(auth_client).to have_received(:create_user)
|
86
|
-
with(
|
89
|
+
it 'creates a new auth user with the correct password confirmation' do
|
90
|
+
expect(auth_client).to have_received(:create_user)
|
91
|
+
.with(
|
92
|
+
hash_including(password_confirmation: password_confirmation)
|
93
|
+
)
|
87
94
|
end
|
88
95
|
|
89
96
|
it 'should reset the password' do
|
@@ -109,8 +116,8 @@ describe Devise::G5::AuthUserCreator do
|
|
109
116
|
before { create }
|
110
117
|
|
111
118
|
it 'should use the user token to call g5 auth' do
|
112
|
-
expect(G5AuthenticationClient::Client).to have_received(:new)
|
113
|
-
with(access_token: model.g5_access_token)
|
119
|
+
expect(G5AuthenticationClient::Client).to have_received(:new)
|
120
|
+
.with(access_token: model.g5_access_token)
|
114
121
|
end
|
115
122
|
end
|
116
123
|
end
|