Skip to content

Commit 1f0d5d1

Browse files
committed
Fix failing shibboleth test
This change attempts to resolve the following error: ``` 1) Email Confirmation A user attempts to sign in via the "Sign in with your institutional credentials" button. The email is linked to a user account, however the account is unconfirmed and has no confirmation token. Failure/Error: raise ActionNotFound.new("The action '#{action}' could not be found for #{self.class.name}", self, action) AbstractController::ActionNotFound: The action 'shibboleth' could not be found for Users::OmniauthCallbacksController ``` The Users::OmniauthCallbacksController#shibboleth action is defined dynamically within the controller. Everything is working locally with commit bcc8d1f, but the test is failing when executed as a GitHub Action. This change attempts to make sure that the Shibboleth identifier_scheme is created before the corresponding dynamical shibboleth action is triggered during test execution.
1 parent bcc8d1f commit 1f0d5d1

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

spec/features/email_confirmation_spec.rb

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,41 @@
2626
expect(page).to have_current_path(plans_path)
2727
end
2828

29-
scenario 'A user attempts to sign in via the "Sign in with your institutional credentials"
30-
button. The email is linked to a user account, however the account is
31-
unconfirmed and has no confirmation token.', :js do
32-
user = create(:user, :unconfirmed_and_no_confirmation_token)
33-
scheme = create(:identifier_scheme, :shibboleth)
34-
# Mock the OmniAuth authentication hash for Shibboleth via OmniAuthHelper
35-
OmniAuth.config.mock_auth[:shibboleth] = mock_auth_hash(user, scheme)
36-
# Create a Shibboleth-related Identifier for the user
37-
Identifier.create(identifier_scheme: scheme,
38-
value: OmniAuth.config.mock_auth[:shibboleth].uid,
39-
attrs: OmniAuth.config.mock_auth[:shibboleth],
40-
identifiable: user)
41-
42-
visit root_path
43-
# Sign-in attempt #1 (user is unconfirmed and has no confirmation_token)
44-
click_link SSO_SIGN_IN_BUTTON_TEXT
45-
expectations_for_unconfirmed_user_with_no_confirmation_token_after_sign_in_attempt(user)
29+
describe 'Initial setup for shibboleth sign-in' do
30+
before do
31+
# Set up the user and identifier scheme
32+
@user = create(:user, :unconfirmed_and_no_confirmation_token)
33+
@scheme = create(:identifier_scheme, :shibboleth)
4634

47-
visit root_path
48-
# Sign-in attempt #2 (user still unconfirmed but has a confirmation_token)
49-
click_link SSO_SIGN_IN_BUTTON_TEXT
50-
expectations_for_unconfirmed_user_with_confirmation_token_after_sign_in_attempt
35+
# Mock OmniAuth authentication hash for Shibboleth via OmniAuthHelper
36+
OmniAuth.config.mock_auth[:shibboleth] = mock_auth_hash(@user, @scheme)
5137

52-
# Sign-in attempt #3 (user is now confirmed)
53-
user.confirm
54-
click_link SSO_SIGN_IN_BUTTON_TEXT
55-
# The user is signed in
56-
expect(page).to have_current_path(plans_path)
38+
# Create the identifier for the user
39+
Identifier.create(identifier_scheme: @scheme,
40+
value: OmniAuth.config.mock_auth[:shibboleth].uid,
41+
attrs: OmniAuth.config.mock_auth[:shibboleth],
42+
identifiable: @user)
43+
end
44+
45+
scenario 'A user attempts to sign in via the "Sign in with your institutional credentials"
46+
button. The email is linked to a user account, however the account is
47+
unconfirmed and has no confirmation token.', :js do
48+
visit root_path
49+
# Sign-in attempt #1 (user is unconfirmed and has no confirmation_token)
50+
click_link SSO_SIGN_IN_BUTTON_TEXT
51+
expectations_for_unconfirmed_user_with_no_confirmation_token_after_sign_in_attempt(@user)
52+
53+
visit root_path
54+
# Sign-in attempt #2 (user still unconfirmed but has a confirmation_token)
55+
click_link SSO_SIGN_IN_BUTTON_TEXT
56+
expectations_for_unconfirmed_user_with_confirmation_token_after_sign_in_attempt
57+
58+
# Sign-in attempt #3 (user is now confirmed)
59+
@user.confirm
60+
click_link SSO_SIGN_IN_BUTTON_TEXT
61+
# The user is signed in
62+
expect(page).to have_current_path(plans_path)
63+
end
5764
end
5865

5966
scenario 'A user is unconfirmed but has no confirmation token.

0 commit comments

Comments
 (0)