Commit c4202554 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rs-remove-invalid-key-factories' into 'master'

Remove the invalid key factories

They're only used once each, and they're easy to build in-place.

See merge request !1766
parents 4632983c 273df6a4
...@@ -101,12 +101,6 @@ FactoryGirl.define do ...@@ -101,12 +101,6 @@ FactoryGirl.define do
user user
end end
factory :key_with_a_space_in_the_middle do
key do
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
end
end
factory :another_key do factory :another_key do
key do key do
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ"
...@@ -115,12 +109,6 @@ FactoryGirl.define do ...@@ -115,12 +109,6 @@ FactoryGirl.define do
factory :another_deploy_key, class: 'DeployKey' do factory :another_deploy_key, class: 'DeployKey' do
end end
end end
factory :invalid_key do
key do
"ssh-rsa this_is_invalid_key=="
end
end
end end
factory :email do factory :email do
......
require 'spec_helper' require 'spec_helper'
INVALID_FACTORIES = [
:key_with_a_space_in_the_middle,
:invalid_key,
]
FactoryGirl.factories.map(&:name).each do |factory_name| FactoryGirl.factories.map(&:name).each do |factory_name|
next if INVALID_FACTORIES.include?(factory_name)
describe "#{factory_name} factory" do describe "#{factory_name} factory" do
it 'should be valid' do it 'should be valid' do
expect(build(factory_name)).to be_valid expect(build(factory_name)).to be_valid
......
...@@ -58,12 +58,17 @@ describe Key do ...@@ -58,12 +58,17 @@ describe Key do
expect(build(:key)).to be_valid expect(build(:key)).to be_valid
end end
it "rejects the unfingerprintable key (contains space in middle)" do it 'rejects an unfingerprintable key that contains a space' do
expect(build(:key_with_a_space_in_the_middle)).not_to be_valid key = build(:key)
# Not always the middle, but close enough
key.key = key.key[0..100] + ' ' + key.key[100..-1]
expect(key).not_to be_valid
end end
it "rejects the unfingerprintable key (not a key)" do it 'rejects the unfingerprintable key (not a key)' do
expect(build(:invalid_key)).not_to be_valid expect(build(:key, key: 'ssh-rsa an-invalid-key==')).not_to be_valid
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment