|
134 | 134 | end
|
135 | 135 | end
|
136 | 136 | context "that was accepted" do
|
137 |
| - it "should add an SSLv2 cipher result to the SSLv2 Accepted array" do |
| 137 | + it "should add an SSLv2 cipher result to the SSLv2 Accepted array or generate an SSLv2 exception" do |
138 | 138 | begin
|
139 | 139 | subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
|
140 | 140 | subject.accepted(:SSLv2).should include({
|
|
144 | 144 | :weak=> false,
|
145 | 145 | :status => :accepted})
|
146 | 146 | rescue ArgumentError => e
|
147 |
| - e.message.should == "unknown SSL method `SSLv2'" |
| 147 | + e.message.should == "unknown SSL method `SSLv2'." |
148 | 148 | end
|
149 | 149 | end
|
150 | 150 |
|
|
192 | 192 | end
|
193 | 193 | end
|
194 | 194 | context "that was rejected" do
|
195 |
| - it "should add an SSLv2 cipher result to the SSLv2 Rejected array" do |
196 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected) |
197 |
| - subject.rejected(:SSLv2).should include({ |
198 |
| - :version => :SSLv2, |
199 |
| - :cipher=>"DES-CBC3-MD5", |
200 |
| - :key_length=>168, |
201 |
| - :weak=> false, |
202 |
| - :status => :rejected}) |
| 195 | + it "should add an SSLv2 cipher result to the SSLv2 Rejected array or generate an SSLv2 exception" do |
| 196 | + begin |
| 197 | + subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected) |
| 198 | + subject.rejected(:SSLv2).should include({ |
| 199 | + :version => :SSLv2, |
| 200 | + :cipher=>"DES-CBC3-MD5", |
| 201 | + :key_length=>168, |
| 202 | + :weak=> false, |
| 203 | + :status => :rejected}) |
| 204 | + rescue ArgumentError => e |
| 205 | + e.message.should == "unknown SSL method `SSLv2'." |
| 206 | + end |
203 | 207 | end
|
204 | 208 |
|
205 | 209 | it "should add an SSLv3 cipher result to the SSLv3 Rejected array" do
|
|
249 | 253 |
|
250 | 254 | context "enumerating all accepted ciphers" do
|
251 | 255 | before(:each) do
|
252 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
253 | 256 | subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
|
254 | 257 | subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
|
255 | 258 | subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
|
|
267 | 270 | subject.each_accepted do |cipher_details|
|
268 | 271 | count = count+1
|
269 | 272 | end
|
270 |
| - count.should == 4 |
| 273 | + count.should == 3 |
271 | 274 | end
|
272 | 275 | end
|
273 | 276 |
|
|
281 | 284 | end
|
282 | 285 |
|
283 | 286 | it "should return only ciphers matching the version" do
|
284 |
| - subject.each_accepted(:SSLv2) do |cipher_details| |
285 |
| - cipher_details[:version].should == :SSLv2 |
| 287 | + subject.each_accepted(:SSLv3) do |cipher_details| |
| 288 | + cipher_details[:version].should == :SSLv3 |
286 | 289 | end
|
287 | 290 | end
|
288 | 291 | end
|
|
293 | 296 | subject.each_accepted([:TLSv3, :TLSv4]) do |cipher_details|
|
294 | 297 | count = count+1
|
295 | 298 | end
|
296 |
| - count.should == 4 |
| 299 | + count.should == 3 |
297 | 300 | end
|
298 | 301 |
|
299 | 302 | it "should return only the ciphers for the specified version" do
|
|
306 | 309 |
|
307 | 310 | context "enumerating all rejected ciphers" do
|
308 | 311 | before(:each) do
|
309 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected) |
310 | 312 | subject.add_cipher(:SSLv3, "AES256-SHA", 256, :rejected)
|
311 | 313 | subject.add_cipher(:TLSv1, "AES256-SHA", 256, :rejected)
|
312 | 314 | subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected)
|
|
324 | 326 | subject.each_rejected do |cipher_details|
|
325 | 327 | count = count+1
|
326 | 328 | end
|
327 |
| - count.should == 4 |
| 329 | + count.should == 3 |
328 | 330 | end
|
329 | 331 | end
|
330 | 332 |
|
|
338 | 340 | end
|
339 | 341 |
|
340 | 342 | it "should return only ciphers matching the version" do
|
341 |
| - subject.each_rejected(:SSLv2) do |cipher_details| |
342 |
| - cipher_details[:version].should == :SSLv2 |
| 343 | + subject.each_rejected(:SSLv3) do |cipher_details| |
| 344 | + cipher_details[:version].should == :SSLv3 |
343 | 345 | end
|
344 | 346 | end
|
345 | 347 | end
|
|
350 | 352 | subject.each_rejected([:TLSv3, :TLSv4]) do |cipher_details|
|
351 | 353 | count = count+1
|
352 | 354 | end
|
353 |
| - count.should == 4 |
| 355 | + count.should == 3 |
354 | 356 | end
|
355 | 357 |
|
356 | 358 | it "should return only the ciphers for the specified version" do
|
|
366 | 368 | it "should return false if there are no accepted ciphers" do
|
367 | 369 | subject.supports_sslv2?.should == false
|
368 | 370 | end
|
369 |
| - it "should return true if there are accepted ciphers" do |
370 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
371 |
| - subject.supports_sslv2?.should == true |
| 371 | + it "should return true if there are accepted ciphers or raise an SSLv2 exception" do |
| 372 | + begin |
| 373 | + subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
| 374 | + subject.supports_sslv2?.should == true |
| 375 | + rescue ArgumentError => e |
| 376 | + e.message.should == "unknown SSL method `SSLv2'." |
| 377 | + end |
372 | 378 | end
|
373 | 379 | end
|
374 | 380 | context "for SSLv3" do
|
|
403 | 409 | context "checking for weak ciphers" do
|
404 | 410 | context "when weak ciphers are supported" do
|
405 | 411 | before(:each) do
|
406 |
| - subject.add_cipher(:SSLv2, "DES-CBC-MD5", 56, :accepted) |
407 |
| - subject.add_cipher(:SSLv2, "EXP-RC2-CBC-MD5", 40, :accepted) |
| 412 | + subject.add_cipher(:SSLv3, "EXP-RC4-MD5", 40, :accepted) |
| 413 | + subject.add_cipher(:SSLv3, "DES-CBC-SHA", 56, :accepted) |
408 | 414 | end
|
409 | 415 | it "should return an array of weak ciphers from #weak_ciphers" do
|
410 | 416 | weak = subject.weak_ciphers
|
|
422 | 428 |
|
423 | 429 | context "when no weak ciphers are supported" do
|
424 | 430 | before(:each) do
|
425 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
426 | 431 | subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
|
427 | 432 | subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
|
428 | 433 | subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
|
|
442 | 447 | subject.standards_compliant?.should == true
|
443 | 448 | end
|
444 | 449 |
|
445 |
| - it "should return false if SSLv2 is supported" do |
446 |
| - subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
447 |
| - subject.standards_compliant?.should == false |
| 450 | + it "should return false if SSLv2 is supported or raise an SSLv2 exception" do |
| 451 | + begin |
| 452 | + subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) |
| 453 | + subject.standards_compliant?.should == false |
| 454 | + rescue ArgumentError => e |
| 455 | + e.message.should == "unknown SSL method `SSLv2'." |
| 456 | + end |
448 | 457 | end
|
449 | 458 |
|
450 | 459 | it "should return false if weak ciphers are supported" do
|
|
0 commit comments