Commit 8912ad9

mo <mo.khan@gmail.com>
2018-02-15 17:08:49
delegate not_after, not_before to x509
1 parent befddfa
Changed files (2)
lib/xml/kit/certificate.rb
@@ -98,6 +98,14 @@ module Xml
         x509.not_before <= time && !expired?(time)
       end
 
+      def not_after
+        x509.not_after
+      end
+
+      def not_before
+        x509.not_before
+      end
+
       class << self
         def to_x509(value)
           return value if value.is_a?(OpenSSL::X509::Certificate)
spec/xml/certificate_spec.rb
@@ -121,4 +121,22 @@ RSpec.describe Xml::Kit::Certificate do
       end
     end
   end
+
+  describe "#not_after, #not_before" do
+    subject { described_class.new(certificate, use: :signing) }
+    let(:certificate) { OpenSSL::X509::Certificate.new }
+
+    before :each do
+      certificate.not_before = 1.minute.from_now
+      certificate.not_after = 10.minutes.from_now
+    end
+
+    it 'delegates not_after to the x509 certificate' do
+      expect(subject.not_after).to eql(certificate.not_after)
+    end
+
+    it 'delegates not_before to the x509 certificate' do
+      expect(subject.not_before).to eql(certificate.not_before)
+    end
+  end
 end