gitolite-rugged 1.2.pre.devel

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/.gitignore +9 -0
  4. data/.travis.yml +14 -0
  5. data/Gemfile +5 -0
  6. data/Guardfile +13 -0
  7. data/LICENSE.txt +26 -0
  8. data/README.md +108 -0
  9. data/Rakefile +59 -0
  10. data/gitolite.gemspec +36 -0
  11. data/lib/gitolite/config/group.rb +62 -0
  12. data/lib/gitolite/config/repo.rb +107 -0
  13. data/lib/gitolite/config.rb +284 -0
  14. data/lib/gitolite/dirty_proxy.rb +32 -0
  15. data/lib/gitolite/gitolite_admin.rb +276 -0
  16. data/lib/gitolite/ssh_key.rb +103 -0
  17. data/lib/gitolite/version.rb +3 -0
  18. data/lib/gitolite.rb +10 -0
  19. data/spec/config_spec.rb +498 -0
  20. data/spec/dirty_proxy_spec.rb +66 -0
  21. data/spec/fixtures/configs/complicated-output.conf +72 -0
  22. data/spec/fixtures/configs/complicated.conf +311 -0
  23. data/spec/fixtures/configs/simple.conf +5 -0
  24. data/spec/fixtures/keys/bob+joe@test.zilla.com@desktop.pub +1 -0
  25. data/spec/fixtures/keys/bob-ins@zilla-site.com@desktop.pub +1 -0
  26. data/spec/fixtures/keys/bob.joe@test.zilla.com@desktop.pub +1 -0
  27. data/spec/fixtures/keys/bob.pub +1 -0
  28. data/spec/fixtures/keys/bob@desktop.pub +1 -0
  29. data/spec/fixtures/keys/bob@foo-bar.pub +1 -0
  30. data/spec/fixtures/keys/bob@zilla.com.pub +1 -0
  31. data/spec/fixtures/keys/bob@zilla.com@desktop.pub +1 -0
  32. data/spec/fixtures/keys/jakub123.pub +1 -0
  33. data/spec/fixtures/keys/jakub123@foo.net.pub +1 -0
  34. data/spec/fixtures/keys/joe-bob@god-zilla.com@desktop.pub +1 -0
  35. data/spec/fixtures/keys/joe@sch.ool.edu.pub +1 -0
  36. data/spec/fixtures/keys/joe@sch.ool.edu@desktop.pub +1 -0
  37. data/spec/gitolite_admin_spec.rb +40 -0
  38. data/spec/group_spec.rb +125 -0
  39. data/spec/repo_spec.rb +202 -0
  40. data/spec/spec_helper.rb +21 -0
  41. data/spec/ssh_key_spec.rb +355 -0
  42. metadata +280 -0
