# frozen_string_literal: true
require 'rails_helper'
RSpec.describe X509Certificate do
subject { create :self_signed_x509_certificate }
describe '#x509_certificate_request' do
it { is_expected.not_to validate_presence_of :x509_certificate_request }
end
describe '#pem' do
def allow_value(*)
super.for :pem
it { is_expected.to validate_presence_of :pem }
it 'is allowed to be a valid certificate' do
is_expected.to allow_value File.read Rails.root.join 'fixtures', 'ca.crt'
it 'is not allowed to be an invalid certificate' do
is_expected.not_to allow_value OpenSSL::X509::Certificate.new.to_pem
describe '#subject' do
it { is_expected.to validate_presence_of :subject }
describe '#issuer' do
it { is_expected.to validate_presence_of :issuer }
describe '#not_before' do
it { is_expected.to validate_presence_of :not_before }
describe '#not_after' do
it { is_expected.to validate_presence_of :not_after }