Skip to content

Commit

Permalink
Added settings for single log out (SLO) and convenience initializer.
Browse files Browse the repository at this point in the history
  • Loading branch information
oc committed Oct 22, 2012
1 parent 2d3d46c commit 692d9b3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/onelogin/ruby-saml/settings.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
module Onelogin
module Saml
class Settings
def initialize(config = {})
config.each do |k,v|
acc = "#{k.to_s}=".to_sym
self.send(acc, v) if self.respond_to? acc
end
end
attr_accessor :assertion_consumer_service_url, :issuer, :sp_name_qualifier
attr_accessor :idp_sso_target_url, :idp_cert_fingerprint, :idp_cert, :name_identifier_format
attr_accessor :authn_context
attr_accessor :authn_context
attr_accessor :idp_slo_target_url
attr_accessor :name_identifier_value
attr_accessor :sessionindex
end
end
end
24 changes: 22 additions & 2 deletions test/settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class SettingsTest < Test::Unit::TestCase
end
should "should provide getters and settings" do
accessors = [
:assertion_consumer_service_url, :issuer, :sp_name_qualifier, :sp_name_qualifier,
:idp_sso_target_url, :idp_cert_fingerprint, :name_identifier_format
:assertion_consumer_service_url, :issuer, :sp_name_qualifier,
:idp_sso_target_url, :idp_cert_fingerprint, :name_identifier_format,
:idp_slo_target_url, :name_identifier_format, :sessionindex
]

accessors.each do |accessor|
Expand All @@ -18,6 +19,25 @@ class SettingsTest < Test::Unit::TestCase
assert_equal value, @settings.send(accessor)
end
end

should "create settings from hash" do

config = {
:assertion_consumer_service_url => "http://app.muda.no/sso",
:issuer => "http://muda.no",
:sp_name_qualifier => "http://sso.muda.no",
:idp_sso_target_url => "http://sso.muda.no/sso",
:idp_slo_target_url => "http://sso.muda.no/slo",
:idp_cert_fingerprint => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
}
@settings = Onelogin::Saml::Settings.new(config)

config.each do |k,v|
assert_equal v, @settings.send(k)
end
end

end

end

0 comments on commit 692d9b3

Please sign in to comment.