Skip to content

Commit cf25ef3

Browse files
author
Dan Woolley
committed
Add settings.protocol_binding attribute with tests. Allows setting of ProtocolBinding attribute in AuthnRequest root node of xml doc.
1 parent 84c3a6f commit cf25ef3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/request_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ class RequestTest < Test::Unit::TestCase
6363
assert_match /<samlp:AuthnRequest[^<]* IsPassive='true'/, inflated
6464
end
6565

66+
should "create the SAMLRequest URL parameter with ProtocolBinding" do
67+
settings = Onelogin::Saml::Settings.new
68+
settings.idp_sso_target_url = "http://example.com"
69+
settings.protocol_binding = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
70+
auth_url = Onelogin::Saml::Authrequest.new.create(settings)
71+
assert auth_url =~ /^http:\/\/example\.com\?SAMLRequest=/
72+
payload = CGI.unescape(auth_url.split("=").last)
73+
decoded = Base64.decode64(payload)
74+
75+
zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
76+
inflated = zstream.inflate(decoded)
77+
zstream.finish
78+
zstream.close
79+
80+
assert_match /<samlp:AuthnRequest[^<]* ProtocolBinding='urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'/, inflated
81+
end
82+
6683
should "accept extra parameters" do
6784
settings = OneLogin::RubySaml::Settings.new
6885
settings.idp_sso_target_url = "http://example.com"

0 commit comments

Comments
 (0)