Commit f6c97a6fcc677230b5178dfa1a3d5333477f9467
- Date: Tue Dec 11 22:55:30 +0000 2007
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: f6c97a6fcc677230b5178dfa1a3d5333477f9467
- Tree SHA1: 150723552dcc3a4f0ea0b31b35eb156cb6c097dd
ease parsability of ssh keys
Commit diff
| |   |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | def to_key |
| 14 | %Q{### START KEY #{self.id || "nil"} ###\n} + |
| 14 | 15 | %Q{command="gitorious #{user.login}",no-port-forwarding,} + |
| 15 | | %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{key}} |
| 16 | %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{key}} + |
| 17 | %Q{\n### END KEY #{self.id || "nil"} ###} |
| 16 | 18 | end |
| 17 | 19 | |
| 18 | 20 | protected |
| toggle raw diff |
--- a/app/models/ssh_key.rb
+++ b/app/models/ssh_key.rb
@@ -11,8 +11,10 @@ class SshKey < ActiveRecord::Base
end
def to_key
+ %Q{### START KEY #{self.id || "nil"} ###\n} +
%Q{command="gitorious #{user.login}",no-port-forwarding,} +
- %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{key}}
+ %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{key}} +
+ %Q{\n### END KEY #{self.id || "nil"} ###}
end
protected |
| |   |
| 43 | 43 | |
| 44 | 44 | it "returns a proper ssh key with to_key" do |
| 45 | 45 | ssh_key = create_key |
| 46 | | exp_key = %Q{command="gitorious #{users(:johan).login}",no-port-forwarding,} + |
| 47 | | %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{ssh_key.key}} |
| 46 | ssh_key.save! |
| 47 | exp_key = %Q{### START KEY #{ssh_key.id} ###\n} + |
| 48 | %Q{command="gitorious #{users(:johan).login}",no-port-forwarding,} + |
| 49 | %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{ssh_key.key}} + |
| 50 | %Q{\n### END KEY #{ssh_key.id} ###} |
| 48 | 51 | ssh_key.to_key.should == exp_key |
| 49 | 52 | end |
| 50 | 53 | end |
| toggle raw diff |
--- a/spec/models/ssh_key_spec.rb
+++ b/spec/models/ssh_key_spec.rb
@@ -43,8 +43,11 @@ describe SshKey do
it "returns a proper ssh key with to_key" do
ssh_key = create_key
- exp_key = %Q{command="gitorious #{users(:johan).login}",no-port-forwarding,} +
- %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{ssh_key.key}}
+ ssh_key.save!
+ exp_key = %Q{### START KEY #{ssh_key.id} ###\n} +
+ %Q{command="gitorious #{users(:johan).login}",no-port-forwarding,} +
+ %Q{no-X11-forwarding,no-agent-forwarding,no-pty #{ssh_key.key}} +
+ %Q{\n### END KEY #{ssh_key.id} ###}
ssh_key.to_key.should == exp_key
end
end |
| |   |
| 4 | 4 | --loadby |
| 5 | 5 | mtime |
| 6 | 6 | --reverse |
| 7 | --diff |
| toggle raw diff |
--- a/spec/spec.opts
+++ b/spec/spec.opts
@@ -4,3 +4,4 @@ progress
--loadby
mtime
--reverse
+--diff |