File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -615,10 +615,13 @@ def validate_destination
615615 end
616616
617617 # Checks that the samlp:Response/saml:Assertion/saml:Conditions element exists and is unique.
618+ # (If the response was initialized with the :skip_conditions option, this validation is skipped)
618619 # If fails, the error is added to the errors array
619620 # @return [Boolean] True if there is a conditions element and is unique
620621 #
621622 def validate_one_conditions
623+ return true if options [ :skip_conditions ]
624+
622625 conditions_nodes = xpath_from_signed_assertion ( '/a:Conditions' )
623626 unless conditions_nodes . size == 1
624627 error_msg = "The Assertion must include one Conditions element"
@@ -634,7 +637,7 @@ def validate_one_conditions
634637 #
635638 def validate_one_authnstatement
636639 return true if options [ :skip_authnstatement ]
637-
640+
638641 authnstatement_nodes = xpath_from_signed_assertion ( '/a:AuthnStatement' )
639642 unless authnstatement_nodes . size == 1
640643 error_msg = "The Assertion must include one AuthnStatement element"
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class RubySamlTest < Minitest::Test
2323 let ( :response_no_version ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_saml2.xml.base64" ) ) }
2424 let ( :response_multi_assertion ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "multiple_assertions.xml.base64" ) ) }
2525 let ( :response_no_conditions ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_conditions.xml.base64" ) ) }
26+ let ( :response_no_conditions_with_skip ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_conditions.xml.base64" ) , { :skip_conditions => true } ) }
2627 let ( :response_no_authnstatement ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_authnstatement.xml.base64" ) ) }
2728 let ( :response_no_authnstatement_with_skip ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "no_authnstatement.xml.base64" ) , { :skip_authnstatement => true } ) }
2829 let ( :response_empty_destination ) { OneLogin ::RubySaml ::Response . new ( read_invalid_response ( "empty_destination.xml.base64" ) ) }
@@ -984,6 +985,11 @@ class RubySamlTest < Minitest::Test
984985 response . soft = true
985986 assert response . send ( :validate_one_conditions )
986987 end
988+
989+ it "return true when no conditions are present and skip_conditions is true" do
990+ response_no_conditions_with_skip . soft = true
991+ assert response_no_conditions_with_skip . send ( :validate_one_conditions )
992+ end
987993 end
988994
989995 describe "#check_one_authnstatement" do
You can’t perform that action at this time.
0 commit comments