Skip to content

Do not override omniauth.origin in environment in test mode - #1134

Merged
BobbyMcWho merged 2 commits into
omniauth:masterfrom
TastyPi:env-override
Aug 6, 2024
Merged

BobbyMcWho merged 2 commits into
omniauth:masterfrom
TastyPi:env-override

Conversation

@TastyPi

@TastyPi TastyPi commented Jul 19, 2024

Copy link
Copy Markdown
Contributor

I'm attempting to write a test for our authentication callback Rails controller, however using ActionDispatch::IntegrationTest it is not possible to modify the session. This change makes it easy to test.

Fixes #934

Example with Rails:

class ExampleController < ApplicationController
  def callback
    # Add user to session
    redirect_to(env["omniauth.origin"] || "/")
  end
end

class ExampleControllerTest < ActionDispatch::IntegrationTest
  test "redirects to origin" do
    get "/auth/example/callback", env: {"omniauth.origin" => "/foo"}

    assert_redirected_to "/foo"
  end
end

Comment thread lib/omniauth/strategy.rb Resolved
@TastyPi
TastyPi requested a review from BobbyMcWho July 22, 2024 11:09
@TastyPi

TastyPi commented Aug 5, 2024

Copy link
Copy Markdown
Contributor Author

@BobbyMcWho I've addressed your comment, could you take another look please?

@TastyPi

TastyPi commented Aug 6, 2024

Copy link
Copy Markdown
Contributor Author

@BobbyMcWho the test failures are unrelated to this change.

The head and debug failures are complaining that URI::ABS_URI does not exist, which is being addressed by #1136.

The (macos, 2.5) failure appears to be because CRuby does not support macos-arm64. macos-latest is now arm64 instead of x86 https://github.com/actions/runner-images?tab=readme-ov-file#available-images. I've created #1137 to address this failing pair.

@BobbyMcWho
BobbyMcWho merged commit e23567a into omniauth:master Aug 6, 2024
@TastyPi

TastyPi commented Sep 16, 2024

Copy link
Copy Markdown
Contributor Author

@BobbyMcWho could we get a new Omniauth release that includes this change? Looks like there hasn't been a new release in nearly a year.

@BobbyMcWho

Copy link
Copy Markdown
Member

The project is considered stable and in maintenance, I'll look into releasing, but typically don't release small things like this alone

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

Successfully merging this pull request may close these issues.

mocking request.env['omniauth.origin'] when request.

2 participants