@@ -16,6 +16,7 @@ class RubySamlTest < Minitest::Test
1616 let ( :response_wrapped ) { OneLogin ::RubySaml ::Response . new ( response_document_wrapped ) }
1717 let ( :response_multiple_attr_values ) { OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) ) }
1818 let ( :response_valid_signed ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed ) }
19+ let ( :response_valid_signed_without_x509certificate ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed_without_x509certificate ) }
1920 let ( :response_no_id ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_id.xml.base64" ) ) }
2021 let ( :response_no_version ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_saml2.xml.base64" ) ) }
2122 let ( :response_multi_assertion ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "multiple_assertions.xml.base64" ) ) }
@@ -695,6 +696,30 @@ class RubySamlTest < Minitest::Test
695696 assert !response . send ( :validate_signature )
696697 assert_includes response . errors , "Invalid Signature on SAML Response"
697698 end
699+
700+ it "return false when no X509Certificate and not cert provided at settings" do
701+ settings . idp_cert_fingerprint = ruby_saml_cert_fingerprint
702+ settings . idp_cert = nil
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 false when no X509Certificate and the cert provided at settings mismatches" do
709+ settings . idp_cert_fingerprint = nil
710+ settings . idp_cert = signature_1
711+ response_valid_signed_without_x509certificate . settings = settings
712+ assert !response_valid_signed_without_x509certificate . send ( :validate_signature )
713+ assert_includes response_valid_signed_without_x509certificate . errors , "Invalid Signature on SAML Response"
714+ end
715+
716+ it "return true when no X509Certificate and the cert provided at settings matches" do
717+ settings . idp_cert_fingerprint = nil
718+ settings . idp_cert = ruby_saml_cert_text
719+ response_valid_signed_without_x509certificate . settings = settings
720+ assert response_valid_signed_without_x509certificate . send ( :validate_signature )
721+ assert_empty response_valid_signed_without_x509certificate . errors
722+ end
698723 end
699724
700725 describe "#nameid" do
0 commit comments