Skip to content

Commit 9dee0ea

Browse files
author
Lordnibbler
committed
Merge pull request #100 from danwoolley/master
Add settings.protocol_binding attribute with tests.
2 parents 84c3a6f + 45f7971 commit 9dee0ea

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::RubySaml::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::RubySaml::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)