spec/private_key_spec.rb in r509-0.9.2 vs spec/private_key_spec.rb in r509-0.10.0

- old
+ new

@@ -32,52 +32,53 @@ private_key.dsa?.should == true end it "generates a default 2048-bit RSA key when nothing is passed to the constructor" do private_key = R509::PrivateKey.new private_key.rsa?.should == true + private_key.bit_length.should == 2048 private_key.bit_strength.should == 2048 end it "defaults to RSA" do - private_key = R509::PrivateKey.new(:bit_strength=>1024) + private_key = R509::PrivateKey.new(:bit_length=>1024) private_key.key.kind_of?(OpenSSL::PKey::RSA).should == true end it "loads a pre-existing RSA key" do private_key = R509::PrivateKey.new(:key=>@key_csr) private_key.to_pem.should == @key_csr @key_csr.should_not == nil end - it "generates an RSA key at the default bit strength (2048)" do - private_key = R509::PrivateKey.new(:type => :rsa) - private_key.bit_strength.should == 2048 + it "generates an RSA key at the default bit length (2048)" do + private_key = R509::PrivateKey.new(:type => "rsa") + private_key.bit_length.should == 2048 private_key.key.n.to_i.to_s(2).size.should == 2048 end - it "generates an RSA key at a custom bit strength" do - private_key = R509::PrivateKey.new(:type => :rsa, :bit_strength => 512) - private_key.bit_strength.should == 512 + it "generates an RSA key at a custom bit length" do + private_key = R509::PrivateKey.new(:type => "rsa", :bit_length => 512) + private_key.bit_length.should == 512 private_key.key.n.to_i.to_s(2).size.should == 512 end it "loads a pre-existing DSA key" do private_key = R509::PrivateKey.new(:key => @dsa_key) private_key.key.kind_of?(OpenSSL::PKey::DSA).should == true private_key.key.to_pem.should == @dsa_key @dsa_key.should_not == nil end - it "generates a DSA key at the default bit strength (2048)" do - private_key = R509::PrivateKey.new(:type => :dsa) + it "generates a DSA key at the default bit length (2048)" do + private_key = R509::PrivateKey.new(:type => "dsa") private_key.dsa?.should == true - private_key.bit_strength.should == 2048 + private_key.bit_length.should == 2048 private_key.key.p.to_i.to_s(2).size.should == 2048 end - it "generates a DSA key at a custom bit strength" do - private_key = R509::PrivateKey.new(:type => :dsa, :bit_strength => 512) - private_key.bit_strength.should == 512 + it "generates a DSA key at a custom bit length" do + private_key = R509::PrivateKey.new(:type => "dsa", :bit_length => 512) + private_key.bit_length.should == 512 private_key.key.p.to_i.to_s(2).size.should == 512 end it "has an exponent of 65537 for new RSA keys" do #this test actually checks ruby's underlying libs to make sure they're #doing what they're supposed to be doing. - private_key = R509::PrivateKey.new(:type => :rsa, :bit_strength => 512) + private_key = R509::PrivateKey.new(:type => "rsa", :bit_length => 512) private_key.key.e.should == 65537 end it "returns the public key" do private_key = R509::PrivateKey.new(:key => @key_csr) private_key.public_key.n.to_i.should == @csr_public_key_modulus.to_i @@ -236,16 +237,16 @@ private_key = R509::PrivateKey.new(:key => @ec_key_pem) private_key.curve_name.should == 'secp384r1' end it "generates an elliptic curve key using the default curve (secp384r1)" do - private_key = R509::PrivateKey.new(:type => :ec) + private_key = R509::PrivateKey.new(:type => "ec") private_key.curve_name.should == 'secp384r1' end it "generates an elliptic curve key using a specified curve" do - private_key = R509::PrivateKey.new(:type => :ec, :curve_name => 'sect283r1') + private_key = R509::PrivateKey.new(:type => "ec", :curve_name => 'sect283r1') private_key.curve_name.should == 'sect283r1' end it "returns the public key" do private_key = R509::PrivateKey.new(:key => @ec_key_pem) @@ -262,12 +263,12 @@ it "returns the der" do private_key = R509::PrivateKey.new(:key => @ec_key_pem) private_key.to_der.should == @ec_key_der end - it "returns error for bit_strength" do + it "returns error for bit_length" do private_key = R509::PrivateKey.new(:key => @ec_key_pem) - expect { private_key.bit_strength }.to raise_error(R509::R509Error,'Bit strength is not available for EC at this time.') + expect { private_key.bit_length }.to raise_error(R509::R509Error,'Bit length is not available for EC at this time.') end end end