Commit ea28519f5704c8dab74cba4d1e2039331504aafd
Exists in
master
and in
4 other branches
Merge pull request #2996 from raphendyr/ssh_fingerprint_fix
Ssh fingerprint fix
Showing
5 changed files
with
17 additions
and
4 deletions
Show diff stats
app/models/key.rb
| ... | ... | @@ -45,7 +45,7 @@ class Key < ActiveRecord::Base |
| 45 | 45 | file.close |
| 46 | 46 | file.unlink # deletes the temp file |
| 47 | 47 | end |
| 48 | - errors.add(:key, "can't be fingerprinted") if fingerprint_output.match("failed") | |
| 48 | + errors.add(:key, "can't be fingerprinted") if $?.exitstatus != 0 | |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | def set_identifier | ... | ... |
features/steps/profile/profile_ssh_keys.rb
| ... | ... | @@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | And 'I have ssh key "ssh-rsa Work"' do |
| 46 | - create(:key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work") | |
| 46 | + create(:key, :user => @user, :title => "ssh-rsa Work", :key => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+L3TbFegm3k8QjejSwemk4HhlRh+DuN679Pc5ckqE/MPhVtE/+kZQDYCTB284GiT2aIoGzmZ8ee9TkaoejAsBwlA+Wz2Q3vhz65X6sMgalRwpdJx8kSEUYV8ZPV3MZvPo8KdNg993o4jL6G36GDW4BPIyO6FPZhfsawdf6liVD0Xo5kibIK7B9VoE178cdLQtLpS2YolRwf5yy6XR6hbbBGQR+6xrGOdP16eGZDb1CE2bMvvJijjloFqPscGktWOqW+nfh5txwFfBzlfARDTBsS8WZtg3Yoj1kn33kPsWRlgHfNutFRAIynDuDdQzQq8tTtVwm+Yi75RfcPHW8y3P Work") | |
| 47 | 47 | end |
| 48 | 48 | end | ... | ... |
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 | ... | ... |