@@ -17,7 +17,7 @@ class RubySamlTest < Minitest::Test
17
17
let ( :response_wrapped ) { OneLogin ::RubySaml ::Response . new ( response_document_wrapped ) }
18
18
let ( :response_multiple_attr_values ) { OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) ) }
19
19
let ( :response_valid_signed ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed ) }
20
- let ( :response_valid_signed_with_recipient ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed , { :skip_recipient_check => false } ) }
20
+ let ( :response_valid_signed_without_recipient ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed , { :skip_recipient_check => true } ) }
21
21
let ( :response_valid_signed_without_x509certificate ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed_without_x509certificate ) }
22
22
let ( :response_no_id ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_id.xml.base64" ) ) }
23
23
let ( :response_no_version ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_saml2.xml.base64" ) ) }
@@ -242,19 +242,19 @@ class RubySamlTest < Minitest::Test
242
242
end
243
243
244
244
it "return true when the response is initialized with valid data" do
245
- response_valid_signed . stubs ( :conditions ) . returns ( nil )
246
- response_valid_signed . settings = settings
247
- response_valid_signed . settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
248
- assert response_valid_signed . is_valid?
249
- assert_empty response_valid_signed . errors
245
+ response_valid_signed_without_recipient . stubs ( :conditions ) . returns ( nil )
246
+ response_valid_signed_without_recipient . settings = settings
247
+ response_valid_signed_without_recipient . settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
248
+ assert response_valid_signed_without_recipient . is_valid?
249
+ assert_empty response_valid_signed_without_recipient . errors
250
250
end
251
251
252
252
it "return true when the response is initialized with valid data and using certificate instead of fingerprint" do
253
- response_valid_signed . stubs ( :conditions ) . returns ( nil )
254
- response_valid_signed . settings = settings
255
- response_valid_signed . settings . idp_cert = ruby_saml_cert_text
256
- assert response_valid_signed . is_valid?
257
- assert_empty response_valid_signed . errors
253
+ response_valid_signed_without_recipient . stubs ( :conditions ) . returns ( nil )
254
+ response_valid_signed_without_recipient . settings = settings
255
+ response_valid_signed_without_recipient . settings . idp_cert = ruby_saml_cert_text
256
+ assert response_valid_signed_without_recipient . is_valid?
257
+ assert_empty response_valid_signed_without_recipient . errors
258
258
end
259
259
260
260
it "return false when response is initialized with blank data" do
@@ -283,11 +283,11 @@ class RubySamlTest < Minitest::Test
283
283
end
284
284
285
285
it "should be idempotent when the response is initialized with valid data" do
286
- response_valid_signed . stubs ( :conditions ) . returns ( nil )
287
- response_valid_signed . settings = settings
288
- response_valid_signed . settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
289
- assert response_valid_signed . is_valid?
290
- assert response_valid_signed . is_valid?
286
+ response_valid_signed_without_recipient . stubs ( :conditions ) . returns ( nil )
287
+ response_valid_signed_without_recipient . settings = settings
288
+ response_valid_signed_without_recipient . settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
289
+ assert response_valid_signed_without_recipient . is_valid?
290
+ assert response_valid_signed_without_recipient . is_valid?
291
291
end
292
292
293
293
it "not allow signature wrapping attack" do
@@ -383,6 +383,7 @@ class RubySamlTest < Minitest::Test
383
383
384
384
it "return true when a nil URI is given in the ds:Reference" do
385
385
settings . idp_cert = ruby_saml_cert_text
386
+ settings . assertion_consumer_service_url = "http://localhost:9001/v1/users/authorize/saml"
386
387
response_without_reference_uri . settings = settings
387
388
response_without_reference_uri . stubs ( :conditions ) . returns ( nil )
388
389
response_without_reference_uri . is_valid?
@@ -678,25 +679,25 @@ class RubySamlTest < Minitest::Test
678
679
end
679
680
680
681
it "return true when valid subject confirmation recipient" do
681
- response_valid_signed_with_recipient . settings = settings
682
- response_valid_signed_with_recipient . settings . assertion_consumer_service_url = 'recipient'
682
+ response_valid_signed . settings = settings
683
+ response_valid_signed . settings . assertion_consumer_service_url = 'recipient'
683
684
assert response_valid_signed . send ( :validate_subject_confirmation )
684
685
assert_empty response_valid_signed . errors
685
- assert_empty response_valid_signed_with_recipient . errors
686
+ assert_empty response_valid_signed . errors
686
687
end
687
688
688
689
it "return false when invalid subject confirmation recipient" do
689
- response_valid_signed_with_recipient . settings = settings
690
- response_valid_signed_with_recipient . settings . assertion_consumer_service_url = 'not-the-recipient'
691
- assert !response_valid_signed_with_recipient . send ( :validate_subject_confirmation )
692
- assert_includes response_valid_signed_with_recipient . errors , "A valid SubjectConfirmation was not found on this Response"
690
+ response_valid_signed . settings = settings
691
+ response_valid_signed . settings . assertion_consumer_service_url = 'not-the-recipient'
692
+ assert !response_valid_signed . send ( :validate_subject_confirmation )
693
+ assert_includes response_valid_signed . errors , "A valid SubjectConfirmation was not found on this Response"
693
694
end
694
695
695
696
it "return false when invalid subject confirmation recipient, but skipping the check(default)" do
696
- response_valid_signed . settings = settings
697
- response_valid_signed . settings . assertion_consumer_service_url = 'not-the-recipient'
698
- assert response_valid_signed . send ( :validate_subject_confirmation )
699
- assert_empty response_valid_signed . errors
697
+ response_valid_signed_without_recipient . settings = settings
698
+ response_valid_signed_without_recipient . settings . assertion_consumer_service_url = 'not-the-recipient'
699
+ assert response_valid_signed_without_recipient . send ( :validate_subject_confirmation )
700
+ assert_empty response_valid_signed_without_recipient . errors
700
701
end
701
702
702
703
it "return true when the skip_subject_confirmation option is passed and the subject confirmation is valid" do
@@ -1146,6 +1147,7 @@ class RubySamlTest < Minitest::Test
1146
1147
document . sign_document ( private_key , cert )
1147
1148
1148
1149
signed_response = OneLogin ::RubySaml ::Response . new ( document . to_s )
1150
+ settings . assertion_consumer_service_url = "http://recipient"
1149
1151
settings . idp_cert = ruby_saml_cert_text
1150
1152
signed_response . settings = settings
1151
1153
Timecop . freeze ( Time . parse ( "2015-03-18T04:50:24Z" ) ) do
0 commit comments