You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't get failing test to redirect to /auth/failure, all other cucumber and rspec tests passing for other behaviors.
Documentation says:
Mocking Failure
If you set a provider's mock to a symbol instead of a hash, it will fail with that message.
OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
You will be redirected back to /auth/failure?message=invalid_credentials.
However, all the mock scenarios use a symbol with no effect.
Documentation says:
By default Omniauth will raise an exception for invalid credentials in the development and test environments. If you'd like to be redirected to the /auth/failure endpoint in those environments, include this code:
It is unclear where, exactly, to insert this code, and it is unclear how env gets set.
Configuration
Provider Gem: omniauth-github
Ruby Version: 2.6.6
Framework: Rails 4.2.11
Platform: Ubuntu 18.04.3 LTS
Expected Behavior
in test mode, should route to 'auth/failure'
Actual Behavior
Authentication passes in test mode, then fails in sessions/create because of validations
Steps to Reproduce
cucumber test
# features/failure.feature
@omniauth_test5
Scenario: failure
Given I am on the RottenPotatoes Landing Page
When I press "Register or Login with GitHub"
Then I will see "Failure" # this would be edited if I could see what was returned
Applicable new step_definition (not in web_steps.rb):
# features/step_definitions/movie_steps.rb
Then /^I will see "([^"]*)"$/ do |message|
puts page.body # for debug
expect(page.body).to have_content(message)
end
Test setup :
# features/support/env.rb
Before('@omniauth_test5') do
OmniAuth.config.test_mode = true
Capybara.default_host = 'http://example.com'
OmniAuth.config.mock_auth[:github] = :invalid_credentials
OmniAuth.config.on_failure = Proc.new { |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:github]
end
After('@omniauth_test5') do
OmniAuth.config.test_mode = false
OmniAuth.config.mock_auth[:github] = nil
end
Omniauth initializer:
# config/initializers/omniauth.rb
OmniAuth.config.logger = Rails.logger
OmniAuth.config.allowed_request_methods = [:post] # recently added because of vulnerability
#************************************************
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_CLIENT_ID'],ENV['GITHUB_CLIENT_SECRET'],
{ :name => "github", :scope => ['read:user','user:email']}
end
controller:
# app/controllers/sessions_controller.rb
def failure
begin
rescue Exception => exception
flash[:error] = "#{exception.class}: #{exception.message}"
redirect_to welcome_landing_path
end
Have tried inserting following code in a number of places, but it doesn't have any effect.
Can't get failing test to redirect to
/auth/failure
, all other cucumber and rspec tests passing for other behaviors.Documentation says:
However, all the mock scenarios use a symbol with no effect.
Documentation says:
By default Omniauth will raise an exception for invalid credentials in the development and test environments. If you'd like to be redirected to the /auth/failure endpoint in those environments, include this code:
OmniAuth.config.on_failure = Proc.new { |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}
It is unclear where, exactly, to insert this code, and it is unclear how
env
gets set.Configuration
omniauth-github
2.6.6
Rails 4.2.11
Ubuntu 18.04.3 LTS
Expected Behavior
in test mode, should route to 'auth/failure'
Actual Behavior
Authentication passes in test mode, then fails in
sessions/create
because of validationsSteps to Reproduce
cucumber test
Applicable new step_definition (not in web_steps.rb):
Test setup :
Omniauth initializer:
controller:
Have tried inserting following code in a number of places, but it doesn't have any effect.
The text was updated successfully, but these errors were encountered: