test/pgp_test.rb in iostreams-1.2.1 vs test/pgp_test.rb in iostreams-1.3.0
- old
+ new
@@ -68,27 +68,46 @@
describe ".delete_keys" do
it "handles no keys" do
refute IOStreams::Pgp.delete_keys(email: "random@iostreams.net", public: true, private: true)
end
- it "deletes existing keys" do
+ it "deletes existing keys with specified email" do
generated_key_id
# There is a timing issue with creating and then deleting keys.
# Call list_keys again to give GnuPGP time.
IOStreams::Pgp.list_keys(email: email, private: true)
assert IOStreams::Pgp.delete_keys(email: email, public: true, private: true)
end
- it "deletes just the private key" do
+ it "deletes existing keys with specified key_id" do
generated_key_id
+
# There is a timing issue with creating and then deleting keys.
# Call list_keys again to give GnuPGP time.
+ IOStreams::Pgp.list_keys(key_id: generated_key_id, private: true)
+ assert IOStreams::Pgp.delete_keys(key_id: generated_key_id, public: true, private: true)
+ end
+
+ it "deletes just the private key with specified email" do
+ generated_key_id
+ # There is a timing issue with creating and then deleting keys.
+ # Call list_keys again to give GnuPGP time.
IOStreams::Pgp.list_keys(email: email, private: true)
assert IOStreams::Pgp.delete_keys(email: email, public: false, private: true)
refute IOStreams::Pgp.key?(key_id: generated_key_id, private: true)
assert IOStreams::Pgp.key?(key_id: generated_key_id, private: false)
end
+
+ it "deletes just the private key with specified key_id" do
+ generated_key_id
+ # There is a timing issue with creating and then deleting keys.
+ # Call list_keys again to give GnuPGP time.
+ IOStreams::Pgp.list_keys(key_id: generated_key_id, private: true)
+ assert IOStreams::Pgp.delete_keys(key_id: generated_key_id, public: false, private: true)
+ refute IOStreams::Pgp.key?(key_id: generated_key_id, private: true)
+ assert IOStreams::Pgp.key?(key_id: generated_key_id, private: false)
+ end
end
describe ".export" do
before do
generated_key_id
@@ -111,11 +130,11 @@
# There is a timing issue with creating and then immediately using keys.
# Call list_keys again to give GnuPGP time.
IOStreams::Pgp.list_keys(email: email)
end
- it "lists public keys" do
+ it "lists public keys for email" do
assert keys = IOStreams::Pgp.list_keys(email: email)
assert_equal 1, keys.size
assert key = keys.first
assert_equal Date.today, key[:date]
@@ -128,11 +147,42 @@
ver = IOStreams::Pgp.pgp_version
maint = ver.split(".").last.to_i
assert_equal "ultimate", key[:trust] if (ver.to_f >= 2) && (maint >= 30)
end
- it "lists private keys" do
+ it "lists public keys for key_id" do
+ assert keys = IOStreams::Pgp.list_keys(key_id: generated_key_id)
+ assert_equal 1, keys.size
+ assert key = keys.first
+
+ assert_equal Date.today, key[:date]
+ assert_equal email, key[:email]
+ assert_includes key[:key_id], generated_key_id
+ assert_equal 1024, key[:key_length]
+ assert_includes %w[R rsa], key[:key_type]
+ assert_equal user_name, key[:name]
+ refute key[:private], key
+ ver = IOStreams::Pgp.pgp_version
+ maint = ver.split(".").last.to_i
+ assert_equal "ultimate", key[:trust] if (ver.to_f >= 2) && (maint >= 30)
+ end
+
+ it "lists private keys for email" do
assert keys = IOStreams::Pgp.list_keys(email: email, private: true)
+ assert_equal 1, keys.size
+ assert key = keys.first
+
+ assert_equal Date.today, key[:date]
+ assert_equal email, key[:email]
+ assert_includes key[:key_id], generated_key_id
+ assert_equal 1024, key[:key_length]
+ assert_includes %w[R rsa], key[:key_type]
+ assert_equal user_name, key[:name]
+ assert key[:private], key
+ end
+
+ it "lists private keys for key_id" do
+ assert keys = IOStreams::Pgp.list_keys(key_id: generated_key_id, private: true)
assert_equal 1, keys.size
assert key = keys.first
assert_equal Date.today, key[:date]
assert_equal email, key[:email]