Commit 27f4cf75422d2995fdd403ee9562ab30afe85536
1 parent
6fd88b8c
Exists in
master
and in
4 other branches
Tests to validate that invalid keys are rejected
Showing
3 changed files
with
15 additions
and
2 deletions
Show diff stats
spec/factories.rb
| ... | ... | @@ -148,6 +148,12 @@ FactoryGirl.define do |
| 148 | 148 | "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" |
| 149 | 149 | end |
| 150 | 150 | end |
| 151 | + | |
| 152 | + factory :invalid_key do | |
| 153 | + key do | |
| 154 | + "ssh-rsa this_is_invalid_key==" | |
| 155 | + end | |
| 156 | + end | |
| 151 | 157 | end |
| 152 | 158 | |
| 153 | 159 | factory :milestone do | ... | ... |
spec/factories_spec.rb
spec/models/key_spec.rb
| ... | ... | @@ -73,8 +73,12 @@ describe Key do |
| 73 | 73 | build(:key, user: user).should be_valid |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | - it "rejects the unfingerprintable key" do | |
| 76 | + it "rejects the unfingerprintable key (contains space in middle)" do | |
| 77 | 77 | build(:key_with_a_space_in_the_middle).should_not be_valid |
| 78 | 78 | end |
| 79 | + | |
| 80 | + it "rejects the unfingerprintable key (not a key)" do | |
| 81 | + build(:invalid_key).should_not be_valid | |
| 82 | + end | |
| 79 | 83 | end |
| 80 | 84 | end | ... | ... |