Sha256: 605845cd29bc1610a0ca49a7f5188853bf276a85e4c382ac33fe9e74d08df881
Contents?: true
Size: 1.87 KB
Versions: 10
Compression:
Stored size: 1.87 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper")) class RequestTest < Test::Unit::TestCase context "Authrequest" do should "create the deflated SAMLRequest URL parameter" do settings = Ciam::Saml::Settings.new settings.idp_sso_target_url = "http://example.com" auth_url = Ciam::Saml::Authrequest.new.create(settings) assert auth_url =~ /^http:\/\/example\.com\?SAMLRequest=/ payload = CGI.unescape(auth_url.split("=").last) decoded = Base64.decode64(payload) zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS) inflated = zstream.inflate(decoded) zstream.finish zstream.close assert_match /^<samlp:AuthnRequest/, inflated end should "accept extra parameters" do settings = Ciam::Saml::Settings.new settings.idp_sso_target_url = "http://example.com" auth_url = Ciam::Saml::Authrequest.new.create(settings, { :hello => "there" }) assert auth_url =~ /&hello=there$/ auth_url = Ciam::Saml::Authrequest.new.create(settings, { :hello => nil }) assert auth_url =~ /&hello=$/ end context "when the target url doesn't contain a query string" do should "create the SAMLRequest parameter correctly" do settings = Ciam::Saml::Settings.new settings.idp_sso_target_url = "http://example.com" auth_url = Ciam::Saml::Authrequest.new.create(settings) assert auth_url =~ /^http:\/\/example.com\?SAMLRequest/ end end context "when the target url contains a query string" do should "create the SAMLRequest parameter correctly" do settings = Ciam::Saml::Settings.new settings.idp_sso_target_url = "http://example.com?field=value" auth_url = Ciam::Saml::Authrequest.new.create(settings) assert auth_url =~ /^http:\/\/example.com\?field=value&SAMLRequest/ end end end end
Version data entries
10 entries across 10 versions & 1 rubygems