-
Log In
+
+
+
Log In
-
-
If you have a UC Central Login username, you can use it to log in to Scholar@UC.
-
<%= link_to 'Log in using your UC Central Login', '/users/auth/shibboleth', class: 'btn btn-primary', style: 'font-size: larger' %>
-
+
+
If you have a UC Central Login username, you can use it to log in to Scholar@UC.
+
<%= link_to 'Log in using your UC Central Login', '/users/auth/shibboleth', class: 'btn btn-primary', style: 'font-size: larger' %>
+
-
-
-
Other Users
-
If you're not affiliated with UC, but have been given an account for <%= t('hyrax.product_name') %>, you can <%= link_to 'log in using a local account', new_user_session_path %>. To request an account, <%= link_to 'use the contact page', contact_path %>.
+
+
+
Other Users
+
If you're not affiliated with UC, but have been given an account for <%= t('hyrax.product_name') %>, you can <%= link_to 'log in using a local account', new_user_session_path %>. To request an account, <%= link_to 'use the contact page', contact_path %>.
+
-
\ No newline at end of file
diff --git a/config/authentication.yml b/config/authentication.yml
index ac4e1395..503fed26 100644
--- a/config/authentication.yml
+++ b/config/authentication.yml
@@ -1,11 +1,11 @@
-development:
- shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
- signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
+ development:
+ shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
+ signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
-test:
- shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
- signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
+ test:
+ shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
+ signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
-production:
- shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
- signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
+ production:
+ shibboleth_enabled: <%= ENV["SCHOLAR_SHIBBOLETH_ENABLED"] %>
+ signups_enabled: <%= ENV["SCHOLAR_SIGNUPS_ENABLED"] %>
diff --git a/config/initializers/authentication_config.rb b/config/initializers/authentication_config.rb
index f995c0b5..3808d3f4 100644
--- a/config/initializers/authentication_config.rb
+++ b/config/initializers/authentication_config.rb
@@ -1,3 +1,3 @@
-# frozen_string_literal: true
+ # frozen_string_literal: true
-AUTH_CONFIG = YAML.safe_load(ERB.new(File.read(Rails.root.join('config', 'authentication.yml'))).result)[Rails.env]
+ AUTH_CONFIG = YAML.safe_load(ERB.new(File.read(Rails.root.join('config', 'authentication.yml'))).result)[Rails.env]
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index dda9c261..e8f96b2c 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -259,37 +259,37 @@
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :get
- # ==> OmniAuth
- # Add a new OmniAuth provider. Check the wiki for more information on setting
- # up on your models and hooks.
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
- config.omniauth :shibboleth,
- shib_session_id_field: "Shib-Session-ID",
- shib_application_id_field: "Shib-Application-ID",
- uid_field: "eppn",
- name_field: "displayName",
- debug: false,
- extra_fields: [
- :cn,
- :eppn,
- :givenName,
- :ou,
- :'persistent-id',
- :sn,
- :street,
- :title,
- :uceduAffiliation,
- :uceduPrimaryAffiliation,
- :uceduUCID,
- :mail,
- :affiliation,
- :remoteuser,
- :telephoneNumber,
- :uceduAcademicProgram,
- :uceduFERPACode,
- :uceduPrimaryCollege,
- :uceduSISPersonID
- ]
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+ config.omniauth :shibboleth,
+ shib_session_id_field: "Shib-Session-ID",
+ shib_application_id_field: "Shib-Application-ID",
+ uid_field: "eppn",
+ name_field: "displayName",
+ debug: false,
+ extra_fields: [
+ :cn,
+ :eppn,
+ :givenName,
+ :ou,
+ :'persistent-id',
+ :sn,
+ :street,
+ :title,
+ :uceduAffiliation,
+ :uceduPrimaryAffiliation,
+ :uceduUCID,
+ :mail,
+ :affiliation,
+ :remoteuser,
+ :telephoneNumber,
+ :uceduAcademicProgram,
+ :uceduFERPACode,
+ :uceduPrimaryCollege,
+ :uceduSISPersonID
+ ]
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
diff --git a/config/routes.rb b/config/routes.rb
index e91082c5..bf377667 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -26,12 +26,12 @@
mount Sidekiq::Web => '/sidekiq'
end
- devise_for :users, controllers: { omniauth_callbacks: 'callbacks', registrations: "registrations" }
+ devise_for :users, controllers: { omniauth_callbacks: 'callbacks', registrations: "registrations" }
mount Hydra::RoleManagement::Engine => '/'
resources :users, only: [:index], constraints: { format: :html }, controller: 'display_users'
- get 'login' => 'static#login'
+ get 'login' => 'static#login'
get 'about' => 'static#about'
get 'help' => 'static#help'
get 'contact' => 'hyrax/contact_form#new'
diff --git a/db/migrate/20170718204534_add_columns_to_users.rb b/db/migrate/20170718204534_add_columns_to_users.rb
index ccda9662..b2761c68 100644
--- a/db/migrate/20170718204534_add_columns_to_users.rb
+++ b/db/migrate/20170718204534_add_columns_to_users.rb
@@ -1,6 +1,6 @@
-class AddColumnsToUsers < ActiveRecord::Migration[5.1]
- def change
- add_column :users, :provider, :string
- add_column :users, :uid, :string
+ class AddColumnsToUsers < ActiveRecord::Migration[5.1]
+ def change
+ add_column :users, :provider, :string
+ add_column :users, :uid, :string
+ end
end
-end
diff --git a/spec/controllers/callbacks_controller_spec.rb b/spec/controllers/callbacks_controller_spec.rb
index 94298e3a..92883ac5 100644
--- a/spec/controllers/callbacks_controller_spec.rb
+++ b/spec/controllers/callbacks_controller_spec.rb
@@ -42,82 +42,17 @@
end
end
- describe 'omniauth-shibboleth' do
- let(:uid) { 'sixplus2@test.com' }
- let(:provider) { :shibboleth }
-
- before do
- @request.env["devise.mapping"] = Devise.mappings[:user]
- omniauth_hash = { provider: 'shibboleth',
- uid: uid,
- extra: {
- raw_info: {
- mail: uid,
- title: 'title',
- telephoneNumber: '123-456-7890',
- givenName: 'Fake',
- sn: 'User',
- uceduPrimaryAffiliation: 'staff',
- ou: 'department'
- }
- } }
- OmniAuth.config.add_mock(provider, omniauth_hash)
- request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
- end
-
- context 'with a user who is already logged in' do
- let(:user) { FactoryBot.create(:user) }
-
- before do
- controller.stub(:current_user).and_return(user)
- end
- it 'redirects to the dashboard' do
- get provider
- expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.dashboard_path)
- end
- end
-
- shared_examples 'Shibboleth login' do
- it 'assigns the user and redirects' do
- get provider
- expect(flash[:notice]).to match(/You are now signed in as */)
- expect(cookies[:login_type]).not_to eq(nil)
- expect(assigns(:user).email).to eq(email)
- expect(assigns(:user).provider).to eq('shibboleth')
- expect(assigns(:user).uid).to eq(request.env["omniauth.auth"]["uid"])
- expect(assigns(:user).profile_update_not_required).to eq(false)
- expect(response).to be_redirect
- end
- end
-
- context 'with a brand new user' do
- let(:email) { uid }
-
- it_behaves_like 'Shibboleth login'
-
- it 'updates the shibboleth attributes' do
- get provider
- expect(assigns(:user).title).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["title"])
- expect(assigns(:user).telephone).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["telephoneNumber"])
- expect(assigns(:user).first_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["givenName"])
- expect(assigns(:user).last_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["sn"])
- expect(assigns(:user).uc_affiliation).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["uceduPrimaryAffiliation"])
- expect(assigns(:user).ucdepartment).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["ou"])
- end
+ describe 'omniauth-shibboleth' do
+ let(:uid) { 'sixplus2@test.com' }
+ let(:provider) { :shibboleth }
- it 'sends a welcome email' do
- ActionMailer::Base.deliveries = []
- get provider
- expect(ActionMailer::Base.deliveries.count).to eq(1)
- end
- end
-
- context 'with a brand new user when Shibboleth email is not defined' do
before do
+ @request.env["devise.mapping"] = Devise.mappings[:user]
omniauth_hash = { provider: 'shibboleth',
uid: uid,
extra: {
raw_info: {
+ mail: uid,
title: 'title',
telephoneNumber: '123-456-7890',
givenName: 'Fake',
@@ -129,81 +64,146 @@
OmniAuth.config.add_mock(provider, omniauth_hash)
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
end
- let(:email) { uid }
- it_behaves_like 'Shibboleth login'
- end
+ context 'with a user who is already logged in' do
+ let(:user) { FactoryBot.create(:user) }
- context 'with a brand new user when Shibboleth email is blank' do
- before do
- omniauth_hash = { provider: 'shibboleth',
- uid: uid,
- extra: {
- raw_info: {
- mail: '',
- title: 'title',
- telephoneNumber: '123-456-7890',
- givenName: 'Fake',
- sn: 'User',
- uceduPrimaryAffiliation: 'staff',
- ou: 'department'
- }
- } }
- OmniAuth.config.add_mock(provider, omniauth_hash)
- request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
+ before do
+ controller.stub(:current_user).and_return(user)
+ end
+ it 'redirects to the dashboard' do
+ get provider
+ expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.dashboard_path)
+ end
end
- let(:email) { uid }
- it_behaves_like 'Shibboleth login'
- end
+ shared_examples 'Shibboleth login' do
+ it 'assigns the user and redirects' do
+ get provider
+ expect(flash[:notice]).to match(/You are now signed in as */)
+ expect(cookies[:login_type]).not_to eq(nil)
+ expect(assigns(:user).email).to eq(email)
+ expect(assigns(:user).provider).to eq('shibboleth')
+ expect(assigns(:user).uid).to eq(request.env["omniauth.auth"]["uid"])
+ expect(assigns(:user).profile_update_not_required).to eq(false)
+ expect(response).to be_redirect
+ end
+ end
- context 'with a registered user who has previously logged in' do
- let!(:user) { FactoryBot.create(:shibboleth_user, count: 1, profile_update_not_required: false) }
- let(:email) { user.email }
+ context 'with a brand new user' do
+ let(:email) { uid }
+
+ it_behaves_like 'Shibboleth login'
+
+ it 'updates the shibboleth attributes' do
+ get provider
+ expect(assigns(:user).title).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["title"])
+ expect(assigns(:user).telephone).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["telephoneNumber"])
+ expect(assigns(:user).first_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["givenName"])
+ expect(assigns(:user).last_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["sn"])
+ expect(assigns(:user).uc_affiliation).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["uceduPrimaryAffiliation"])
+ expect(assigns(:user).ucdepartment).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["ou"])
+ end
+
+ it 'sends a welcome email' do
+ ActionMailer::Base.deliveries = []
+ get provider
+ expect(ActionMailer::Base.deliveries.count).to eq(1)
+ end
+ end
- it_behaves_like 'Shibboleth login'
- end
+ context 'with a brand new user when Shibboleth email is not defined' do
+ before do
+ omniauth_hash = { provider: 'shibboleth',
+ uid: uid,
+ extra: {
+ raw_info: {
+ title: 'title',
+ telephoneNumber: '123-456-7890',
+ givenName: 'Fake',
+ sn: 'User',
+ uceduPrimaryAffiliation: 'staff',
+ ou: 'department'
+ }
+ } }
+ OmniAuth.config.add_mock(provider, omniauth_hash)
+ request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
+ end
+ let(:email) { uid }
+
+ it_behaves_like 'Shibboleth login'
+ end
- context 'with a registered user who has never logged in' do
- let!(:user) { FactoryBot.create(:shibboleth_user, count: 0, profile_update_not_required: false) }
- let(:email) { user.email }
+ context 'with a brand new user when Shibboleth email is blank' do
+ before do
+ omniauth_hash = { provider: 'shibboleth',
+ uid: uid,
+ extra: {
+ raw_info: {
+ mail: '',
+ title: 'title',
+ telephoneNumber: '123-456-7890',
+ givenName: 'Fake',
+ sn: 'User',
+ uceduPrimaryAffiliation: 'staff',
+ ou: 'department'
+ }
+ } }
+ OmniAuth.config.add_mock(provider, omniauth_hash)
+ request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
+ end
+ let(:email) { uid }
+
+ it_behaves_like 'Shibboleth login'
+ end
- it_behaves_like 'Shibboleth login'
+ context 'with a registered user who has previously logged in' do
+ let!(:user) { FactoryBot.create(:shibboleth_user, count: 1, profile_update_not_required: false) }
+ let(:email) { user.email }
- it 'updates the shibboleth attributes' do
- get provider
- expect(assigns(:user).title).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["title"])
- expect(assigns(:user).telephone).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["telephoneNumber"])
- expect(assigns(:user).first_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["givenName"])
- expect(assigns(:user).last_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["sn"])
- expect(assigns(:user).uc_affiliation).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["uceduPrimaryAffiliation"])
- expect(assigns(:user).ucdepartment).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["ou"])
+ it_behaves_like 'Shibboleth login'
end
- end
- context 'with a registered user who has previously logged in and has updated shibboleth data' do
- before do
- omniauth_hash = { provider: 'shibboleth',
- uid: uid,
- extra: {
- raw_info: {
- uceduPrimaryAffiliation: 'Second Affiliation',
- ou: 'Second Department'
- }
- } }
- OmniAuth.config.add_mock(provider, omniauth_hash)
- request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
+ context 'with a registered user who has never logged in' do
+ let!(:user) { FactoryBot.create(:shibboleth_user, count: 0, profile_update_not_required: false) }
+ let(:email) { user.email }
+
+ it_behaves_like 'Shibboleth login'
+
+ it 'updates the shibboleth attributes' do
+ get provider
+ expect(assigns(:user).title).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["title"])
+ expect(assigns(:user).telephone).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["telephoneNumber"])
+ expect(assigns(:user).first_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["givenName"])
+ expect(assigns(:user).last_name).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["sn"])
+ expect(assigns(:user).uc_affiliation).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["uceduPrimaryAffiliation"])
+ expect(assigns(:user).ucdepartment).to eq(request.env["omniauth.auth"]["extra"]["raw_info"]["ou"])
+ end
end
- let!(:user) { FactoryBot.create(:shibboleth_user, count: 1, uc_affiliation: "First Affiliation", ucdepartment: "First Department") }
- let!(:email) { user.email }
-
- it 'has the correct metadata' do
- get provider
- user = User.find(1)
- expect(user["uc_affiliation"]).to eq "Second Affiliation"
- expect(user["ucdepartment"]).to eq "Second Department"
+ context 'with a registered user who has previously logged in and has updated shibboleth data' do
+ before do
+ omniauth_hash = { provider: 'shibboleth',
+ uid: uid,
+ extra: {
+ raw_info: {
+ uceduPrimaryAffiliation: 'Second Affiliation',
+ ou: 'Second Department'
+ }
+ } }
+ OmniAuth.config.add_mock(provider, omniauth_hash)
+ request.env["omniauth.auth"] = OmniAuth.config.mock_auth[provider]
+ end
+
+ let!(:user) { FactoryBot.create(:shibboleth_user, count: 1, uc_affiliation: "First Affiliation", ucdepartment: "First Department") }
+ let!(:email) { user.email }
+
+ it 'has the correct metadata' do
+ get provider
+ user = User.find(1)
+ expect(user["uc_affiliation"]).to eq "Second Affiliation"
+ expect(user["ucdepartment"]).to eq "Second Department"
+ end
end
end
- end
end
diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb
index a2bd144a..6c57afa2 100644
--- a/spec/controllers/static_controller_spec.rb
+++ b/spec/controllers/static_controller_spec.rb
@@ -89,17 +89,17 @@
expect(response).to render_template('static/doi_help')
end
end
- describe '#login' do
- let(:user) { FactoryBot.create(:user) }
+ describe '#login' do
+ let(:user) { FactoryBot.create(:user) }
- before do
- controller.stub(:current_user).and_return(user)
+ before do
+ controller.stub(:current_user).and_return(user)
+ end
+ it 'redirects to dashboard when already logged in' do
+ get :login
+ expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.dashboard_path)
+ end
end
- it 'redirects to dashboard when already logged in' do
- get :login
- expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.dashboard_path)
- end
- end
describe '#whats_new' do
it "renders the what's new page" do
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 4e5d6f7c..c5c496a0 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -59,20 +59,20 @@
end
end
- factory :shibboleth_user, class: 'User' do
- transient do
- count { 1 }
- person_pid { nil }
+ factory :shibboleth_user, class: 'User' do
+ transient do
+ count { 1 }
+ person_pid { nil }
+ end
+ email { 'sixplus2@test.com' }
+ password { '12345678' }
+ first_name { 'Fake' }
+ last_name { 'User' }
+ password_confirmation { '12345678' }
+ sign_in_count { count.to_s }
+ provider { 'shibboleth' }
+ uid { 'sixplus2@test.com' }
end
- email { 'sixplus2@test.com' }
- password { '12345678' }
- first_name { 'Fake' }
- last_name { 'User' }
- password_confirmation { '12345678' }
- sign_in_count { count.to_s }
- provider { 'shibboleth' }
- uid { 'sixplus2@test.com' }
- end
trait :guest do
guest { true }
diff --git a/spec/features/uc_shibboleth_spec.rb b/spec/features/uc_shibboleth_spec.rb
index 42e87f2a..ba7b0f4b 100644
--- a/spec/features/uc_shibboleth_spec.rb
+++ b/spec/features/uc_shibboleth_spec.rb
@@ -1,159 +1,159 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
+ # frozen_string_literal: true
+
+ require 'rails_helper'
+
+ describe 'UC account workflow', type: :feature do
+ let(:user) { FactoryBot.create(:user) }
+ let(:password) { FactoryBot.attributes_for(:user).fetch(:password) }
+ let(:locale) { 'en' }
+
+ describe 'overridden devise password reset page' do
+ context 'with a uc.edu email address' do
+ email_address = 'fake.user@uc.edu'
+ it 'rejects password reset for @.uc.edu user' do
+ visit new_user_password_path
+ fill_in('user[email]', with: email_address)
+ click_on('Send me reset password instructions')
+ expect(page).to have_content('You cannot reset passwords for @uc.edu accounts. Use your UC Central Login instead')
+ end
+ end
-describe 'UC account workflow', type: :feature do
- let(:user) { FactoryBot.create(:user) }
- let(:password) { FactoryBot.attributes_for(:user).fetch(:password) }
- let(:locale) { 'en' }
+ context 'with a non uc.edu email address' do
+ it 'allows a password reset' do
+ visit new_user_password_path
+ fill_in('user[email]', with: user.email)
+ click_on('Send me reset password instructions')
+ expect(page).to have_content('You will receive an email with instructions on how to reset your password in a few minutes.')
+ end
+ end
- describe 'overridden devise password reset page' do
- context 'with a uc.edu email address' do
- email_address = 'fake.user@uc.edu'
- it 'rejects password reset for @.uc.edu user' do
- visit new_user_password_path
- fill_in('user[email]', with: email_address)
- click_on('Send me reset password instructions')
- expect(page).to have_content('You cannot reset passwords for @uc.edu accounts. Use your UC Central Login instead')
+ context 'with an invalid email address' do
+ email_address = 'fake.user@mail.edu'
+ it 'allows a password reset' do
+ visit new_user_password_path
+ fill_in('user[email]', with: email_address)
+ click_on('Send me reset password instructions')
+ expect(page).to have_content('Email not found')
+ end
end
end
- context 'with a non uc.edu email address' do
- it 'allows a password reset' do
+ describe 'overridden devise password reset page' do
+ it 'shows a Central Login option with shibboleth enabled' do
+ AUTH_CONFIG['shibboleth_enabled'] = true
visit new_user_password_path
- fill_in('user[email]', with: user.email)
- click_on('Send me reset password instructions')
- expect(page).to have_content('You will receive an email with instructions on how to reset your password in a few minutes.')
+ expect(page).to have_content('Central Login form')
end
- end
- context 'with an invalid email address' do
- email_address = 'fake.user@mail.edu'
- it 'allows a password reset' do
+ it 'does not show a Central Login option with shibboleth disabled' do
+ AUTH_CONFIG['shibboleth_enabled'] = false
visit new_user_password_path
- fill_in('user[email]', with: email_address)
- click_on('Send me reset password instructions')
- expect(page).to have_content('Email not found')
+ skip "this string displays without regard to shibboleth status"
+ expect(page).not_to have_content('Central Login form') # This string appears in the help text on the page
end
- end
- end
- describe 'overridden devise password reset page' do
- it 'shows a Central Login option with shibboleth enabled' do
- AUTH_CONFIG['shibboleth_enabled'] = true
- visit new_user_password_path
- expect(page).to have_content('Central Login form')
- end
-
- it 'does not show a Central Login option with shibboleth disabled' do
- AUTH_CONFIG['shibboleth_enabled'] = false
- visit new_user_password_path
- skip "this string displays without regard to shibboleth status"
- expect(page).not_to have_content('Central Login form') # This string appears in the help text on the page
- end
-
- it 'does not display the Shared links at the bottom' do
- visit new_user_password_path
- expect(page).not_to have_link('Sign in', href: '/users/sign_in')
- expect(page).not_to have_link('Sign up', href: '/users/sign_up')
- end
- end
-
- describe 'overridden devise registration page' do
- it 'shows a sign up form if signups are enabled' do
- AUTH_CONFIG['signups_enabled'] = true
- visit new_user_registration_path
- expect(page).to have_field('user[email]')
- end
-
- it 'shows a request link of signups are disabled' do
- AUTH_CONFIG['signups_enabled'] = false
- visit new_user_registration_path
- expect(page).to have_link('use the contact page', href: contact_path(locale: locale))
+ it 'does not display the Shared links at the bottom' do
+ visit new_user_password_path
+ expect(page).not_to have_link('Sign in', href: '/users/sign_in')
+ expect(page).not_to have_link('Sign up', href: '/users/sign_up')
+ end
end
- end
- describe 'overridden devise sign-in page' do
- it 'shows a shibboleth login link if shibboleth is enabled' do
- AUTH_CONFIG['shibboleth_enabled'] = true
- visit new_user_session_path
- expect(page).to have_link('Central Login form', href: user_shibboleth_omniauth_authorize_path(locale: locale))
- end
+ describe 'overridden devise registration page' do
+ it 'shows a sign up form if signups are enabled' do
+ AUTH_CONFIG['signups_enabled'] = true
+ visit new_user_registration_path
+ expect(page).to have_field('user[email]')
+ end
- it 'does not show a shibboleth login link if shibboleth is disabled' do
- AUTH_CONFIG['shibboleth_enabled'] = false
- visit new_user_session_path
- expect(page).not_to have_link('Central Login form', href: user_shibboleth_omniauth_authorize_path(locale: locale))
+ it 'shows a request link of signups are disabled' do
+ AUTH_CONFIG['signups_enabled'] = false
+ visit new_user_registration_path
+ expect(page).to have_link('use the contact page', href: contact_path(locale: locale))
+ end
end
- it 'shows a signup link if signups are enabled' do
- AUTH_CONFIG['signups_enabled'] = true
- visit new_user_session_path
- expect(page).to have_link('Sign up', href: new_user_registration_path(locale: locale))
- end
+ describe 'overridden devise sign-in page' do
+ it 'shows a shibboleth login link if shibboleth is enabled' do
+ AUTH_CONFIG['shibboleth_enabled'] = true
+ visit new_user_session_path
+ expect(page).to have_link('Central Login form', href: user_shibboleth_omniauth_authorize_path(locale: locale))
+ end
- it 'does not show signup link if signups are disabled' do
- AUTH_CONFIG['signups_enabled'] = false
- visit new_user_session_path
- expect(page).not_to have_link('Sign up', href: new_user_registration_path(locale: locale))
- end
- end
+ it 'does not show a shibboleth login link if shibboleth is disabled' do
+ AUTH_CONFIG['shibboleth_enabled'] = false
+ visit new_user_session_path
+ expect(page).not_to have_link('Central Login form', href: user_shibboleth_omniauth_authorize_path(locale: locale))
+ end
- describe 'shibboleth login page' do
- context 'when shibboleth is enabled' do
- before do
- AUTH_CONFIG['shibboleth_enabled'] = true
- visit login_path
+ it 'shows a signup link if signups are enabled' do
+ AUTH_CONFIG['signups_enabled'] = true
+ visit new_user_session_path
+ expect(page).to have_link('Sign up', href: new_user_registration_path(locale: locale))
end
- it 'shows a shibboleth login link and local login link' do
- expect(page).to have_link('UC Central Login username', href: 'https://www.uc.edu/distance/Student_Orientation/One_Stop_Student_Resources/central-log-in-.html')
- expect(page).to have_link('log in using a local account', href: new_user_session_path + '?locale=en')
+ it 'does not show signup link if signups are disabled' do
+ AUTH_CONFIG['signups_enabled'] = false
+ visit new_user_session_path
+ expect(page).not_to have_link('Sign up', href: new_user_registration_path(locale: locale))
end
end
- context 'when shibboleth is not enabled' do
- before do
- AUTH_CONFIG['shibboleth_enabled'] = false
- visit login_path
+ describe 'shibboleth login page' do
+ context 'when shibboleth is enabled' do
+ before do
+ AUTH_CONFIG['shibboleth_enabled'] = true
+ visit login_path
+ end
+
+ it 'shows a shibboleth login link and local login link' do
+ expect(page).to have_link('UC Central Login username', href: 'https://www.uc.edu/distance/Student_Orientation/One_Stop_Student_Resources/central-log-in-.html')
+ expect(page).to have_link('log in using a local account', href: new_user_session_path + '?locale=en')
+ end
end
- it 'shows the local log in page' do
- expect(page).to have_field('user[email]')
+ context 'when shibboleth is not enabled' do
+ before do
+ AUTH_CONFIG['shibboleth_enabled'] = false
+ visit login_path
+ end
+
+ it 'shows the local log in page' do
+ expect(page).to have_field('user[email]')
+ end
end
end
- end
- describe 'shibboleth password management' do
- it 'hides the password change fields for shibboleth users' do
- login_as(user)
- user.provider = 'shibboleth'
- visit hyrax.edit_dashboard_profile_path(user)
- expect(page).not_to have_field('user[password]')
- expect(page).not_to have_field('user[password_confirmation]')
+ describe 'shibboleth password management' do
+ it 'hides the password change fields for shibboleth users' do
+ login_as(user)
+ user.provider = 'shibboleth'
+ visit hyrax.edit_dashboard_profile_path(user)
+ expect(page).not_to have_field('user[password]')
+ expect(page).not_to have_field('user[password_confirmation]')
+ end
end
- end
- describe 'home page login button' do
- it 'shows the correct login link' do
- visit root_path
- expect(page).to have_link('Login', href: login_path + '?locale=en')
+ describe 'home page login button' do
+ it 'shows the correct login link' do
+ visit root_path
+ expect(page).to have_link('Login', href: login_path + '?locale=en')
+ end
end
- end
- describe 'a user using a UC Shibboleth login' do
- it "redirects to the UC Shibboleth logout page after logout" do
- create_cookie('login_type', 'shibboleth')
- visit('/users/sign_out')
- expect(page).to have_content("You have been logged out of the University of Cincinnati's Login Service")
+ describe 'a user using a UC Shibboleth login' do
+ it "redirects to the UC Shibboleth logout page after logout" do
+ create_cookie('login_type', 'shibboleth')
+ visit('/users/sign_out')
+ expect(page).to have_content("You have been logged out of the University of Cincinnati's Login Service")
+ end
end
- end
- describe 'a user using a local login' do
- it "redirects to the home page after logout" do
- create_cookie('login_type', 'local')
- visit('/users/sign_out')
- expect(page).to have_title("Scholar@UC")
+ describe 'a user using a local login' do
+ it "redirects to the home page after logout" do
+ create_cookie('login_type', 'local')
+ visit('/users/sign_out')
+ expect(page).to have_title("Scholar@UC")
+ end
end
end
-end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index f9547cfc..40a0d549 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -145,7 +145,7 @@ def ci_build?
config.include OptionalExample
config.include Devise::Test::IntegrationHelpers, type: :feature
- config.include Devise::Test::ControllerHelpers, type: :controller
+ config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :helper
config.before :suite do
@@ -190,8 +190,8 @@ def ci_build?
config.order = :random
Kernel.srand config.seed
- # Allow cookies to be set in feature tests (for UC Shibboleth testing)
- config.include ShowMeTheCookies, type: :feature
+ # Allow cookies to be set in feature tests (for UC Shibboleth testing)
+ config.include ShowMeTheCookies, type: :feature
config.include Shoulda::Matchers::Independent
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f8a85e0a..638a762f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -59,7 +59,7 @@
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
- # mocks.verify_partial_doubles = true
+ # mocks.verify_partial_doubles = true
end
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
diff --git a/spec/support/test_routes.rb b/spec/support/test_routes.rb
index 1836a400..019658b2 100644
--- a/spec/support/test_routes.rb
+++ b/spec/support/test_routes.rb
@@ -1,13 +1,13 @@
-# frozen_string_literal: true
+ # frozen_string_literal: true
-class ShibbolethLogoutController < ApplicationController
- def show
- render plain: "You have been logged out of the University of Cincinnati's Login Service"
+ class ShibbolethLogoutController < ApplicationController
+ def show
+ render plain: "You have been logged out of the University of Cincinnati's Login Service"
+ end
end
-end
-test_routes = proc do
- get '/Shibboleth.sso/Logout' => 'shibboleth_logout#show'
-end
+ test_routes = proc do
+ get '/Shibboleth.sso/Logout' => 'shibboleth_logout#show'
+ end
-Rails.application.routes.send :eval_block, test_routes
+ Rails.application.routes.send :eval_block, test_routes
diff --git a/spec/views/_user_util_links.html.erb_spec.rb b/spec/views/_user_util_links.html.erb_spec.rb
index f9a6b203..5fbd8604 100644
--- a/spec/views/_user_util_links.html.erb_spec.rb
+++ b/spec/views/_user_util_links.html.erb_spec.rb
@@ -26,27 +26,27 @@
expect(rendered).to have_link 'Edit Profile', href: hyrax.edit_dashboard_profile_path('userX')
end
- context 'when the user is using shibboleth' do
- before do
- allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX', provider: 'shibboleth'))
- render
- end
+ context 'when the user is using shibboleth' do
+ before do
+ allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX', provider: 'shibboleth'))
+ render
+ end
- it 'does not show the change password manu option' do
- expect(rendered).not_to have_link 'Change password'
+ it 'does not show the change password manu option' do
+ expect(rendered).not_to have_link 'Change password'
+ end
end
- end
- context 'when the user is not using shibboleth' do
- before do
- allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX', provider: nil))
- render
- end
+ context 'when the user is not using shibboleth' do
+ before do
+ allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX', provider: nil))
+ render
+ end
- it 'shows the change password manu option' do
- expect(rendered).to have_link 'Change password', href: edit_user_registration_path
+ it 'shows the change password manu option' do
+ expect(rendered).to have_link 'Change password', href: edit_user_registration_path
+ end
end
- end
it 'shows the number of outstanding messages' do
render
diff --git a/spec/views/devise/registrations/edit.html.erb_spec.rb b/spec/views/devise/registrations/edit.html.erb_spec.rb
index 7592b251..abd9f2bb 100644
--- a/spec/views/devise/registrations/edit.html.erb_spec.rb
+++ b/spec/views/devise/registrations/edit.html.erb_spec.rb
@@ -1,20 +1,20 @@
-# frozen_string_literal: true
+ # frozen_string_literal: true
-require 'rails_helper'
+ require 'rails_helper'
-RSpec.describe 'devise/registrations/edit.html.erb', type: :view do
- let(:resource) { stub_model(User, user_key: 'mjg') }
- let(:resource_name) { :user }
- let(:devise_mapping) { Devise.mappings[:user] }
+ RSpec.describe 'devise/registrations/edit.html.erb', type: :view do
+ let(:resource) { stub_model(User, user_key: 'mjg') }
+ let(:resource_name) { :user }
+ let(:devise_mapping) { Devise.mappings[:user] }
- before do
- allow(view).to receive(:resource).and_return(resource)
- allow(view).to receive(:resource_name).and_return(resource_name)
- allow(view).to receive(:devise_mapping).and_return(devise_mapping)
- render
- end
+ before do
+ allow(view).to receive(:resource).and_return(resource)
+ allow(view).to receive(:resource_name).and_return(resource_name)
+ allow(view).to receive(:devise_mapping).and_return(devise_mapping)
+ render
+ end
- it "does not allow the user to cancel their account" do
- expect(rendered).not_to have_content('Cancel my account')
+ it "does not allow the user to cancel their account" do
+ expect(rendered).not_to have_content('Cancel my account')
+ end
end
-end