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,7 +45,7 @@ class Key < ActiveRecord::Base | ||
| 45 | file.close | 45 | file.close |
| 46 | file.unlink # deletes the temp file | 46 | file.unlink # deletes the temp file |
| 47 | end | 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 | end | 49 | end |
| 50 | 50 | ||
| 51 | def set_identifier | 51 | def set_identifier |
features/steps/profile/profile_ssh_keys.rb
| @@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps | @@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps | ||
| 43 | end | 43 | end |
| 44 | 44 | ||
| 45 | And 'I have ssh key "ssh-rsa Work"' do | 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 | end | 47 | end |
| 48 | end | 48 | end |
spec/factories.rb
| @@ -148,6 +148,12 @@ FactoryGirl.define do | @@ -148,6 +148,12 @@ FactoryGirl.define do | ||
| 148 | "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" | 148 | "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" |
| 149 | end | 149 | end |
| 150 | end | 150 | end |
| 151 | + | ||
| 152 | + factory :invalid_key do | ||
| 153 | + key do | ||
| 154 | + "ssh-rsa this_is_invalid_key==" | ||
| 155 | + end | ||
| 156 | + end | ||
| 151 | end | 157 | end |
| 152 | 158 | ||
| 153 | factory :milestone do | 159 | factory :milestone do |
spec/factories_spec.rb
| 1 | require 'spec_helper' | 1 | require 'spec_helper' |
| 2 | 2 | ||
| 3 | -INVALID_FACTORIES = [:key_with_a_space_in_the_middle] | 3 | +INVALID_FACTORIES = [ |
| 4 | + :key_with_a_space_in_the_middle, | ||
| 5 | + :invalid_key, | ||
| 6 | +] | ||
| 4 | 7 | ||
| 5 | FactoryGirl.factories.map(&:name).each do |factory_name| | 8 | FactoryGirl.factories.map(&:name).each do |factory_name| |
| 6 | next if INVALID_FACTORIES.include?(factory_name) | 9 | next if INVALID_FACTORIES.include?(factory_name) |
spec/models/key_spec.rb
| @@ -73,8 +73,12 @@ describe Key do | @@ -73,8 +73,12 @@ describe Key do | ||
| 73 | build(:key, user: user).should be_valid | 73 | build(:key, user: user).should be_valid |
| 74 | end | 74 | end |
| 75 | 75 | ||
| 76 | - it "rejects the unfingerprintable key" do | 76 | + it "rejects the unfingerprintable key (contains space in middle)" do |
| 77 | build(:key_with_a_space_in_the_middle).should_not be_valid | 77 | build(:key_with_a_space_in_the_middle).should_not be_valid |
| 78 | end | 78 | end |
| 79 | + | ||
| 80 | + it "rejects the unfingerprintable key (not a key)" do | ||
| 81 | + build(:invalid_key).should_not be_valid | ||
| 82 | + end | ||
| 79 | end | 83 | end |
| 80 | end | 84 | end |