shelly 0.1.33 → 0.1.34.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ * [feature] Accept DSA keys when logging in or registering
2
+
3
+ DSA key is used in the first place, if it doesn't exist RSA key is used
4
+
1
5
  ## 0.1.31 / 2012-10-10
2
6
 
3
7
  * [bug] Writing backups to disk in binary mode to avoid ascii/utf8 conversion errors.
data/lib/shelly/user.rb CHANGED
@@ -53,7 +53,8 @@ module Shelly
53
53
  end
54
54
 
55
55
  def delete_ssh_key
56
- shelly.logout(File.read(ssh_key_path)) if ssh_key_exists?
56
+ shelly.logout(File.read(dsa_key)) if File.exists?(dsa_key)
57
+ shelly.logout(File.read(rsa_key)) if File.exists?(rsa_key)
57
58
  end
58
59
 
59
60
  def ssh_key_exists?
@@ -61,6 +62,15 @@ module Shelly
61
62
  end
62
63
 
63
64
  def ssh_key_path
65
+ return dsa_key if File.exists?(dsa_key)
66
+ rsa_key
67
+ end
68
+
69
+ def dsa_key
70
+ File.expand_path("~/.ssh/id_dsa.pub")
71
+ end
72
+
73
+ def rsa_key
64
74
  File.expand_path("~/.ssh/id_rsa.pub")
65
75
  end
66
76
 
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.1.33"
2
+ VERSION = "0.1.34.pre"
3
3
  end
@@ -3,7 +3,8 @@ require "spec_helper"
3
3
  describe Shelly::User do
4
4
  before do
5
5
  FileUtils.mkdir_p("~/.ssh")
6
- File.open("~/.ssh/id_rsa.pub", "w") { |f| f << "ssh-key AAbbcc" }
6
+ File.open("~/.ssh/id_rsa.pub", "w") { |f| f << "rsa-key AAbbcc" }
7
+ File.open("~/.ssh/id_dsa.pub", "w") { |f| f << "dsa-key AAbbcc" }
7
8
  @client = mock
8
9
  Shelly::Client.stub(:new).and_return(@client)
9
10
  @user = Shelly::User.new("bob@example.com", "secret")
@@ -24,7 +25,7 @@ describe Shelly::User do
24
25
  end
25
26
 
26
27
  it "should register user at Shelly Cloud" do
27
- @client.should_receive(:register_user).with("bob@example.com", "secret", "ssh-key AAbbcc")
28
+ @client.should_receive(:register_user).with("bob@example.com", "secret", "dsa-key AAbbcc")
28
29
  @user.register
29
30
  end
30
31
 
@@ -36,6 +37,7 @@ describe Shelly::User do
36
37
  context "when ssh key is not available" do
37
38
  it "should register without it" do
38
39
  FileUtils.rm_rf("~/.ssh/id_rsa.pub")
40
+ FileUtils.rm_rf("~/.ssh/id_dsa.pub")
39
41
  @client.should_receive(:register_user).with("bob@example.com", "secret", nil)
40
42
  @user.register
41
43
  end
@@ -117,7 +119,12 @@ describe Shelly::User do
117
119
  end
118
120
 
119
121
  describe "#ssh_key_path" do
120
- it "should return path to public ssh key file" do
122
+ it "should return path to public dsa key file in the first place" do
123
+ @user.ssh_key_path.should == File.expand_path("~/.ssh/id_dsa.pub")
124
+ end
125
+
126
+ it "should return path to public rsa key file if dsa key is not present" do
127
+ FileUtils.rm_rf("~/.ssh/id_dsa.pub")
121
128
  @user.ssh_key_path.should == File.expand_path("~/.ssh/id_rsa.pub")
122
129
  end
123
130
  end
@@ -126,18 +133,22 @@ describe Shelly::User do
126
133
  it "should return true if key exists, false otherwise" do
127
134
  @user.should be_ssh_key_exists
128
135
  FileUtils.rm_rf("~/.ssh/id_rsa.pub")
136
+ @user.should be_ssh_key_exists
137
+ FileUtils.rm_rf("~/.ssh/id_dsa.pub")
129
138
  @user.should_not be_ssh_key_exists
130
139
  end
131
140
  end
132
141
 
133
142
  describe "#delete_ssh_key" do
134
143
  it "should invoke logout when ssh key exists" do
135
- @client.should_receive(:logout).with('ssh-key AAbbcc')
144
+ @client.should_receive(:logout).with('rsa-key AAbbcc')
145
+ @client.should_receive(:logout).with('dsa-key AAbbcc')
136
146
  @user.delete_ssh_key
137
147
  end
138
148
 
139
149
  it "should not invoke logout when ssh key doesn't exist" do
140
150
  FileUtils.rm_rf("~/.ssh/id_rsa.pub")
151
+ FileUtils.rm_rf("~/.ssh/id_dsa.pub")
141
152
  @client.should_not_receive(:logout)
142
153
  @user.delete_ssh_key
143
154
  end
@@ -145,7 +156,7 @@ describe Shelly::User do
145
156
 
146
157
  describe "#upload_ssh_key" do
147
158
  it "should read and upload user's public SSH key" do
148
- @client.should_receive(:add_ssh_key).with("ssh-key AAbbcc")
159
+ @client.should_receive(:add_ssh_key).with("dsa-key AAbbcc")
149
160
  @user.upload_ssh_key
150
161
  end
151
162
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.33
5
- prerelease:
4
+ version: 0.1.34.pre
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shelly Cloud team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-30 00:00:00.000000000 Z
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -343,18 +343,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
343
  - - ! '>='
344
344
  - !ruby/object:Gem::Version
345
345
  version: '0'
346
- segments:
347
- - 0
348
- hash: 3939130509060040795
349
346
  required_rubygems_version: !ruby/object:Gem::Requirement
350
347
  none: false
351
348
  requirements:
352
- - - ! '>='
349
+ - - ! '>'
353
350
  - !ruby/object:Gem::Version
354
- version: '0'
355
- segments:
356
- - 0
357
- hash: 3939130509060040795
351
+ version: 1.3.1
358
352
  requirements: []
359
353
  rubyforge_project: shelly
360
354
  rubygems_version: 1.8.24