From 7e6cb1ff2e56ab19645363dbb8a729ba3d2f92e4 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 8 Feb 2021 10:59:43 +0000 Subject: [PATCH] FIX: Correct server error for starting SSO login, and add spec (#12010) Followup to 821bb1e8cb72bee56cf5c2a878043112cc7ea2fd --- app/controllers/session_controller.rb | 2 +- spec/requests/session_controller_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rb index 257ea5d9851..0c190147747 100644 --- a/app/controllers/session_controller.rb +++ b/app/controllers/session_controller.rb @@ -29,7 +29,7 @@ class SessionController < ApplicationController if SiteSetting.verbose_discourse_connect_logging Rails.logger.warn("Verbose SSO log: Started SSO process\n\n#{sso.diagnostics}") end - redirect_to discourse_connect_url(sso) + redirect_to sso_url(sso) else render body: nil, status: 404 end diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb index fd1061aee62..84420d9d011 100644 --- a/spec/requests/session_controller_spec.rb +++ b/spec/requests/session_controller_spec.rb @@ -503,6 +503,20 @@ RSpec.describe SessionController do end end + describe '#sso' do + before do + SiteSetting.discourse_connect_url = "http://example.com/discourse_sso" + SiteSetting.enable_discourse_connect = true + SiteSetting.discourse_connect_secret = "shjkfdhsfkjh" + end + + it "redirects correctly" do + get "/session/sso" + expect(response.status).to eq(302) + expect(response.location).to start_with(SiteSetting.discourse_connect_url) + end + end + describe '#sso_login' do before do @sso_url = "http://example.com/discourse_sso"