summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Kantojärvi <jaakko@n-1.fi>2013-02-15 11:31:05 +0200
committerJaakko Kantojärvi <jaakko@n-1.fi>2013-02-17 21:31:20 +0200
commit27f4cf75422d2995fdd403ee9562ab30afe85536 (patch)
treee72260ed533a242d3203eb6c1c628f2238ba6f59
parent6fd88b8cbba62d1af4e249cee455a30df0eb0b1b (diff)
downloadgitlab-ce-27f4cf75422d2995fdd403ee9562ab30afe85536.tar.gz
Tests to validate that invalid keys are rejected
-rw-r--r--spec/factories.rb6
-rw-r--r--spec/factories_spec.rb5
-rw-r--r--spec/models/key_spec.rb6
3 files changed, 15 insertions, 2 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index d2e9f48c47b..17dbc796d8f 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -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
diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb
index 5ee7354688a..8360477d8fe 100644
--- a/spec/factories_spec.rb
+++ b/spec/factories_spec.rb
@@ -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)
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 94b952cf932..a9ab2f05a34 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -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