File tree Expand file tree Collapse file tree
lib/cloud_controller/diego
spec/unit/lib/cloud_controller/diego Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ gem 'sequel', '~> 5.75'
4040gem 'sequel_pg' , require : 'sequel'
4141gem 'sinatra' , '~> 3.1'
4242gem 'sinatra-contrib'
43+ gem 'sshkey'
4344gem 'statsd-ruby' , '~> 1.5.0'
4445gem 'steno'
4546gem 'talentbox-delayed_job_sequel' , '~> 4.3.0'
Original file line number Diff line number Diff line change 527527 spring (4.1.3 )
528528 spring-commands-rspec (1.0.4 )
529529 spring (>= 0.9.1 )
530+ sshkey (3.0.0 )
530531 statsd-ruby (1.5.0 )
531532 steno (1.3.4 )
532533 fluent-logger
@@ -651,6 +652,7 @@ DEPENDENCIES
651652 spork !
652653 spring
653654 spring-commands-rspec
655+ sshkey
654656 statsd-ruby (~> 1.5.0 )
655657 steno
656658 talentbox-delayed_job_sequel (~> 4.3.0 )
Original file line number Diff line number Diff line change 11require 'net/ssh'
2+ require 'sshkey'
23
34module VCAP
45 module CloudController
56 module Diego
67 class SSHKey
7- def initialize ( bits = 1024 )
8+ def initialize ( bits = 2048 )
89 @bits = bits
910 end
1011
@@ -21,7 +22,9 @@ def authorized_key
2122 end
2223 end
2324
24- delegate :fingerprint , to : :key
25+ def fingerprint
26+ @fingerprint ||= ::SSHKey . new ( key . to_der ) . sha1_fingerprint
27+ end
2528
2629 private
2730
Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ module Diego
3232 expect ( key1 ) . to eq ( key2 )
3333 end
3434 end
35+
36+ describe '#fingerprint' do
37+ it 'returns an sha1 fingerprint' do
38+ ssh_key = SSHKey . new ( 1024 )
39+ expect ( ssh_key . fingerprint ) . to match ( /([0-9a-f]{2}:){19}[0-9a-f]{2}/ )
40+ end
41+ end
3542 end
3643 end
3744end
You can’t perform that action at this time.
0 commit comments