spec/cert_spec.rb in r509-0.9.2 vs spec/cert_spec.rb in r509-0.10.0
- old
+ new
@@ -95,15 +95,15 @@
cert = R509::Cert.new(:cert => @cert)
cert.signature_algorithm.should == 'sha1WithRSAEncryption'
end
it "returns the RSA key algorithm" do
cert = R509::Cert.new(:cert => @cert)
- cert.key_algorithm.should == :rsa
+ cert.key_algorithm.should == "RSA"
end
it "returns the DSA key algorithm" do
cert = R509::Cert.new(:cert => @cert6)
- cert.key_algorithm.should == :dsa
+ cert.key_algorithm.should == "DSA"
end
it "returns list of san names when it is a san cert" do
cert = R509::Cert.new(:cert => @cert_san)
cert.san.dns_names.should == ['langui.sh']
end
@@ -143,11 +143,11 @@
it "writes to pem" do
cert = R509::Cert.new(:cert => @cert)
sio = StringIO.new
sio.set_encoding("BINARY") if sio.respond_to?(:set_encoding)
cert.write_pem(sio)
- sio.string.should == @cert + "\n"
+ sio.string.should == @cert
end
it "writes to der" do
cert = R509::Cert.new(:cert => @cert)
sio = StringIO.new
sio.set_encoding("BINARY") if sio.respond_to?(:set_encoding)
@@ -267,11 +267,11 @@
cert = R509::Cert.new(:cert => @cert)
cert.bit_strength.should == 2048
end
it "returns an error for curve_name for DSA/RSA" do
cert = R509::Cert.new(:cert => @cert)
- expect { cert.curve_name }.to raise_error(R509::R509Error, 'Curve name is only available with EC certs')
+ expect { cert.curve_name }.to raise_error(R509::R509Error, 'Curve name is only available with EC')
end
it "checks dsa?" do
cert = R509::Cert.new(:cert => @cert6)
cert.rsa?.should == false
cert.ec?.should == false
@@ -310,16 +310,18 @@
end
it "is revoked by crl" do
cert = R509::Cert.new(:cert => @cert3)
crl_admin = R509::CRL::Administrator.new(TestFixtures.test_ca_config)
crl_admin.revoke_cert(1425751142578902223005775172931960716533532010870)
- cert.is_revoked_by_crl?(crl_admin.crl).should == true
+ crl = crl_admin.generate_crl
+ cert.is_revoked_by_crl?(crl).should == true
end
it "is not revoked by crl" do
cert = R509::Cert.new(:cert => @cert3)
crl_admin = R509::CRL::Administrator.new(TestFixtures.test_ca_config)
- cert.is_revoked_by_crl?(crl_admin.crl).should == false
+ crl = crl_admin.generate_crl
+ cert.is_revoked_by_crl?(crl).should == false
end
it "loads a cert with load_from_file" do
path = File.dirname(__FILE__) + '/fixtures/cert1.pem'
cert = R509::Cert.load_from_file path
cert.serial.to_i.should == 211653423715
@@ -348,11 +350,11 @@
cert.write_pkcs12(sio,'r509_password')
expect { R509::Cert.new(:pkcs12 => sio.string, :password => 'r509_password') }.to_not raise_error
end
it "raises error on bit strength" do
cert = R509::Cert.new(:cert => @cert_ec)
- expect { cert.bit_strength }.to raise_error(R509::R509Error,'Bit strength is not available for EC at this time.')
+ expect { cert.bit_strength }.to raise_error(R509::R509Error,'Bit length is not available for EC at this time.')
end
it "returns curve name" do
cert = R509::Cert.new(:cert => @cert_ec)
cert.curve_name.should == 'secp384r1'
end
@@ -367,11 +369,11 @@
private_key = R509::PrivateKey.new(:key => @key_ec)
cert.public_key.to_der.should == private_key.public_key.to_der
end
it "returns the key algorithm" do
cert = R509::Cert.new(:cert => @cert_ec)
- cert.key_algorithm.should == :ec
+ cert.key_algorithm.should == "EC"
end
end
context "when elliptic curve support is unavailable" do
before :all do
@@ -388,9 +390,9 @@
cert.ec?.should == false
cert.dsa?.should == false
end
it "returns RSA key algorithm for RSA CSR" do
cert = R509::Cert.new(:cert => @cert)
- cert.key_algorithm.should == :rsa
+ cert.key_algorithm.should == "RSA"
end
end
end