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

Raise a more descriptive exception if idp_sso_target_url is missing #453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/onelogin/ruby-saml/authrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def create(settings, params = {})
params.each_pair do |key, value|
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
end
raise "Invalid settings, idp_sso_target_url is not set!" if settings.idp_sso_target_url.nil?
@login_url = settings.idp_sso_target_url + request_params
end

Expand Down
13 changes: 13 additions & 0 deletions test/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ class RequestTest < Minitest::Test
assert_match /&hello=$/, auth_url
end

describe "when the target url is not set" do
before do
settings.idp_sso_target_url = nil
end

it "raises an error with a descriptive message" do
err = assert_raises RuntimeError do
OneLogin::RubySaml::Authrequest.new.create(settings)
end
assert_match /idp_sso_target_url is not set/, err.message
end
end

describe "when the target url doesn't contain a query string" do
it "create the SAMLRequest parameter correctly" do

Expand Down