From 5467260528018774c8baec65f3cbf692bb3d93b7 Mon Sep 17 00:00:00 2001 From: Patricio Cano Date: Thu, 30 Jun 2016 14:54:07 -0500 Subject: Added tests for 2FA check on OAuth request --- spec/support/login_helpers.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spec/support/login_helpers.rb') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 7a0f078c72b..75a8846c0da 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -37,6 +37,31 @@ module LoginHelpers Thread.current[:current_user] = user end + def login_via(provider, user, uid) + mock_auth_hash(provider, uid, user.email) + visit new_user_session_path + #page.find('.oauth-image-link').click + click_link provider + end + + def mock_auth_hash(provider, uid, email) + # The mock_auth configuration allows you to set per-provider (or default) + # authentication hashes to return during integration testing. + OmniAuth.config.mock_auth[provider.to_sym] = OmniAuth::AuthHash.new({ + provider: provider, + uid: uid, + info: { + name: 'mockuser', + email: email, + image: 'mock_user_thumbnail_url' + }, + credentials: { + token: 'mock_token', + secret: 'mock_secret' + } + }) + end + # Requires Javascript driver. def logout find(:css, ".fa.fa-sign-out").click -- cgit v1.2.3 From 40e16b22f9a4ecb7dd7a25c4a0355809bed70ebe Mon Sep 17 00:00:00 2001 From: Patricio Cano Date: Mon, 4 Jul 2016 11:50:11 -0500 Subject: Change order of stubbing to fix tests --- spec/support/login_helpers.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec/support/login_helpers.rb') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 75a8846c0da..f9ce929000c 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -40,7 +40,6 @@ module LoginHelpers def login_via(provider, user, uid) mock_auth_hash(provider, uid, user.email) visit new_user_session_path - #page.find('.oauth-image-link').click click_link provider end -- cgit v1.2.3 From 2a0be666e3078e28a02de298b386ec4c09232978 Mon Sep 17 00:00:00 2001 From: Patricio Cano Date: Tue, 5 Jul 2016 16:34:34 -0500 Subject: Added a lot of stubbing to make sure OAUth requests are handled properly with 2FA --- spec/support/login_helpers.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/support/login_helpers.rb') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index f9ce929000c..2e400dd825a 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -39,6 +39,7 @@ module LoginHelpers def login_via(provider, user, uid) mock_auth_hash(provider, uid, user.email) + Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml] visit new_user_session_path click_link provider end @@ -57,6 +58,15 @@ module LoginHelpers credentials: { token: 'mock_token', secret: 'mock_secret' + }, + extra: { + raw_info: { + info: { + name: 'mockuser', + email: email, + image: 'mock_user_thumbnail_url' + } + } } }) end -- cgit v1.2.3 From 24cf6b9f62a312c010c9479fd6155f7c72099979 Mon Sep 17 00:00:00 2001 From: Patricio Cano Date: Mon, 11 Jul 2016 12:41:02 -0500 Subject: Refactor `mock_auth_hash` --- spec/support/login_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/support/login_helpers.rb') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 2e400dd825a..ba08733e48d 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -39,7 +39,6 @@ module LoginHelpers def login_via(provider, user, uid) mock_auth_hash(provider, uid, user.email) - Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml] visit new_user_session_path click_link provider end @@ -69,6 +68,7 @@ module LoginHelpers } } }) + Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml] end # Requires Javascript driver. -- cgit v1.2.3