1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Move spec/rubyspec to spec/ruby for consistency

* Other ruby implementations use the spec/ruby directory.
  [Misc #13792] [ruby-core:82287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-09-20 20:18:52 +00:00
parent 75bfc6440d
commit 1d15d5f080
4370 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,9 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::Cipher's CipherError" do
it "exists under OpenSSL::Cipher namespace" do
OpenSSL::Cipher.should have_constant :CipherError
end
end

View file

@ -0,0 +1,16 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::Config#freeze" do
it "needs to be reviewed for completeness"
it "freezes" do
c = OpenSSL::Config.new
lambda{c['foo'] = [ ['key', 'value'] ]}.should_not raise_error
c.freeze
c.frozen?.should be_true
lambda{c['foo'] = [ ['key', 'value'] ]}.should raise_error
end
end

View file

@ -0,0 +1,16 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::HMAC.digest" do
it "returns an SHA1 digest" do
cur_digest = OpenSSL::Digest::SHA1.new
cur_digest.digest.should == HMACConstants::BlankSHA1Digest
digest = OpenSSL::HMAC.digest(cur_digest,
HMACConstants::Key,
HMACConstants::Contents)
digest.should == HMACConstants::SHA1Digest
end
end
# Should add in similar specs for MD5, RIPEMD160, and SHA256

View file

@ -0,0 +1,16 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../shared/constants', __FILE__)
require 'openssl'
describe "OpenSSL::HMAC.hexdigest" do
it "returns an SHA1 hex digest" do
cur_digest = OpenSSL::Digest::SHA1.new
cur_digest.hexdigest.should == HMACConstants::BlankSHA1HexDigest
hexdigest = OpenSSL::HMAC.hexdigest(cur_digest,
HMACConstants::Key,
HMACConstants::Contents)
hexdigest.should == HMACConstants::SHA1Hexdigest
end
end
# Should add in similar specs for MD5, RIPEMD160, and SHA256

View file

@ -0,0 +1,8 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../shared/random_bytes.rb', __FILE__)
if defined?(OpenSSL::Random.pseudo_bytes)
describe "OpenSSL::Random.pseudo_bytes" do
it_behaves_like :openssl_random_bytes, :pseudo_bytes
end
end

View file

@ -0,0 +1,6 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../shared/random_bytes.rb', __FILE__)
describe "OpenSSL::Random.random_bytes" do
it_behaves_like :openssl_random_bytes, :random_bytes
end

View file

@ -0,0 +1,29 @@
require File.expand_path('../../../../../spec_helper', __FILE__)
require 'openssl'
describe :openssl_random_bytes, shared: true do |cmd|
it "generates a random binary string of specified length" do
(1..64).each do |idx|
bytes = OpenSSL::Random.send(@method, idx)
bytes.should be_kind_of(String)
bytes.length.should == idx
end
end
it "generates different binary strings with subsequent invocations" do
# quick and dirty check, but good enough
values = []
256.times do
val = OpenSSL::Random.send(@method, 16)
# make sure the random bytes are not repeating
values.include?(val).should == false
values << val
end
end
it "raises ArgumentError on negative arguments" do
lambda {
OpenSSL::Random.send(@method, -1)
}.should raise_error(ArgumentError)
end
end

View file

@ -0,0 +1,11 @@
# -*- encoding: binary -*-
module HMACConstants
Contents = "Ipsum is simply dummy text of the printing and typesetting industry. \nLorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \nIt has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \nIt was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
Key = 'sekrit'
BlankSHA1Digest = "\3329\243\356^kK\r2U\277\357\225`\030\220\257\330\a\t"
SHA1Digest = "\236\022\323\341\037\236\262n\344\t\372:\004J\242\330\257\270\363\264"
BlankSHA1HexDigest = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
SHA1Hexdigest = "9e12d3e11f9eb26ee409fa3a044aa2d8afb8f3b4"
end

View file

@ -0,0 +1,48 @@
require File.expand_path('../../../../../spec_helper', __FILE__)
require 'openssl'
describe "OpenSSL::X509::Name.parse" do
it "parses a /-delimited string of key-value pairs into a Name" do
dn = "/DC=org/DC=ruby-lang/CN=www.ruby-lang.org"
name = OpenSSL::X509::Name.parse(dn)
name.to_s.should == dn
ary = name.to_a
ary[0][0].should == "DC"
ary[1][0].should == "DC"
ary[2][0].should == "CN"
ary[0][1].should == "org"
ary[1][1].should == "ruby-lang"
ary[2][1].should == "www.ruby-lang.org"
ary[0][2].should == OpenSSL::ASN1::IA5STRING
ary[1][2].should == OpenSSL::ASN1::IA5STRING
ary[2][2].should == OpenSSL::ASN1::UTF8STRING
end
it "parses a comma-delimited string of key-value pairs into a name" do
dn = "DC=org, DC=ruby-lang, CN=www.ruby-lang.org"
name = OpenSSL::X509::Name.parse(dn)
name.to_s.should == "/DC=org/DC=ruby-lang/CN=www.ruby-lang.org"
ary = name.to_a
ary[0][1].should == "org"
ary[1][1].should == "ruby-lang"
ary[2][1].should == "www.ruby-lang.org"
end
it "raises TypeError if the given string contains no key/value pairs" do
lambda do
OpenSSL::X509::Name.parse("hello")
end.should raise_error(TypeError)
end
it "raises OpenSSL::X509::NameError if the given string contains invalid keys" do
lambda do
OpenSSL::X509::Name.parse("hello=goodbye")
end.should raise_error(OpenSSL::X509::NameError)
end
end