docbrown/spec/services/authentication/providers/github_spec.rb
Fernando Valverde c74121b0c0
Forem passport (cont) (#14759)
* Initial forem omniauth strategy setup work

* Finish basic raw proof of concept

* Some playing around

* use OAuth payloads + PASSPORT_OAUTH_URL for local dev

* Use FeatureFlag for Forem Passport Auth

* Working on tests

* Fix tests 🤞🏼 & some cleanup

* Use correct namespace within lib directory (match class namespace)

* Test to ensure Forem Passport auth is restricted by FeatureFlag

* Add broadcast + work on tests

* Update spec/lib/data_update_scripts/insert_forem_connect_broadcast_message_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Hash format

* Schema cleanup + inline comments

* Use temprorary Heroku domain

* More cleanup

* Missed one

* Back to passport.forem.com

* Require correct path in lib

* Apply suggestions from code review

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Use with_indifferent_access for symbol hash access in Forem strategy

Co-authored-by: benhalpern <bendhalpern@gmail.com>
Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-09-30 06:47:45 -06:00

36 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe Authentication::Providers::Github, type: :service do
describe ".authentication_path" do
it "returns the correct authentication path" do
expected_path = Rails.application.routes.url_helpers.user_github_omniauth_authorize_path
expect(described_class.authentication_path).to eq(expected_path)
end
it "supports additional parameters" do
path = described_class.authentication_path(state: "state")
expect(path).to include("state=state")
end
end
describe ".sign_in_path" do
let(:expected_path) do
expected_callback_url = CGI.escape(URL.url("/users/auth/github/callback"))
"/users/auth/github?callback_url=#{expected_callback_url}"
end
it "returns the correct sign in path" do
expect(described_class.sign_in_path).to eq(expected_path)
end
it "supports additional parameters" do
path = described_class.sign_in_path(state: "state")
expect(path).to include("state=state")
end
it "does not override the callback_url parameter" do
path = described_class.sign_in_path(callback_url: "https://example.com/callback")
expect(path).to eq(expected_path)
end
end
end