test/response_test.rb in ruby-saml-0.4.7 vs test/response_test.rb in ruby-saml-0.5.0

- old
+ new

@@ -5,19 +5,41 @@ context "Response" do should "raise an exception when response is initialized with nil" do assert_raises(ArgumentError) { Onelogin::Saml::Response.new(nil) } end + should "be able to parse a document which contains ampersands" do + XMLSecurity::SignedDocument.any_instance.stubs(:digests_match?).returns(true) + Onelogin::Saml::Response.any_instance.stubs(:validate_conditions).returns(true) + + response = Onelogin::Saml::Response.new(ampersands_response) + settings = Onelogin::Saml::Settings.new + settings.idp_cert_fingerprint = 'c51985d947f1be57082025050846eb27f6cab783' + response.settings = settings + response.validate! + end + should "adapt namespace" do response = Onelogin::Saml::Response.new(response_document) assert !response.name_id.nil? response = Onelogin::Saml::Response.new(response_document_2) assert !response.name_id.nil? response = Onelogin::Saml::Response.new(response_document_3) assert !response.name_id.nil? end + context "Assertion" do + should "only retreive an assertion with an ID that matches the signature's reference URI" do + response = Onelogin::Saml::Response.new(wrapped_response_2) + response.stubs(:conditions).returns(nil) + settings = Onelogin::Saml::Settings.new + settings.idp_cert_fingerprint = signature_fingerprint_1 + response.settings = settings + assert response.name_id.nil? + end + end + context "#validate!" do should "raise when encountering a condition that prevents the document from being valid" do response = Onelogin::Saml::Response.new(response_document) assert_raise(Onelogin::Saml::ValidationError) do response.validate! @@ -146,8 +168,14 @@ response = Onelogin::Saml::Response.new(response_document_2) assert response.session_expires_at.nil? end end - end + context "#issuer" do + should "return the issuer of the assertion" do + response = Onelogin::Saml::Response.new(response_document_2) + assert_equal "wibble", response.issuer + end + end + end end