1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/models/x509_certificate_spec.rb

43 lines
1 KiB
Ruby

# 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
end
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'
end
it 'is not allowed to be an invalid certificate' do
is_expected.not_to allow_value OpenSSL::X509::Certificate.new.to_pem
end
end
describe '#subject' do
it { is_expected.to validate_presence_of :subject }
end
describe '#issuer' do
it { is_expected.to validate_presence_of :issuer }
end
describe '#not_before' do
it { is_expected.to validate_presence_of :not_before }
end
describe '#not_after' do
it { is_expected.to validate_presence_of :not_after }
end
end