Tests to validate that invalid keys are rejected

This commit is contained in:
Jaakko Kantojärvi 2013-02-15 11:31:05 +02:00
parent 6fd88b8cbb
commit 27f4cf7542
3 changed files with 15 additions and 2 deletions

View file

@ -148,6 +148,12 @@ FactoryGirl.define do
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
end
end
factory :invalid_key do
key do
"ssh-rsa this_is_invalid_key=="
end
end
end
factory :milestone do

View file

@ -1,6 +1,9 @@
require 'spec_helper'
INVALID_FACTORIES = [:key_with_a_space_in_the_middle]
INVALID_FACTORIES = [
:key_with_a_space_in_the_middle,
:invalid_key,
]
FactoryGirl.factories.map(&:name).each do |factory_name|
next if INVALID_FACTORIES.include?(factory_name)

View file

@ -73,8 +73,12 @@ describe Key do
build(:key, user: user).should be_valid
end
it "rejects the unfingerprintable key" do
it "rejects the unfingerprintable key (contains space in middle)" do
build(:key_with_a_space_in_the_middle).should_not be_valid
end
it "rejects the unfingerprintable key (not a key)" do
build(:invalid_key).should_not be_valid
end
end
end