data/spec/repo_spec.rb ADDED
@@ -0,0 +1,202 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitolite::Config::Repo do
4
+ before(:each) do
5
+ @repo = Gitolite::Config::Repo.new("CoolRepo")
6
+ end
7
+
8
+ describe '#new' do
9
+ it 'should create a repo called "CoolRepo"' do
10
+ @repo.name.should == "CoolRepo"
11
+ end
12
+ end
13
+
14
+ describe "deny rules" do
15
+ it 'should maintain the order of rules for a repository' do
16
+ @repo.add_permission("RW+", "", "bob", "joe", "sam")
17
+ @repo.add_permission("R", "", "sue", "jen", "greg")
18
+ @repo.add_permission("-", "refs/tags/test[0-9]", "@students", "jessica")
19
+ @repo.add_permission("RW", "refs/tags/test[0-9]", "@teachers", "bill", "todd")
20
+ @repo.add_permission("R", "refs/tags/test[0-9]", "@profs")
21
+
22
+ @repo.permissions.length.should == 2
23
+ @repo.permissions[0].size.should == 2
24
+ @repo.permissions[1].size.should == 3
25
+ end
26
+ end
27
+
28
+ describe '#add_permission' do
29
+ it 'should allow adding a permission to the permissions list' do
30
+ @repo.add_permission("RW+")
31
+ @repo.permissions.length.should == 1
32
+ @repo.permissions.first.keys.first.should == "RW+"
33
+ end
34
+
35
+ it 'should allow adding a permission while specifying a refex' do
36
+ @repo.add_permission("RW+", "refs/heads/master")
37
+ @repo.permissions.length.should == 1
38
+ @repo.permissions.first.keys.first.should == "RW+"
39
+ @repo.permissions.first.values.last.first.first.should == "refs/heads/master"
40
+ end
41
+
42
+ it 'should allow specifying users individually' do
43
+ @repo.add_permission("RW+", "", "bob", "joe", "susan", "sam", "bill")
44
+ @repo.permissions.first["RW+"][""].should == %w[bob joe susan sam bill]
45
+ end
46
+
47
+ it 'should allow specifying users as an array' do
48
+ users = %w[bob joe susan sam bill]
49
+
50
+ @repo.add_permission("RW+", "", users)
51
+ @repo.permissions.first["RW+"][""].should == users
52
+ end
53
+
54
+ it 'should not allow adding an invalid permission via an InvalidPermissionError' do
55
+ expect {@repo.add_permission("BadPerm")}.to raise_error
56
+ end
57
+ end
58
+
59
+ describe "permissions" do
60
+ before(:each) do
61
+ @repo = Gitolite::Config::Repo.new("CoolRepo")
62
+ end
63
+
64
+ it 'should allow adding the permission C' do
65
+ @repo.add_permission("C", "", "bob")
66
+ end
67
+
68
+ it 'should allow adding the permission -' do
69
+ @repo.add_permission("-", "", "bob")
70
+ end
71
+
72
+ it 'should allow adding the permission R' do
73
+ @repo.add_permission("R", "", "bob")
74
+ end
75
+
76
+ it 'should allow adding the permission RM' do
77
+ @repo.add_permission("RM", "", "bob")
78
+ end
79
+
80
+ it 'should allow adding the permission RW' do
81
+ @repo.add_permission("RW", "", "bob")
82
+ end
83
+
84
+ it 'should allow adding the permission RWM' do
85
+ @repo.add_permission("RWM", "", "bob")
86
+ end
87
+
88
+ it 'should allow adding the permission RW+' do
89
+ @repo.add_permission("RW+", "", "bob")
90
+ end
91
+
92
+ it 'should allow adding the permission RW+M' do
93
+ @repo.add_permission("RW+M", "", "bob")
94
+ end
95
+
96
+ it 'should allow adding the permission RWC' do
97
+ @repo.add_permission("RWC", "", "bob")
98
+ end
99
+
100
+ it 'should allow adding the permission RWCM' do
101
+ @repo.add_permission("RWCM", "", "bob")
102
+ end
103
+
104
+ it 'should allow adding the permission RW+C' do
105
+ @repo.add_permission("RW+C", "", "bob")
106
+ end
107
+
108
+ it 'should allow adding the permission RW+CM' do
109
+ @repo.add_permission("RW+CM", "", "bob")
110
+ end
111
+
112
+ it 'should allow adding the permission RWD' do
113
+ @repo.add_permission("RWD", "", "bob")
114
+ end
115
+
116
+ it 'should allow adding the permission RWDM' do
117
+ @repo.add_permission("RWDM", "", "bob")
118
+ end
119
+
120
+ it 'should allow adding the permission RW+D' do
121
+ @repo.add_permission("RW+D", "", "bob")
122
+ end
123
+
124
+ it 'should allow adding the permission RW+DM' do
125
+ @repo.add_permission("RW+DM", "", "bob")
126
+ end
127
+
128
+ it 'should allow adding the permission RWCD' do
129
+ @repo.add_permission("RWCD", "", "bob")
130
+ end
131
+
132
+ it 'should allow adding the permission RWCDM' do
133
+ @repo.add_permission("RWCDM", "", "bob")
134
+ end
135
+
136
+ it 'should allow adding the permission RW+CD' do
137
+ @repo.add_permission("RW+CD", "", "bob")
138
+ end
139
+
140
+ it 'should allow adding the permission RW+CDM' do
141
+ @repo.add_permission("RW+CDM", "", "bob")
142
+ end
143
+ end
144
+
145
+ describe 'git config options' do
146
+ it 'should allow setting a git configuration option' do
147
+ email = "bob@zilla.com"
148
+ @repo.set_git_config("email", email).should == email
149
+ end
150
+
151
+ it 'should allow deletion of an existing git configuration option' do
152
+ email = "bob@zilla.com"
153
+ @repo.set_git_config("email", email)
154
+ @repo.unset_git_config("email").should == email
155
+ end
156
+
157
+ end
158
+
159
+ describe 'gitolite options' do
160
+ it 'should allow setting a gitolite option' do
161
+ master = "kenobi"
162
+ slaves = "one"
163
+ @repo.set_gitolite_option("mirror.master", master).should == master
164
+ @repo.set_gitolite_option("mirror.slaves", slaves).should == slaves
165
+ @repo.options.length.should == 2
166
+ end
167
+
168
+ it 'should allow deletion of an existing gitolite option' do
169
+ master = "kenobi"
170
+ slaves = "one"
171
+ @repo.set_gitolite_option("mirror.master", master)
172
+ @repo.set_gitolite_option("mirror.slaves", slaves)
173
+ @repo.options.length.should == 2
174
+ @repo.unset_gitolite_option("mirror.master").should == master
175
+ @repo.options.length.should == 1
176
+ end
177
+ end
178
+
179
+ describe 'permission management' do
180
+ it 'should combine two entries for the same permission and refex' do
181
+ users = %w[bob joe susan sam bill]
182
+ more_users = %w[sally peyton andrew erin]
183
+
184
+ @repo.add_permission("RW+", "", users)
185
+ @repo.add_permission("RW+", "", more_users)
186
+ @repo.permissions.first["RW+"][""].should == users.concat(more_users)
187
+ @repo.permissions.first["RW+"][""].length.should == 9
188
+ end
189
+
190
+ it 'should not list the same users twice for the same permission level' do
191
+ users = %w[bob joe susan sam bill]
192
+ more_users = %w[bob peyton andrew erin]
193
+ even_more_users = %w[bob jim wayne courtney]
194
+
195
+ @repo.add_permission("RW+", "", users)
196
+ @repo.add_permission("RW+", "", more_users)
197
+ @repo.add_permission("RW+", "", even_more_users)
198
+ @repo.permissions.first["RW+"][""].should == users.concat(more_users).concat(even_more_users).uniq!
199
+ @repo.permissions.first["RW+"][""].length.should == 11
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ require 'forgery'
4
+
5
+ require 'simplecov'
6
+ require 'simplecov-rcov'
7
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
8
+ SimpleCov.start
9
+
10
+ Spork.prefork do
11
+ # Loading more in this block will cause your tests to run faster. However,
12
+ # if you change any configuration or code from libraries loaded here, you'll
13
+ # need to restart spork for it take effect.
14
+
15
+ end
16
+
17
+ Spork.each_run do
18
+ # This code will be run each time you run your specs.
19
+ require File.expand_path('../../lib/gitolite', __FILE__)
20
+ include Gitolite
21
+ end
@@ -0,0 +1,355 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitolite::SSHKey do
4
+
5
+ key_dir = File.join(File.dirname(__FILE__), 'fixtures', 'keys')
6
+ output_dir = '/tmp'
7
+ # output_dir = File.join(File.dirname(File.dirname(__FILE__)), 'tmp')
8
+
9
+ describe "#from_string" do
10
+ it 'should construct an SSH key from a string' do
11
+ key = File.join(key_dir, 'bob.pub')
12
+ key_string = File.read(key)
13
+ s = SSHKey.from_string(key_string, "bob")
14
+
15
+ s.owner.should == 'bob'
16
+ s.location.should == ""
17
+ s.blob.should == key_string.split[1]
18
+ end
19
+
20
+ it 'should raise an ArgumentError when an owner isnt specified' do
21
+ key_string = "not_a_real_key"
22
+ lambda { SSHKey.from_string(key_string) }.should raise_error
23
+ end
24
+
25
+ it 'should have a location when one is specified' do
26
+ key = File.join(key_dir, 'bob.pub')
27
+ key_string = File.read(key)
28
+ s = SSHKey.from_string(key_string, "bob", "kansas")
29
+
30
+ s.owner.should == 'bob'
31
+ s.location.should == "kansas"
32
+ s.blob.should == key_string.split[1]
33
+ end
34
+
35
+ it 'should raise an ArgumentError when owner is nil' do
36
+ lambda { SSHKey.from_string("bad_string", nil) }.should raise_error
37
+ end
38
+
39
+ it 'should raise an ArgumentError when we get an invalid SSHKey string' do
40
+ lambda { SSHKey.from_string("bad_string", "bob") }.should raise_error
41
+ end
42
+ end
43
+
44
+ describe "#from_file" do
45
+ it 'should load a key from a file' do
46
+ key = File.join(key_dir, 'bob.pub')
47
+ s = SSHKey.from_file(key)
48
+ key_string = File.read(key).split
49
+
50
+ s.owner.should == "bob"
51
+ s.blob.should == key_string[1]
52
+ end
53
+
54
+ it 'should load a key with a location from a file' do
55
+ key = File.join(key_dir, 'bob@desktop.pub')
56
+ s = SSHKey.from_file(key)
57
+ s.owner.should == 'bob'
58
+ s.location.should == 'desktop'
59
+ end
60
+
61
+ it 'should load a key with owner and location from a file' do
62
+ key = File.join(key_dir, 'joe-bob@god-zilla.com@desktop.pub')
63
+ s = SSHKey.from_file(key)
64
+ s.owner.should == 'joe-bob@god-zilla.com'
65
+ s.location.should == 'desktop'
66
+ end
67
+ end
68
+
69
+ describe '#owner' do
70
+ it 'owner should be bob for bob.pub' do
71
+ key = File.join(key_dir, 'bob.pub')
72
+ s = SSHKey.from_file(key)
73
+ s.owner.should == 'bob'
74
+ end
75
+
76
+ it 'owner should be bob for bob@desktop.pub' do
77
+ key = File.join(key_dir, 'bob@desktop.pub')
78
+ s = SSHKey.from_file(key)
79
+ s.owner.should == 'bob'
80
+ end
81
+
82
+ it 'owner should be bob@zilla.com for bob@zilla.com.pub' do
83
+ key = File.join(key_dir, 'bob@zilla.com.pub')
84
+ s = SSHKey.from_file(key)
85
+ s.owner.should == 'bob@zilla.com'
86
+ end
87
+
88
+ it "owner should be joe-bob@god-zilla.com for joe-bob@god-zilla.com@desktop.pub" do
89
+ key = File.join(key_dir, 'joe-bob@god-zilla.com@desktop.pub')
90
+ s = SSHKey.from_file(key)
91
+ s.owner.should == 'joe-bob@god-zilla.com'
92
+ end
93
+
94
+ it "owner should be bob.joe@test.zilla.com for bob.joe@test.zilla.com@desktop.pub" do
95
+ key = File.join(key_dir, 'bob.joe@test.zilla.com@desktop.pub')
96
+ s = SSHKey.from_file(key)
97
+ s.owner.should == 'bob.joe@test.zilla.com'
98
+ end
99
+
100
+ it "owner should be bob+joe@test.zilla.com for bob+joe@test.zilla.com@desktop.pub" do
101
+ key = File.join(key_dir, 'bob+joe@test.zilla.com@desktop.pub')
102
+ s = SSHKey.from_file(key)
103
+ s.owner.should == 'bob+joe@test.zilla.com'
104
+ end
105
+
106
+ it 'owner should be bob@zilla.com for bob@zilla.com@desktop.pub' do
107
+ key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
108
+ s = SSHKey.from_file(key)
109
+ s.owner.should == 'bob@zilla.com'
110
+ end
111
+
112
+ it 'owner should be jakub123 for jakub123.pub' do
113
+ key = File.join(key_dir, 'jakub123.pub')
114
+ s = SSHKey.from_file(key)
115
+ s.owner.should == 'jakub123'
116
+ end
117
+
118
+ it 'owner should be jakub123@foo.net for jakub123@foo.net.pub' do
119
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
120
+ s = SSHKey.from_file(key)
121
+ s.owner.should == 'jakub123@foo.net'
122
+ end
123
+
124
+ it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu' do
125
+ key = File.join(key_dir, 'joe@sch.ool.edu.pub')
126
+ s = SSHKey.from_file(key)
127
+ s.owner.should == 'joe@sch.ool.edu'
128
+ end
129
+
130
+ it 'owner should be joe@sch.ool.edu for joe@sch.ool.edu@desktop.pub' do
131
+ key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
132
+ s = SSHKey.from_file(key)
133
+ s.owner.should == 'joe@sch.ool.edu'
134
+ end
135
+ end
136
+
137
+ describe '#location' do
138
+ it 'location should be "" for bob.pub' do
139
+ key = File.join(key_dir, 'bob.pub')
140
+ s = SSHKey.from_file(key)
141
+ s.location.should == ''
142
+ end
143
+
144
+ it 'location should be "desktop" for bob@desktop.pub' do
145
+ key = File.join(key_dir, 'bob@desktop.pub')
146
+ s = SSHKey.from_file(key)
147
+ s.location.should == 'desktop'
148
+ end
149
+
150
+ it 'location should be "" for bob@zilla.com.pub' do
151
+ key = File.join(key_dir, 'bob@zilla.com.pub')
152
+ s = SSHKey.from_file(key)
153
+ s.location.should == ''
154
+ end
155
+
156
+ it 'location should be "desktop" for bob@zilla.com@desktop.pub' do
157
+ key = File.join(key_dir, 'bob@zilla.com@desktop.pub')
158
+ s = SSHKey.from_file(key)
159
+ s.location.should == 'desktop'
160
+ end
161
+
162
+ it 'location should be "" for jakub123.pub' do
163
+ key = File.join(key_dir, 'jakub123.pub')
164
+ s = SSHKey.from_file(key)
165
+ s.location.should == ''
166
+ end
167
+
168
+ it 'location should be "" for jakub123@foo.net.pub' do
169
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
170
+ s = SSHKey.from_file(key)
171
+ s.location.should == ''
172
+ end
173
+
174
+ it 'location should be "" for joe@sch.ool.edu' do
175
+ key = File.join(key_dir, 'joe@sch.ool.edu.pub')
176
+ s = SSHKey.from_file(key)
177
+ s.location.should == ''
178
+ end
179
+
180
+ it 'location should be "desktop" for joe@sch.ool.edu@desktop.pub' do
181
+ key = File.join(key_dir, 'joe@sch.ool.edu@desktop.pub')
182
+ s = SSHKey.from_file(key)
183
+ s.location.should == 'desktop'
184
+ end
185
+
186
+ it 'location should be "foo-bar" for bob@foo-bar.pub' do
187
+ key = File.join(key_dir, 'bob@foo-bar.pub')
188
+ s = SSHKey.from_file(key)
189
+ s.location.should == 'foo-bar'
190
+ end
191
+ end
192
+
193
+ describe '#keys' do
194
+ it 'should load ssh key properly' do
195
+ key = File.join(key_dir, 'bob.pub')
196
+ s = SSHKey.from_file(key)
197
+ parts = File.read(key).split #should get type, blob, email
198
+
199
+ s.type.should == parts[0]
200
+ s.blob.should == parts[1]
201
+ s.email.should == parts[2]
202
+ end
203
+ end
204
+
205
+ describe '#email' do
206
+ it 'should use owner if email is missing' do
207
+ key = File.join(key_dir, 'jakub123@foo.net.pub')
208
+ s = SSHKey.from_file(key)
209
+ s.owner.should == s.email
210
+ end
211
+ end
212
+
213
+ describe '#new' do
214
+ it 'should create a valid ssh key' do
215
+ type = "ssh-rsa"
216
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
217
+ email = Forgery::Internet.email_address
218
+
219
+ s = SSHKey.new(type, blob, email)
220
+
221
+ s.to_s.should == [type, blob, email].join(' ')
222
+ s.owner.should == email
223
+ end
224
+
225
+ it 'should create a valid ssh key while specifying an owner' do
226
+ type = "ssh-rsa"
227
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
228
+ email = Forgery::Internet.email_address
229
+ owner = Forgery::Name.first_name
230
+
231
+ s = SSHKey.new(type, blob, email, owner)
232
+
233
+ s.to_s.should == [type, blob, email].join(' ')
234
+ s.owner.should == owner
235
+ end
236
+
237
+ it 'should create a valid ssh key while specifying an owner and location' do
238
+ type = "ssh-rsa"
239
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
240
+ email = Forgery::Internet.email_address
241
+ owner = Forgery::Name.first_name
242
+ location = Forgery::Name.location
243
+
244
+ s = SSHKey.new(type, blob, email, owner, location)
245
+
246
+ s.to_s.should == [type, blob, email].join(' ')
247
+ s.owner.should == owner
248
+ s.location.should == location
249
+ end
250
+ end
251
+
252
+ describe '#hash' do
253
+ it 'should have two hash equalling one another' do
254
+ type = "ssh-rsa"
255
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
256
+ email = Forgery::Internet.email_address
257
+ owner = Forgery::Name.first_name
258
+ location = Forgery::Name.location
259
+
260
+ hash_test = [owner, location, type, blob, email].hash
261
+ s = SSHKey.new(type, blob, email, owner, location)
262
+
263
+ s.hash.should == hash_test
264
+ end
265
+ end
266
+
267
+ describe '#filename' do
268
+ it 'should create a filename that is the <email>.pub' do
269
+ type = "ssh-rsa"
270
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
271
+ email = Forgery::Internet.email_address
272
+
273
+ s = SSHKey.new(type, blob, email)
274
+
275
+ s.filename.should == "#{email}.pub"
276
+ end
277
+
278
+ it 'should create a filename that is the <owner>.pub' do
279
+ type = "ssh-rsa"
280
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
281
+ email = Forgery::Internet.email_address
282
+ owner = Forgery::Name.first_name
283
+
284
+ s = SSHKey.new(type, blob, email, owner)
285
+
286
+ s.filename.should == "#{owner}.pub"
287
+ end
288
+
289
+ it 'should create a filename that is the <email>@<location>.pub' do
290
+ type = "ssh-rsa"
291
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
292
+ email = Forgery::Internet.email_address
293
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
294
+
295
+ s = SSHKey.new(type, blob, email, nil, location)
296
+
297
+ s.filename.should == "#{email}@#{location}.pub"
298
+ end
299
+
300
+ it 'should create a filename that is the <owner>@<location>.pub' do
301
+ type = "ssh-rsa"
302
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
303
+ email = Forgery::Internet.email_address
304
+ owner = Forgery::Name.first_name
305
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
306
+
307
+ s = SSHKey.new(type, blob, email, owner, location)
308
+
309
+ s.filename.should == "#{owner}@#{location}.pub"
310
+ end
311
+ end
312
+
313
+ describe '#to_file' do
314
+ it 'should write a "valid" SSH public key to the file system' do
315
+ type = "ssh-rsa"
316
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
317
+ email = Forgery::Internet.email_address
318
+ owner = Forgery::Name.first_name
319
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
320
+
321
+ s = SSHKey.new(type, blob, email, owner, location)
322
+
323
+ ## write file
324
+ s.to_file(output_dir)
325
+
326
+ ## compare raw string with written file
327
+ s.to_s.should == File.read(File.join(output_dir, s.filename))
328
+ end
329
+
330
+ it 'should return the filename written' do
331
+ type = "ssh-rsa"
332
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
333
+ email = Forgery::Internet.email_address
334
+ owner = Forgery::Name.first_name
335
+ location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
336
+
337
+ s = SSHKey.new(type, blob, email, owner, location)
338
+
339
+ s.to_file(output_dir).should == File.join(output_dir, s.filename)
340
+ end
341
+ end
342
+
343
+ describe '==' do
344
+ it 'should have two keys equalling one another' do
345
+ type = "ssh-rsa"
346
+ blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
347
+ email = Forgery::Internet.email_address
348
+
349
+ s1 = SSHKey.new(type, blob, email)
350
+ s2 = SSHKey.new(type, blob, email)
351
+
352
+ s1.should == s2
353
+ end
354
+ end
355
+ end