Skip to content

Commit

Permalink
Merge pull request #453 from tomilaine/missing-sso-target-url-exception
Browse files Browse the repository at this point in the history
Raise a more descriptive exception if idp_sso_target_url is missing
  • Loading branch information
pitbulk authored Mar 23, 2018
2 parents 635e75c + 7fd606a commit b69d513
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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

0 comments on commit b69d513

Please sign in to comment.