Cleanup omniauth specs

This commit is contained in:
Michael Ball 2021-02-23 19:49:34 -08:00
parent 2573dbee44
commit e0fd14e0ce
4 changed files with 30 additions and 10 deletions

View file

@ -101,8 +101,8 @@ class User < ApplicationRecord
[:database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable,
# omniauth_providers: [:suse, :google, :facebook, :github, :discourse]
omniauth_providers: [:google, :discourse]
omniauth_providers: [:suse, :google, :facebook, :github, :discourse]
# omniauth_providers: [:google, :discourse]
]
end

View file

@ -6,7 +6,7 @@ Devise.setup do |config|
# Define the available openID providers that can be used to log in
# Pass each provider to User model in :omniauth_providers (for open_id providers use their name)
# config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user'
config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user'
config.omniauth :google_oauth2,
(ENV['OSEM_GOOGLE_KEY'] || Rails.application.secrets.google_key),
@ -14,6 +14,7 @@ Devise.setup do |config|
name: 'google',
scope: 'email'
# TODO (snapcon): This ought to be configurable. Use OSEM_DISCOURSE_KEY?
config.omniauth :discourse,
sso_url: 'https://forum.snap.berkeley.edu/session/sso_provider',
sso_secret: ENV['OSEM_DISCOURSE_SECRET']

View file

@ -2,7 +2,7 @@
require 'spec_helper'
feature Openid do
feature Openid, type: :feature, js: true do
shared_examples 'sign in with openid' do
scenario 'has option to log in with Google account' do

View file

@ -6,12 +6,16 @@ module OmniauthMacros
ENV['OSEM_GOOGLE_KEY'] = 'test key google'
ENV['OSEM_GOOGLE_SECRET'] = 'test secret google'
# ENV['OSEM_FACEBOOK_KEY'] = 'test key facebook'
# ENV['OSEM_FACEBOOK_SECRET'] = 'test secret facebook'
# ENV['OSEM_SUSE_KEY'] = 'test key suse'
# ENV['OSEM_SUSE_SECRET'] = 'test secret suse'
# ENV['OSEM_GITHUB_KEY'] = 'test key github'
# ENV['OSEM_GITHUB_SECRET'] = 'test secret github'
ENV['OSEM_FACEBOOK_KEY'] = 'test key facebook'
ENV['OSEM_FACEBOOK_SECRET'] = 'test secret facebook'
ENV['OSEM_SUSE_KEY'] = 'test key suse'
ENV['OSEM_SUSE_SECRET'] = 'test secret suse'
ENV['OSEM_GITHUB_KEY'] = 'test key github'
ENV['OSEM_GITHUB_SECRET'] = 'test secret github'
ENV['OSEM_DISCOURSE_KEY'] = 'test key discourse'
ENV['OSEM_DISCOURSE_SECRET'] = 'test secret discourse'
def mock_auth_new_user
OmniAuth.config.mock_auth[:google] =
@ -146,5 +150,20 @@ module OmniauthMacros
secret: 'github_mock_secret'
}
)
OmniAuth.config.mock_auth[:discourse] =
OmniAuth::AuthHash.new(
provider: 'discourse',
uid: 'discourse-test-uid-1',
info: {
name: 'discourse user',
email: 'user-discourse@example.com',
username: 'user_discourse'
},
credentials: {
token: 'discourse_mock_token',
secret: 'discourse_mock_secret'
}
)
end
end