@@ -15,6 +15,7 @@ class RubySamlTest < Minitest::Test
1515 let ( :response_wrapped ) { OneLogin ::RubySaml ::Response . new ( response_document_wrapped ) }
1616 let ( :response_multiple_attr_values ) { OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) ) }
1717 let ( :response_valid_signed ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed ) }
18+ let ( :response_valid_signed_without_x509certificate ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed_without_x509certificate ) }
1819 let ( :response_no_id ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_id.xml.base64" ) ) }
1920 let ( :response_no_version ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_saml2.xml.base64" ) ) }
2021 let ( :response_multi_assertion ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "multiple_assertions.xml.base64" ) ) }
@@ -687,6 +688,30 @@ class RubySamlTest < Minitest::Test
687688 assert !response . send ( :validate_signature )
688689 assert_includes response . errors , "Invalid Signature on SAML Response"
689690 end
691+
692+ it "return false when no X509Certificate and not cert provided at settings" do
693+ settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
694+ settings . idp_cert = nil
695+ response_valid_signed_without_x509certificate . settings = settings
696+ assert !response_valid_signed_without_x509certificate . send ( :validate_signature )
697+ assert_includes response_valid_signed_without_x509certificate . errors , "Invalid Signature on SAML Response"
698+ end
699+
700+ it "return false when no X509Certificate and the cert provided at settings mismatches" do
701+ settings . idp_cert_fingerprint = nil
702+ settings . idp_cert = signature_1
703+ response_valid_signed_without_x509certificate . settings = settings
704+ assert !response_valid_signed_without_x509certificate . send ( :validate_signature )
705+ assert_includes response_valid_signed_without_x509certificate . errors , "Invalid Signature on SAML Response"
706+ end
707+
708+ it "return true when no X509Certificate and the cert provided at settings matches" do
709+ settings . idp_cert_fingerprint = nil
710+ settings . idp_cert = ruby_saml_cert_text
711+ response_valid_signed_without_x509certificate . settings = settings
712+ assert response_valid_signed_without_x509certificate . send ( :validate_signature )
713+ assert_empty response_valid_signed_without_x509certificate . errors
714+ end
690715 end
691716
692717 describe "#nameid" do
0 commit comments