diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/models/key_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/models/key_spec.rb')
-rw-r--r-- | spec/models/key_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index d41a1604211..19459561edf 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -21,6 +21,28 @@ RSpec.describe Key, :mailer do it { is_expected.to allow_value(attributes_for(:ecdsa_key_256)[:key]).for(:key) } it { is_expected.to allow_value(attributes_for(:ed25519_key_256)[:key]).for(:key) } it { is_expected.not_to allow_value('foo-bar').for(:key) } + + context 'key format' do + let(:key) { build(:key) } + + it 'does not allow the key that begins with an algorithm name that is unsupported' do + key.key = 'unsupported-ssh-rsa key' + + key.valid? + + expect(key.errors.of_kind?(:key, :invalid)).to eq(true) + end + + Gitlab::SSHPublicKey.supported_algorithms.each do |supported_algorithm| + it "allows the key that begins with supported algorithm name '#{supported_algorithm}'" do + key.key = "#{supported_algorithm} key" + + key.valid? + + expect(key.errors.of_kind?(:key, :invalid)).to eq(false) + end + end + end end describe "Methods" do |