diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-07-22 15:38:08 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-07-22 15:38:08 +0000 |
commit | 77e2e453649220ba9c002c935bbc18c34fbf5b11 (patch) | |
tree | 7e08870937bc55583fbf5d82e4448f58605749e8 /spec/models/pages_domain_spec.rb | |
parent | e48851de62086b65c75a3dd802743e722d5d7be8 (diff) | |
download | gitlab-ce-77e2e453649220ba9c002c935bbc18c34fbf5b11.tar.gz |
Validate certificate chain only if it's changed
This validation prevents the domain from being saved from the UI
e.g. when user tries to enable Let's Encrypt integration
Diffstat (limited to 'spec/models/pages_domain_spec.rb')
-rw-r--r-- | spec/models/pages_domain_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb index 973c67937b7..519c519fbcf 100644 --- a/spec/models/pages_domain_spec.rb +++ b/spec/models/pages_domain_spec.rb @@ -127,6 +127,30 @@ describe PagesDomain do it { is_expected.not_to be_valid } end + + context 'when certificate is expired' do + let(:domain) do + build(:pages_domain, :with_trusted_expired_chain) + end + + context 'when certificate is being changed' do + it "adds error to certificate" do + domain.valid? + + expect(domain.errors.keys).to contain_exactly(:key, :certificate) + end + end + + context 'when certificate is already saved' do + it "doesn't add error to certificate" do + domain.save(validate: false) + + domain.valid? + + expect(domain.errors.keys).to contain_exactly(:key) + end + end + end end describe 'validations' do |