зеркало из https://github.com/github/ruby-gpgme.git
GPGME::Ctx#generate_key fixed and with tests
This commit is contained in:
Родитель
c170dcd9aa
Коммит
cb87d30678
|
@ -270,7 +270,7 @@ module GPGME
|
|||
#
|
||||
# If +pubkey+ and +seckey+ are both set to +nil+, it stores the generated
|
||||
# key pair into your key ring.
|
||||
def generate_key(parms, pubkey = Data.new, seckey = Data.new)
|
||||
def generate_key(parms, pubkey = nil, seckey = nil)
|
||||
err = GPGME::gpgme_op_genkey(self, parms, pubkey, seckey)
|
||||
exc = GPGME::error_to_exception(err)
|
||||
raise exc if exc
|
||||
|
|
|
@ -198,6 +198,33 @@ describe GPGME::Ctx do
|
|||
end
|
||||
end
|
||||
|
||||
describe "key generation" do
|
||||
it "generates a key according to specifications" do
|
||||
key = <<-RUBY
|
||||
<GnupgKeyParms format="internal">
|
||||
Key-Type: DSA
|
||||
Key-Length: 1024
|
||||
Subkey-Type: ELG-E
|
||||
Subkey-Length: 1024
|
||||
Name-Real: Key Tester
|
||||
Name-Comment: with some comments
|
||||
Name-Email: test_generation@example.com
|
||||
Expire-Date: 0
|
||||
Passphrase: wadus
|
||||
</GnupgKeyParms>
|
||||
RUBY
|
||||
|
||||
keys_amount = GPGME::Key.find(:public).size
|
||||
GPGME::Ctx.new do |ctx|
|
||||
ctx.generate_key(key.chomp)
|
||||
end
|
||||
|
||||
assert_equal keys_amount + 1, GPGME::Key.find(:public).size
|
||||
|
||||
GPGME::Key.find(:public, "test_generation@example.com").each do |k|
|
||||
k.delete!(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче