Skip to content

Commit 4c9b59c

Browse files
authored
Merge pull request #15 from prahal/remove-abandoned-forgery
Switch ssh unit tests from abandonware forgery gem to Faker gem
2 parents a145adc + 51dc796 commit 4c9b59c

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ gemspec
66

77
# Dev libs
88
gem 'faker'
9-
gem 'forgery'
109
gem 'pry'
1110
gem 'rake'
1211
gem 'rspec'

spec/spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'simplecov'
2-
require 'forgery'
32
require 'rspec'
43
require 'faker'
54
require 'support/helper'

spec/unit_tests/ssh_key_spec.rb

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
describe '#new' do
9999
it 'should create a valid ssh key' do
100100
type = "ssh-rsa"
101-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
102-
email = Forgery::Internet.email_address
101+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
102+
email = Faker::Internet.email
103103

104104
s = Gitolite::SSHKey.new(type, blob, email)
105105

@@ -109,9 +109,9 @@
109109

110110
it 'should create a valid ssh key while specifying an owner' do
111111
type = "ssh-rsa"
112-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
113-
email = Forgery::Internet.email_address
114-
owner = Forgery::Name.first_name
112+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
113+
email = Faker::Internet.email
114+
owner = Faker::Name.first_name
115115

116116
s = Gitolite::SSHKey.new(type, blob, email, owner)
117117

@@ -121,10 +121,10 @@
121121

122122
it 'should create a valid ssh key while specifying an owner and location' do
123123
type = "ssh-rsa"
124-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
125-
email = Forgery::Internet.email_address
126-
owner = Forgery::Name.first_name
127-
location = Forgery::Name.location
124+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
125+
email = Faker::Internet.email
126+
owner = Faker::Name.first_name
127+
location = Faker::Company.name
128128

129129
s = Gitolite::SSHKey.new(type, blob, email, owner, location)
130130

@@ -138,10 +138,10 @@
138138
describe '#hash' do
139139
it 'should have two hash equalling one another' do
140140
type = "ssh-rsa"
141-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
142-
email = Forgery::Internet.email_address
143-
owner = Forgery::Name.first_name
144-
location = Forgery::Name.location
141+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
142+
email = Faker::Internet.email
143+
owner = Faker::Name.first_name
144+
location = Faker::Company.name
145145

146146
hash_test = [owner, location, type, blob, email].hash
147147
s = Gitolite::SSHKey.new(type, blob, email, owner, location)
@@ -154,8 +154,8 @@
154154
describe '#filename' do
155155
it 'should create a filename that is the <email>.pub' do
156156
type = "ssh-rsa"
157-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
158-
email = Forgery::Internet.email_address
157+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
158+
email = Faker::Internet.email
159159

160160
s = Gitolite::SSHKey.new(type, blob, email)
161161

@@ -164,9 +164,9 @@
164164

165165
it 'should create a filename that is the <owner>.pub' do
166166
type = "ssh-rsa"
167-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
168-
email = Forgery::Internet.email_address
169-
owner = Forgery::Name.first_name
167+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
168+
email = Faker::Internet.email
169+
owner = Faker::Name.first_name
170170

171171
s = Gitolite::SSHKey.new(type, blob, email, owner)
172172

@@ -175,9 +175,9 @@
175175

176176
it 'should create a filename that is the <email>.pub' do
177177
type = "ssh-rsa"
178-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
179-
email = Forgery::Internet.email_address
180-
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
178+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
179+
email = Faker::Internet.email
180+
location = Faker::Internet.password(:min_length => 8, :max_length => 15)
181181

182182
s = Gitolite::SSHKey.new(type, blob, email, nil, location)
183183

@@ -187,10 +187,10 @@
187187

188188
it 'should create a filename that is the <owner>@<location>.pub' do
189189
type = "ssh-rsa"
190-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
191-
email = Forgery::Internet.email_address
192-
owner = Forgery::Name.first_name
193-
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
190+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
191+
email = Faker::Internet.email
192+
owner = Faker::Name.first_name
193+
location = Faker::Internet.password(:min_length => 8, :max_length => 15)
194194

195195
s = Gitolite::SSHKey.new(type, blob, email, owner, location)
196196

@@ -202,10 +202,10 @@
202202
describe '#to_file' do
203203
it 'should write a "valid" SSH public key to the file system' do
204204
type = "ssh-rsa"
205-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
206-
email = Forgery::Internet.email_address
207-
owner = Forgery::Name.first_name
208-
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
205+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
206+
email = Faker::Internet.email
207+
owner = Faker::Name.first_name
208+
location = Faker::Internet.password(:min_length => 8, :max_length => 15)
209209

210210
s = Gitolite::SSHKey.new(type, blob, email, owner, location)
211211

@@ -218,10 +218,10 @@
218218

219219
it 'should return the filename written' do
220220
type = "ssh-rsa"
221-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
222-
email = Forgery::Internet.email_address
223-
owner = Forgery::Name.first_name
224-
location = Forgery::Basic.text(:at_least => 8, :at_most => 15)
221+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
222+
email = Faker::Internet.email
223+
owner = Faker::Name.first_name
224+
location = Faker::Internet.password(:min_length => 8, :max_length => 15)
225225

226226
s = Gitolite::SSHKey.new(type, blob, email, owner, location)
227227
expect(s.to_file(output_dir)).to eq File.join(output_dir, owner, location, s.filename)
@@ -232,8 +232,8 @@
232232
describe '==' do
233233
it 'should have two keys equalling one another' do
234234
type = "ssh-rsa"
235-
blob = Forgery::Basic.text(:at_least => 372, :at_most => 372)
236-
email = Forgery::Internet.email_address
235+
blob = Faker::Internet.password(:min_length => 372, :max_length => 372)
236+
email = Faker::Internet.email
237237

238238
s1 = Gitolite::SSHKey.new(type, blob, email)
239239
s2 = Gitolite::SSHKey.new(type, blob, email)

0 commit comments

Comments
 (0)