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

51 lines
1.2 KiB
Ruby
Raw Normal View History

2019-09-10 18:57:12 -04:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe X509Certificate do
subject { create :self_signed_x509_certificate }
2019-09-13 14:03:33 -04:00
describe '#asymmetric_key' do
it { is_expected.to belong_to(:asymmetric_key).required }
it do
is_expected.to \
2019-09-13 14:03:33 -04:00
validate_presence_of(:asymmetric_key).with_message(:required)
end
2019-09-13 14:03:33 -04:00
it { is_expected.not_to validate_uniqueness_of :asymmetric_key }
end
2019-09-10 18:57:12 -04:00
describe '#pem' do
def allow_value(*)
super.for :pem
end
2019-09-10 18:57:12 -04:00
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
2019-09-10 18:57:12 -04:00
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
2019-09-10 18:57:12 -04:00
end