11require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , "test_helper" ) )
22
3- class RequestTest < Test :: Unit :: TestCase
3+ class RequestTest < Minitest :: Test
44
5- context "Logoutrequest" do
6- settings = OneLogin ::RubySaml ::Settings . new
5+ describe "Logoutrequest" do
6+ let ( : settings) { OneLogin ::RubySaml ::Settings . new }
77
8- should "create the deflated SAMLRequest URL parameter" do
8+ it "create the deflated SAMLRequest URL parameter" do
99 settings . idp_slo_target_url = "http://unauth.com/logout"
1010 settings . name_identifier_value = "f00f00"
1111
@@ -17,16 +17,16 @@ class RequestTest < Test::Unit::TestCase
1717 assert_match /^<samlp:LogoutRequest/ , inflated
1818 end
1919
20- should "support additional params" do
21-
20+ it "support additional params" do
21+ settings . idp_slo_target_url = "http://example.com"
2222 unauth_url = OneLogin ::RubySaml ::Logoutrequest . new . create ( settings , { :hello => nil } )
2323 assert unauth_url =~ /&hello=$/
2424
2525 unauth_url = OneLogin ::RubySaml ::Logoutrequest . new . create ( settings , { :foo => "bar" } )
2626 assert unauth_url =~ /&foo=bar$/
2727 end
2828
29- should "set sessionindex" do
29+ it "set sessionindex" do
3030 settings . idp_slo_target_url = "http://example.com"
3131 sessionidx = UUID . new . generate
3232 settings . sessionindex = sessionidx
@@ -38,7 +38,7 @@ class RequestTest < Test::Unit::TestCase
3838 assert_match %r(#{ sessionidx } </samlp:SessionIndex>) , inflated
3939 end
4040
41- should "set name_identifier_value" do
41+ it "set name_identifier_value" do
4242 settings = OneLogin ::RubySaml ::Settings . new
4343 settings . idp_slo_target_url = "http://example.com"
4444 settings . name_identifier_format = "transient"
@@ -52,8 +52,8 @@ class RequestTest < Test::Unit::TestCase
5252 assert_match %r(#{ name_identifier_value } </saml:NameID>) , inflated
5353 end
5454
55- context "when the target url doesn't contain a query string" do
56- should "create the SAMLRequest parameter correctly" do
55+ describe "when the target url doesn't contain a query string" do
56+ it "create the SAMLRequest parameter correctly" do
5757 settings = OneLogin ::RubySaml ::Settings . new
5858 settings . idp_slo_target_url = "http://example.com"
5959 settings . name_identifier_value = "f00f00"
@@ -63,8 +63,8 @@ class RequestTest < Test::Unit::TestCase
6363 end
6464 end
6565
66- context "when the target url contains a query string" do
67- should "create the SAMLRequest parameter correctly" do
66+ describe "when the target url contains a query string" do
67+ it "create the SAMLRequest parameter correctly" do
6868 settings = OneLogin ::RubySaml ::Settings . new
6969 settings . idp_slo_target_url = "http://example.com?field=value"
7070 settings . name_identifier_value = "f00f00"
@@ -74,8 +74,8 @@ class RequestTest < Test::Unit::TestCase
7474 end
7575 end
7676
77- context "consumation of logout may need to track the transaction" do
78- should "have access to the request uuid" do
77+ describe "consumation of logout may need to track the transaction" do
78+ it "have access to the request uuid" do
7979 settings = OneLogin ::RubySaml ::Settings . new
8080 settings . idp_slo_target_url = "http://example.com?field=value"
8181 settings . name_identifier_value = "f00f00"
@@ -88,8 +88,8 @@ class RequestTest < Test::Unit::TestCase
8888 end
8989 end
9090
91- context "when the settings indicate to sign (embebed) the logout request" do
92- should "created a signed logout request" do
91+ describe "when the settings indicate to sign (embebed) the logout request" do
92+ it "created a signed logout request" do
9393 settings = OneLogin ::RubySaml ::Settings . new
9494 settings . idp_slo_target_url = "http://example.com?field=value"
9595 settings . name_identifier_value = "f00f00"
@@ -106,7 +106,7 @@ class RequestTest < Test::Unit::TestCase
106106 assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>] , inflated
107107 end
108108
109- should "create a signed logout request with 256 digest and signature methods" do
109+ it "create a signed logout request with 256 digest and signature methods" do
110110 settings = OneLogin ::RubySaml ::Settings . new
111111 settings . compress_request = false
112112 settings . idp_slo_target_url = "http://example.com?field=value"
@@ -128,8 +128,8 @@ class RequestTest < Test::Unit::TestCase
128128 end
129129 end
130130
131- context "when the settings indicate to sign the logout request" do
132- should "create a signature parameter" do
131+ describe "when the settings indicate to sign the logout request" do
132+ it "create a signature parameter" do
133133 settings = OneLogin ::RubySaml ::Settings . new
134134 settings . compress_request = false
135135 settings . idp_slo_target_url = "http://example.com?field=value"
@@ -153,16 +153,4 @@ class RequestTest < Test::Unit::TestCase
153153 end
154154
155155 end
156-
157- def decode_saml_request_payload ( unauth_url )
158- payload = CGI . unescape ( unauth_url . split ( "SAMLRequest=" ) . last )
159- decoded = Base64 . decode64 ( payload )
160-
161- zstream = Zlib ::Inflate . new ( -Zlib ::MAX_WBITS )
162- inflated = zstream . inflate ( decoded )
163- zstream . finish
164- zstream . close
165- inflated
166- end
167-
168156end
0 commit comments