Commit d30832f

mo <mo@mokhan.ca>
2018-03-06 16:57:42
return true/false instead of truthy/falsey
1 parent ece054a
Changed files (2)
lib
spec
lib/saml/kit/signature.rb
@@ -26,7 +26,7 @@ module Saml
       # Returns true when the fingerprint of the certificate matches one of the certificates registered in the metadata.
       def trusted?(metadata)
         return false if metadata.nil?
-        metadata.matches?(certificate.fingerprint, use: :signing)
+        metadata.matches?(certificate.fingerprint, use: :signing).present?
       end
 
       def digest_value
spec/saml/kit/signature_spec.rb
@@ -117,4 +117,18 @@ RSpec.describe Saml::Kit::Signature do
       expect(subject.expected_digest_value).to eql(expected_digest)
     end
   end
+
+  describe "#trusted?" do
+    context "when trusted" do
+      let(:metadata) { instance_double(Saml::Kit::Metadata, matches?: Object.new) }
+
+      specify { expect(subject.trusted?(metadata)).to be(true) }
+    end
+
+    context "when untrusted" do
+      let(:metadata) { instance_double(Saml::Kit::Metadata, matches?: nil) }
+
+      specify { expect(subject.trusted?(metadata)).to be(false) }
+    end
+  end
 end