diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-09-07 00:29:03 +0000 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2019-09-07 00:29:03 +0000 |
commit | 8c3d0703ed71e9ac166b221146176a3ea7e23989 (patch) | |
tree | d40d8446bf384a0cffb95e818bbeac4f55221a8a /spec/validators | |
parent | 7920ff1147051324e63c6b28cd93ca616d5b3165 (diff) | |
download | gitlab-ce-8c3d0703ed71e9ac166b221146176a3ea7e23989.tar.gz |
Allow to load ECDSA certificates for pages domains
Just replace RSA.new with PKey.read
Diffstat (limited to 'spec/validators')
-rw-r--r-- | spec/validators/named_ecdsa_key_validator_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/validators/named_ecdsa_key_validator_spec.rb b/spec/validators/named_ecdsa_key_validator_spec.rb new file mode 100644 index 00000000000..044c5b84a56 --- /dev/null +++ b/spec/validators/named_ecdsa_key_validator_spec.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe NamedEcdsaKeyValidator do + let(:validator) { described_class.new(attributes: [:key]) } + let!(:domain) { build(:pages_domain) } + + subject { validator.validate_each(domain, :key, value) } + + context 'with empty value' do + let(:value) { nil } + + it 'does not add any error if value is empty' do + subject + + expect(domain.errors).to be_empty + end + end + + shared_examples 'does not add any error' do + it 'does not add any error' do + expect(value).to be_present + + subject + + expect(domain.errors).to be_empty + end + end + + context 'when key is not EC' do + let(:value) { attributes_for(:pages_domain)[:key] } + + include_examples 'does not add any error' + end + + context 'with ECDSA certificate with named curve' do + let(:value) { attributes_for(:pages_domain, :ecdsa)[:key] } + + include_examples 'does not add any error' + end + + context 'with ECDSA certificate with explicit curve params' do + let(:value) { attributes_for(:pages_domain, :explicit_ecdsa)[:key] } + + it 'adds errors' do + expect(value).to be_present + + subject + + expect(domain.errors[:key]).not_to be_empty + end + end +end |