Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before_callback_phase hook not invoked in mocked failure scenario #1043

Open
agrobbin opened this issue Apr 15, 2021 · 0 comments
Open

before_callback_phase hook not invoked in mocked failure scenario #1043

agrobbin opened this issue Apr 15, 2021 · 0 comments

Comments

@agrobbin
Copy link

Configuration

  • Provider Gem: omniauth-auth0
  • Ruby Version: 2.7.3
  • Framework: Rails 6.1.3.1
  • Platform: macOS

Expected Behavior

before_callback_phase hook is invoked when mocking out a failed auth.

Actual Behavior

before_callback_phase hook is skipped due to lines 343-345 below:

def mock_callback_call
setup_phase
@env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
@env['omniauth.params'] = session.delete('omniauth.params') || {}
mocked_auth = OmniAuth.mock_auth_for(name.to_s)
if mocked_auth.is_a?(Symbol)
fail!(mocked_auth)
else
@env['omniauth.auth'] = mocked_auth
OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
call_app!
end
end

Steps to Reproduce

In a non-mocked scenario, before_request_phase is always called, as failure can only happen after the callback_call method calls callback_phase. When testing though, if we mock an auth failure via something like this:

OmniAuth.config.mock_auth[:auth0] = :access_denied

The before_request_phase hook is not called, resulting in a different outcome in tests vs. reality.

The change here seems pretty straightforward, but I wanted to confirm that this was not done on purpose. Is there a specific reason this hook should not be run in the mocked failure case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant